<?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="runningcompiledfromcommandline"/>
      <!--
           Generated at 2010-10-29T18:20:48.427+01:00--><title>Saxonica: XSLT and XQuery Processing: Running Compiled Code from the Command Line</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Running Compiled Code from the Command Line"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Running Compiled Code from the Command Line</h1>
      <p><i>This section does not apply to code generated with the <code>-servlet</code> option.</i></p>
      <p>The generated Java code has a main() method allowing it to be run directly from the command
line. This is not the most efficient way of running a query, because of the overhead of starting up
the Java runtime; but it is useful when testing, or to execute a long-running "batch" query.</p>
      <p>The query is run in the same way as any other Java program:</p>
      <p class="command">java <i>query-class</i> [options] [keyword=value]...</p>
      <p>Note that the classpath must include <code>saxon9ee.jar</code> and <code>saxon9ee-gc.jar</code>as well as the directory in which
the Saxon-EE license file is installed.</p>
      <p>The options available on the command line are as follows:</p>
      <table>
         <tr>
            <td content="para">
               <p>Option</p>
            </td>
            <td content="para">
               <p>Meaning</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-s source-file</p>
            </td>
            <td content="para">
               <p>XML source file to be assigned to the initial context node</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-t</p>
            </td>
            <td content="para">
               <p>Display timing, version, and progress information</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-o output-file</p>
            </td>
            <td content="para">
               <p>File to hold the serialized output of the query</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-val</p>
            </td>
            <td content="para">
               <p>Apply strict schema validation to input files.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-vlax</p>
            </td>
            <td content="para">
               <p>Apply lax schema validation to input files</p>
            </td>
         </tr>
      </table>
      <p>A keyword=value pair is used to supply the value of an external variable defined in the
query prolog. If the variable name is in a namespace, the keyword should use Clark notation, that
is "{uri}localname". The value is interpreted as an untypedAtomic value. If the <code>-untyped</code> option
was specified when compiling the code, the value will be cast
to the required type of the variable (for example if the
variable <code>start</code> is declared as an integer, then the value can be supplied in the form
<code>start=42</code>).</p>
      <p>The notation <code>+keyword=filename</code> can be used to initialize an external variable to
hold the document node of an XML document identified by the given filename.</p>
      <p>The notation <code>!keyword=value</code> can be used to set serialization parameters. For example
<code>!indent=yes</code> causes the output to be indented.</p>
      <p>Note that there is no option on the command line to load additional schema documents. Schema
components that are needed during query execution must be derived either from schema documents that
were imported into the query at compile time, or must be referenced using <code>xsi:schemaLocation</code>
in a source document.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="runningcompiledasservlet.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>