<?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=""/>
      <!--
           Generated at 2010-10-29T18:20:48.427+01:00--><title>Saxonica: XSLT and XQuery Processing: Compiling Queries to Java code</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Compiling Queries to Java code"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Compiling Queries to Java code</h1>
      <p>Saxon-EE provides the capability to compile a query to Java source code.
The Java source code can then be compiled to byte code in a class file, which can be executed in the
same way as any other Java program.</p>
      <p>This is achieved by adding a code-generation phase to the existing query analysis phase. The query
analyzer generates an optimized expression tree in memory. In interpreted execution, the run time
system evaluates this expression tree directly. With compiled execution, the expression tree
is compiled to Java code. The Java code makes calls on the Saxon run-time to perform operations such
as navigating the source tree and serializing the output.</p>
      <p>The following sections discuss Java code generation in more detail.</p>
      <ul>
         <li>
            <p><a class="bodylink" href="querycompilation/limitations.xml">Limitations</a></p>
         </li>
         <li>
            <p><a class="bodylink" href="querycompilation/compilercommandline.xml">Java Code Generation from the Command Line</a></p>
         </li>
         <li>
            <p><a class="bodylink" href="querycompilation/runningcompiledfromcommandline.xml">Running Compiled Code from the Command Line</a></p>
         </li>
         <li>
            <p><a class="bodylink" href="querycompilation/runningcompiledasservlet.xml">Running a Compiled Query as a Servlet</a></p>
         </li>
         <li>
            <p><a class="bodylink" href="querycompilation/callingcompiledfromapp.xml">Calling Compiled Queries from an Application</a></p>
         </li>
      </ul>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="querycompilation/limitations.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>