<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="using-xquery" page="querycompilation" subpage="callingcompiledfromapp"/>
      <!--
           Generated at 2010-10-29T18:20:48.427+01:00--><title>Saxonica: XSLT and XQuery Processing: Calling Compiled Queries from an Application</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Calling Compiled Queries from an Application"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Calling Compiled Queries from an Application</h1>
      <p><i>This section does not apply to code generated with the <code>-servlet</code> option.</i></p>
      <p>When a query is compiled, as well as having a <code>main</code> method allowing invocation from the
operating system command line, it will also have a <code>run()</code> method allowing invocation from
a Java application. This takes two parameters: a JAXP <code>Result</code> object to define the destination
of the query output, and an <code>outputProperties</code> value to define serialization properties.</p>
      <p>A query compiled in this way is not thread-safe. A new instance of the generated class should be created
in each thread. Within a thread, the object is serially reusable.</p>
      <p>Parameters to the query may be supplied using the method <code>setExternalVariable</code>. This accepts the
name of the variable in Clark notation ({uri}local), and the value as an instance of Saxon's
<code>ValueRepresentation</code> class. Most commonly this will be a <code>StringValue</code>, an <code>Int64Value</code>,
or a <code>BooleanValue</code>.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="../extensibility.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>