<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="extensions" page="functions" subpage="compile-query"/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: saxon:compile-query()</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: saxon:compile-query()"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>saxon:compile-query()</h1>
      <p><b>saxon:compile-query($query as xs:string) ==&gt; jt:net.sf.saxon.query.XQueryExpression</b></p>
      <p>This function takes as input a string containing an XQuery query, and produces as output a compiled
query suitable for use with the <a class="bodylink" href="../../extensions/functions/query.xml">saxon:query()</a> extension function.</p>
      <p>The static context for the query (for example, its namespace bindings and its base URI) must be defined
within its own query prolog. It does not inherit any context values from the query or stylesheet in which
the <code>saxon:compile-query()</code> function is called. The query cannot access variables or functions
defined in the containing query or stylesheet.</p>
      <p>There are several ways the string containing the query might be constructed. It can be built directly as
a dynamic string in the calling application. In the case of XSLT, it can be read from a file using
the <code>unparsed-text()</code> function. It can also be generated by calling saxon:serialize() on an XML
representation of the query, using 
<a class="bodylink" href="../../extensions/output-extras/xquery-method.xml">the serialization method saxon:xquery</a></p>
      <p>The compiled query can be evaluated (repeatedly) using the <a class="bodylink" href="../../extensions/functions/query.xml">saxon:query()</a>
extension function.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="compile-stylesheet.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>