<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>XQueryCompiler</title> <meta name="keywords" content="Saxon.Api.XQueryCompiler class"> <link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style"> </head> <body> <div style="width:20%; float:left; background-color:#c1cede; overflow:auto; height:100%"> <h2>Saxon.Api</h2> <div style="position:relative; height:4pt"> <p>Class <a href="DocumentBuilder.html">DocumentBuilder</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="DomDestination.html">DomDestination</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="DynamicContext.html">DynamicContext</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="DynamicError.html">DynamicError</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="EmptyEnumerator.html">EmptyEnumerator</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="ExtensionFunctionCall.html">ExtensionFunctionCall</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="ExtensionFunctionDefinition.html">ExtensionFunctionDefinition</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="NullDestination.html">NullDestination</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="Processor.html">Processor</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="QName.html">QName</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="SchemaManager.html">SchemaManager</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="SchemaValidator.html">SchemaValidator</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="Serializer.html">Serializer</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="StaticContext.html">StaticContext</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="StaticError.html">StaticError</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="TextWriterDestination.html">TextWriterDestination</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XPathCompiler.html">XPathCompiler</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XPathExecutable.html">XPathExecutable</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XPathSelector.html">XPathSelector</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XQueryCompiler.html">XQueryCompiler</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XQueryEvaluator.html">XQueryEvaluator</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XQueryExecutable.html">XQueryExecutable</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XdmAnyFunctionType.html">XdmAnyFunctionType</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XdmAnyItemType.html">XdmAnyItemType</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XdmAnyNodeType.html">XdmAnyNodeType</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XdmAtomicType.html">XdmAtomicType</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XdmAtomicValue.html">XdmAtomicValue</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XdmDestination.html">XdmDestination</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XdmEmptySequence.html">XdmEmptySequence</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XdmFunctionItem.html">XdmFunctionItem</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XdmItem.html">XdmItem</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XdmItemType.html">XdmItemType</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XdmNode.html">XdmNode</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XdmNodeKind.html">XdmNodeKind</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XdmSequenceType.html">XdmSequenceType</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XdmValue.html">XdmValue</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XmlDestination.html">XmlDestination</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XsltCompiler.html">XsltCompiler</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XsltExecutable.html">XsltExecutable</a></p> </div> <div style="position:relative; height:4pt"> <p>Class <a href="XsltTransformer.html">XsltTransformer</a></p> </div> <div style="position:relative; height:4pt"> <p>Enum <a href="RecoveryPolicy.html">RecoveryPolicy</a></p> </div> <div style="position:relative; height:4pt"> <p>Enum <a href="SchemaValidationMode.html">SchemaValidationMode</a></p> </div> <div style="position:relative; height:4pt"> <p>Enum <a href="TreeModel.html">TreeModel</a></p> </div> <div style="position:relative; height:4pt"> <p>Enum <a href="WhitespacePolicy.html">WhitespacePolicy</a></p> </div> <div style="position:relative; height:4pt"> <p>Enum <a href="XdmAxis.html">XdmAxis</a></p> </div> <div style="position:relative; height:4pt"> <p>Interface <a href="IMessageListener.html">IMessageListener</a></p> </div> <div style="position:relative; height:4pt"> <p>Interface <a href="IQueryResolver.html">IQueryResolver</a></p> </div> <div style="position:relative; height:4pt"> <p>Interface <a href="IResultDocumentHandler.html">IResultDocumentHandler</a></p> </div> <div style="position:relative; height:4pt"> <p>Interface <a href="IXdmEnumerator.html">IXdmEnumerator</a></p> </div> <div style="position:relative; height:4pt"> <p>Interface <a href="IXmlLocation.html">IXmlLocation</a></p> </div> <div style="position:relative; height:4pt"> <p>Interface <a href="SchemaResolver.html">SchemaResolver</a></p> </div> </div> <div style="width:5%; float:left; background-color:#e4eef0; overflow:auto; height:100%"> </div> <div style="float:left; width:75%; overflow:auto; height:100%;"> <h2><font size="-1">Saxon.Api</font><br>Class XQueryCompiler </h2> <hr> <dl> <dt><pre>public class XQueryCompiler</pre></dt> <dt> implements <a href="http://msdn.microsoft.com/en-us/library/system.object(VS.80).aspx">object</a></dt> </dl> <dl> <dd> <p> An XQueryCompiler object allows XQuery queries to be compiled. </p> <p>To construct an <code>XQueryCompiler</code>, use the factory method <code>newXQueryCompiler</code> on the <code>Processor</code> object. </p> <p>The <code>XQueryCompiler</code> holds information that represents the static context for the queries that it compiles. This information remains intact after performing a compilation. An <code>XQueryCompiler</code> may therefore be used repeatedly to compile multiple queries. Any changes made to the <code>XQueryCompiler</code> (that is, to the static context) do not affect queries that have already been compiled. An <code>XQueryCompiler</code> may be used concurrently in multiple threads, but it should not then be modified once initialized. </p> </dd> </dl> <hr><a name="property_summary"></a><table border="1" width="100%" cellpadding="3" cellspacing="0" summary=""> <tr border="#ccccff" class="TableHeadingColor"> <th align="left" colspan="2"><font size="+2"><b>Property Summary</b></font></th> </tr> <tr bgcolor="white" class="TableRowColor"> <td align="right" valign="top" width="1%"><code> <a href="Processor.html">Processor</a></code></td> <td><code><b><a href="#Processor">Processor</a></b></code><p> Get the Processor from which this XQueryCompiler was constructed </p> </td> </tr> <tr bgcolor="white" class="TableRowColor"> <td align="right" valign="top" width="1%"><code> <a href="XdmItemType.html">XdmItemType</a></code></td> <td><code><b><a href="#ContextItemType">ContextItemType</a></b></code><p> The required context item type for the expression. This is used for optimizing the expression at compile time, and to check at run-time that the value supplied for the context item is the correct type. </p> </td> </tr> <tr bgcolor="white" class="TableRowColor"> <td align="right" valign="top" width="1%"><code> <a href="http://msdn.microsoft.com/en-us/library/system.string(VS.80).aspx">String</a></code></td> <td><code><b><a href="#BaseUri">BaseUri</a></b></code><p> The base URI of the query, which forms part of the static context of the query. This is used for resolving any relative URIs appearing within the query, for example in references to library modules, schema locations, or as an argument to the <code>doc()</code> function. </p> </td> </tr> <tr bgcolor="white" class="TableRowColor"> <td align="right" valign="top" width="1%"><code> Boolean</code></td> <td><code><b><a href="#SchemaAware">SchemaAware</a></b></code><p> Say that the query must be compiled to be schema-aware, even if it contains no "import schema" declarations. Normally a query is treated as schema-aware only if it contains one or more "import schema" declarations. If it is not schema-aware, then all input documents must be untyped (or xs:anyType), and validation of temporary nodes is disallowed (though validation of the final result tree is permitted). Setting the argument to true means that schema-aware code will be compiled regardless. schemaAware If true, the stylesheet will be compiled with schema-awareness enabled even if it contains no xsl:import-schema declarations. If false, the stylesheet is treated as schema-aware only if it contains one or more xsl:import-schema declarations. </p> </td> </tr> <tr bgcolor="white" class="TableRowColor"> <td align="right" valign="top" width="1%"><code> <a href="http://msdn.microsoft.com/en-us/library/system.boolean(VS.80).aspx">bool</a></code></td> <td><code><b><a href="#UpdatingEnabled">UpdatingEnabled</a></b></code><p> This property indicates whether XQuery Update syntax is accepted. The default value is false. This property must be set to true before compiling a query that uses update syntax. </p> </td> </tr> <tr bgcolor="white" class="TableRowColor"> <td align="right" valign="top" width="1%"><code> <a href="http://msdn.microsoft.com/en-us/library/system.string(VS.80).aspx">string</a></code></td> <td><code><b><a href="#XQueryLanguageVersion">XQueryLanguageVersion</a></b></code><p> This property indicates which version of XQuery language syntax is accepted. The default value is "1.0". This property must be set to "3.0" before compiling a query that uses XQuery 3.0 (formerly known as XQuery 1.1) syntax. </p> </td> </tr> <tr bgcolor="white" class="TableRowColor"> <td align="right" valign="top" width="1%"><code> <a href="IQueryResolver.html">IQueryResolver</a></code></td> <td><code><b><a href="#QueryResolver">QueryResolver</a></b></code><p> A user-supplied <code>IQueryResolver</code> used to resolve location hints appearing in an <code>import module</code> declaration. </p> </td> </tr> <tr bgcolor="white" class="TableRowColor"> <td align="right" valign="top" width="1%"><code> <a href="http://msdn.microsoft.com/en-us/library/system.collections.ilist(VS.80).aspx">IList</a></code></td> <td><code><b><a href="#ErrorList">ErrorList</a></b></code><p> List of errors. The caller should supply an empty list before calling Compile; the processor will then populate the list with error information obtained during the compilation. Each error will be included as an object of type StaticError. If no error list is supplied by the caller, error information will be written to the standard error stream. </p> </td> </tr> <tr bgcolor="white" class="TableRowColor"> <td align="right" valign="top" width="1%"><code> <a href="../../../javadoc/net/sf/saxon/query/StaticQueryContext.html">net.sf.saxon.query.StaticQueryContext</a></code></td> <td><code><b><a href="#Implementation">Implementation</a></b></code><p> Escape hatch to the underying Java implementation </p> </td> </tr> </table> <a name="method_summary"></a><table border="1" width="100%" cellpadding="3" cellspacing="0" summary=""> <tr border="#ccccff" class="TableHeadingColor"> <th align="left" colspan="2"><font size="+2"><b>Method Summary</b></font></th> </tr> <tr bgcolor="white" class="TableRowColor"> <td align="right" valign="top" width="1%"><code> void</code></td> <td><code><b><a href="#DeclareCollation(System.Uri,System.Globalization.CompareInfo,System.Globalization.CompareOptions,bool)">DeclareCollation</a></b>(System.Uri uri, System.Globalization.CompareInfo comparer, System.Globalization.CompareOptions options, <a href="http://msdn.microsoft.com/en-us/library/system.boolean(VS.80).aspx">bool</a> isDefault)</code><p> Create a collation based on a given <code>CompareInfo</code> and <code>CompareOptions</code> </p> </td> </tr> <tr bgcolor="white" class="TableRowColor"> <td align="right" valign="top" width="1%"><code> void</code></td> <td><code><b><a href="#DeclareNamespace(string,string)">DeclareNamespace</a></b>(<a href="http://msdn.microsoft.com/en-us/library/system.string(VS.80).aspx">string</a> prefix, <a href="http://msdn.microsoft.com/en-us/library/system.string(VS.80).aspx">string</a> uri)</code><p> Declare a namespace for use by the query. This has the same status as a namespace appearing within the query prolog (though a declaration in the query prolog of the same prefix will take precedence) </p> </td> </tr> <tr bgcolor="white" class="TableRowColor"> <td align="right" valign="top" width="1%"><code> <a href="XQueryExecutable.html">XQueryExecutable</a></code></td> <td><code><b><a href="#Compile(System.IO.Stream)">Compile</a></b>(<a href="http://msdn.microsoft.com/en-us/library/system.io.stream(VS.80).aspx">System.IO.Stream</a> query)</code><p> Compile a query supplied as a Stream. </p> </td> </tr> <tr bgcolor="white" class="TableRowColor"> <td align="right" valign="top" width="1%"><code> <a href="XQueryExecutable.html">XQueryExecutable</a></code></td> <td><code><b><a href="#Compile(string)">Compile</a></b>(<a href="http://msdn.microsoft.com/en-us/library/system.string(VS.80).aspx">string</a> query)</code><p> Compile a query supplied as a String. </p> </td> </tr> </table> <a name="property_detail"></a><table border="1" width="100%" cellpadding="3" cellspacing="0" summary=""> <tr border="#ccccff" class="TableHeadingColor"> <th align="left" colspan="2"><font size="+2"><b>Property Detail</b></font></th> </tr> </table><a name="Processor"></a><h3>Processor</h3><pre>public <a href="Processor.html">Processor</a> <b>Processor</b> {get; set; }</pre><dl> <dd> <p> Get the Processor from which this XQueryCompiler was constructed </p> </dd> </dl> <hr><a name="ContextItemType"></a><h3>ContextItemType</h3><pre>public <a href="XdmItemType.html">XdmItemType</a> <b>ContextItemType</b> {get; set; }</pre><dl> <dd> <p> The required context item type for the expression. This is used for optimizing the expression at compile time, and to check at run-time that the value supplied for the context item is the correct type. </p> </dd> </dl> <hr><a name="BaseUri"></a><h3>BaseUri</h3><pre>public <a href="http://msdn.microsoft.com/en-us/library/system.string(VS.80).aspx">String</a> <b>BaseUri</b> {get; set; }</pre><dl> <dd> <p> The base URI of the query, which forms part of the static context of the query. This is used for resolving any relative URIs appearing within the query, for example in references to library modules, schema locations, or as an argument to the <code>doc()</code> function. </p> </dd> </dl> <hr><a name="SchemaAware"></a><h3>SchemaAware</h3><pre>public Boolean <b>SchemaAware</b> {get; set; }</pre><dl> <dd> <p> Say that the query must be compiled to be schema-aware, even if it contains no "import schema" declarations. Normally a query is treated as schema-aware only if it contains one or more "import schema" declarations. If it is not schema-aware, then all input documents must be untyped (or xs:anyType), and validation of temporary nodes is disallowed (though validation of the final result tree is permitted). Setting the argument to true means that schema-aware code will be compiled regardless. schemaAware If true, the stylesheet will be compiled with schema-awareness enabled even if it contains no xsl:import-schema declarations. If false, the stylesheet is treated as schema-aware only if it contains one or more xsl:import-schema declarations. </p> </dd> </dl> <hr><a name="UpdatingEnabled"></a><h3>UpdatingEnabled</h3><pre>public <a href="http://msdn.microsoft.com/en-us/library/system.boolean(VS.80).aspx">bool</a> <b>UpdatingEnabled</b> {get; set; }</pre><dl> <dd> <p> This property indicates whether XQuery Update syntax is accepted. The default value is false. This property must be set to true before compiling a query that uses update syntax. </p> <p>This propery must be set to true before any query can be compiled that uses updating syntax. This applies even if the query is not actually an updating query (for example, a copy-modify expression). XQuery Update syntax is accepted only by Saxon-SA. Non-updating queries are accepted regardless of the value of this property. </p> <p> <i>Property added in Saxon 9.1</i> </p> </dd> </dl> <hr><a name="XQueryLanguageVersion"></a><h3>XQueryLanguageVersion</h3><pre>public <a href="http://msdn.microsoft.com/en-us/library/system.string(VS.80).aspx">string</a> <b>XQueryLanguageVersion</b> {get; set; }</pre><dl> <dd> <p> This property indicates which version of XQuery language syntax is accepted. The default value is "1.0". This property must be set to "3.0" before compiling a query that uses XQuery 3.0 (formerly known as XQuery 1.1) syntax. </p> <p>Support for XQuery 3.0 is currently limited: for details see the Saxon documentation. It cannot be used together with XQuery Updates. As well as enabling XQuery 3.0 via this API call, it must also be enabled by setting version="3.0" in the query prolog. </p> <p> <i>Property added in Saxon 9.2</i> </p> </dd> </dl> <hr><a name="QueryResolver"></a><h3>QueryResolver</h3><pre>public <a href="IQueryResolver.html">IQueryResolver</a> <b>QueryResolver</b> {get; set; }</pre><dl> <dd> <p> A user-supplied <code>IQueryResolver</code> used to resolve location hints appearing in an <code>import module</code> declaration. </p> <p>In the absence of a user-supplied <code>QueryResolver</code>, an <code>import module</code> declaration is interpreted as follows. First, if the module URI identifies an already loaded module, that module is used and the location hints are ignored. Otherwise, each URI listed in the location hints is resolved using the <code>XmlResolver</code> registered with the <code>Processor</code>. </p> </dd> </dl> <hr><a name="ErrorList"></a><h3>ErrorList</h3><pre>public <a href="http://msdn.microsoft.com/en-us/library/system.collections.ilist(VS.80).aspx">IList</a> <b>ErrorList</b> {get; set; }</pre><dl> <dd> <p> List of errors. The caller should supply an empty list before calling Compile; the processor will then populate the list with error information obtained during the compilation. Each error will be included as an object of type StaticError. If no error list is supplied by the caller, error information will be written to the standard error stream. </p> <p> By supplying a custom List with a user-written add() method, it is possible to intercept error conditions as they occur. </p> </dd> </dl> <hr><a name="Implementation"></a><h3>Implementation</h3><pre>public <a href="../../../javadoc/net/sf/saxon/query/StaticQueryContext.html">net.sf.saxon.query.StaticQueryContext</a> <b>Implementation</b> {get; }</pre><dl> <dd> <p> Escape hatch to the underying Java implementation </p> </dd> </dl> <hr><a name="method_detail"></a><table border="1" width="100%" cellpadding="3" cellspacing="0" summary=""> <tr border="#ccccff" class="TableHeadingColor"> <th align="left" colspan="2"><font size="+2"><b>Method Detail</b></font></th> </tr> </table><a name="DeclareCollation(System.Uri,System.Globalization.CompareInfo,System.Globalization.CompareOptions,bool)"></a><h3>DeclareCollation</h3><pre>public void <b>DeclareCollation</b>(System.Uri uri, System.Globalization.CompareInfo comparer, System.Globalization.CompareOptions options, <a href="http://msdn.microsoft.com/en-us/library/system.boolean(VS.80).aspx">bool</a> isDefault)</pre><dl> <dd> <p> Create a collation based on a given <code>CompareInfo</code> and <code>CompareOptions</code> </p><b>Parameters:</b><dl> <dt><code>uri</code> - </dt> <dd>The collation URI to be used within the XPath expression to refer to this collation</dd> </dl> <dl> <dt><code>comparer</code> - </dt> <dd>The <code>CompareInfo</code>, which determines the language-specific collation rules to be used </dd> </dl> <dl> <dt><code>options</code> - </dt> <dd>Options to be used in performing comparisons, for example whether they are to be case-blind and/or accent-blind </dd> </dl> <dl> <dt><code>isDefault</code> - </dt> <dd>If true, this collation will be used as the default collation</dd> </dl> </dd> </dl> <hr><a name="DeclareNamespace(string,string)"></a><h3>DeclareNamespace</h3><pre>public void <b>DeclareNamespace</b>(<a href="http://msdn.microsoft.com/en-us/library/system.string(VS.80).aspx">string</a> prefix, <a href="http://msdn.microsoft.com/en-us/library/system.string(VS.80).aspx">string</a> uri)</pre><dl> <dd> <p> Declare a namespace for use by the query. This has the same status as a namespace appearing within the query prolog (though a declaration in the query prolog of the same prefix will take precedence) </p><b>Parameters:</b><dl> <dt><code>prefix</code> - </dt> <dd>The namespace prefix to be declared. Use a zero-length string to declare the default namespace (that is, the default namespace for elements and types). </dd> </dl> <dl> <dt><code>uri</code> - </dt> <dd>The namespace URI. It is possible to specify a zero-length string to "undeclare" a namespace. </dd> </dl> </dd> </dl> <hr><a name="Compile(System.IO.Stream)"></a><h3>Compile</h3><pre>public <a href="XQueryExecutable.html">XQueryExecutable</a> <b>Compile</b>(<a href="http://msdn.microsoft.com/en-us/library/system.io.stream(VS.80).aspx">System.IO.Stream</a> query)</pre><dl> <dd> <p> Compile a query supplied as a Stream. </p> <p>The XQuery processor attempts to deduce the encoding of the query by looking for a byte-order-mark, or if none is present, by looking for the encoding declaration in the XQuery version declaration. For this to work, the stream must have the <code>CanSeek</code> property. If no encoding information is present, UTF-8 is assumed. </p> <p>The base URI of the query is set to the value of the <code>BaseUri</code> property. If this has not been set, then the base URI will be undefined, which means that any use of an expression that depends on the base URI will cause an error. </p> <b>Parameters:</b><dl> <dt><code>query</code> - </dt> <dd>A stream containing the source text of the query</dd> </dl> <dl> <dt>returns</dt> <dd>An <code>XQueryExecutable</code> which represents the compiled query object. The XQueryExecutable may be run as many times as required, in the same or a different thread. The <code>XQueryExecutable</code> is not affected by any changes made to the <code>XQueryCompiler</code> once it has been compiled. </dd> </dl> </dd> </dl> <hr><a name="Compile(string)"></a><h3>Compile</h3><pre>public <a href="XQueryExecutable.html">XQueryExecutable</a> <b>Compile</b>(<a href="http://msdn.microsoft.com/en-us/library/system.string(VS.80).aspx">string</a> query)</pre><dl> <dd> <p> Compile a query supplied as a String. </p> <p> Using this method the query processor is provided with a string of Unicode characters, so no decoding is necessary. Any encoding information present in the version declaration is therefore ignored. </p><b>Parameters:</b><dl> <dt><code>query</code> - </dt> <dd>A string containing the source text of the query</dd> </dl> <dl> <dt>returns</dt> <dd>An <code>XQueryExecutable</code> which represents the compiled query object. The XQueryExecutable may be run as many times as required, in the same or a different thread. The <code>XQueryExecutable</code> is not affected by any changes made to the <code>XQueryCompiler</code> once it has been compiled. </dd> </dl> </dd> </dl> <hr> </div> </body> </html>