## Saxon.Api

Class DocumentBuilder

Class DomDestination

Class DynamicContext

Class DynamicError

Class EmptyEnumerator

Class ExtensionFunctionCall

Class ExtensionFunctionDefinition

Class NullDestination

Class Processor

Class QName

Class SchemaManager

Class SchemaValidator

Class Serializer

Class StaticContext

Class StaticError

Class TextWriterDestination

Class XPathCompiler

Class XPathExecutable

Class XPathSelector

Class XQueryCompiler

Class XQueryEvaluator

Class XQueryExecutable

Class XdmAnyFunctionType

Class XdmAnyItemType

Class XdmAnyNodeType

Class XdmAtomicType

Class XdmAtomicValue

Class XdmDestination

Class XdmEmptySequence

Class XdmFunctionItem

Class XdmItem

Class XdmItemType

Class XdmNode

Class XdmNodeKind

Class XdmSequenceType

Class XdmValue

Class XmlDestination

Class XsltCompiler

Class XsltExecutable

Class XsltTransformer

Enum RecoveryPolicy

Enum SchemaValidationMode

Enum TreeModel

Enum WhitespacePolicy

Enum XdmAxis

Interface IMessageListener

Interface IQueryResolver

Interface IResultDocumentHandler

Interface IXdmEnumerator

Interface IXmlLocation

Interface SchemaResolver

## Saxon.Api
Class XQueryCompiler

    public class XQueryCompiler

implements object

  An XQueryCompiler object allows XQuery queries to be compiled.

  To construct an `XQueryCompiler`, use the factory method `newXQueryCompiler` on the `Processor` object.

  The `XQueryCompiler` holds information that represents the static context for the queries that it compiles. This information remains intact after performing a compilation. An `XQueryCompiler` may therefore be used repeatedly to compile multiple queries. Any changes made to the `XQueryCompiler` (that is, to the static context) do not affect queries that have already been compiled. An `XQueryCompiler` may be used concurrently in multiple threads, but it should not then be modified once initialized.

Property Summary
`Processor` | `Processor` Get the Processor from which this XQueryCompiler was constructed
`XdmItemType` | `ContextItemType` 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.
`String` | `BaseUri` 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 `doc()` function.
`Boolean` | `SchemaAware` 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.
`bool` | `UpdatingEnabled` 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.
`string` | `XQueryLanguageVersion` 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.
`IQueryResolver` | `QueryResolver` A user-supplied `IQueryResolver` used to resolve location hints appearing in an `import module` declaration.
`IList` | `ErrorList` 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.
`net.sf.saxon.query.StaticQueryContext` | `Implementation` Escape hatch to the underying Java implementation

Method Summary
`void` | `DeclareCollation(System.Uri uri, System.Globalization.CompareInfo comparerInfo, System.Globalization.CompareOptions options, bool isDefault)` Create a collation based on a given `CompareInfo` and `CompareOptions`
`void` | `DeclareNamespace(string prefix, string uri)` 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)
`XQueryExecutable` | `Compile(System.IO.Stream query)` Compile a query supplied as a Stream.
`XQueryExecutable` | `Compile(string query)` Compile a query supplied as a String.

Property Detail

### Processor

    public Processor Processor {get; set; }

  Get the Processor from which this XQueryCompiler was constructed

### ContextItemType

    public XdmItemType ContextItemType {get; set; }

  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.

### BaseUri

    public String BaseUri {get; set; }

  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 `doc()` function.

### SchemaAware

    public Boolean SchemaAware {get; set; }

  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.

### UpdatingEnabled

    public bool UpdatingEnabled {get; set; }

  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.

  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.

  Property added in Saxon 9.1

### XQueryLanguageVersion

    public string XQueryLanguageVersion {get; set; }

  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.

  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.

  Property added in Saxon 9.2

### QueryResolver

    public IQueryResolver QueryResolver {get; set; }

  A user-supplied `IQueryResolver` used to resolve location hints appearing in an `import module` declaration.

  In the absence of a user-supplied `QueryResolver`, an `import module` 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 `XmlResolver` registered with the `Processor`.

### ErrorList

    public IList ErrorList {get; set; }

  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.

  By supplying a custom List with a user-written add() method, it is possible to intercept error conditions as they occur.

### Implementation

    public net.sf.saxon.query.StaticQueryContext Implementation {get; }

  Escape hatch to the underying Java implementation

Method Detail

### DeclareCollation

    public void DeclareCollation(System.Uri uri,
                            System.Globalization.CompareInfo comparerInfo,
                            System.Globalization.CompareOptions options,
                            bool isDefault)

  Create a collation based on a given `CompareInfo` and `CompareOptions`

  Parameters:
  `uri` -
    The collation URI to be used within the XPath expression to refer to this collation
  `comparerInfo` -
    The `CompareInfo`, which determines the language-specific collation rules to be used
  `options` -
    Options to be used in performing comparisons, for example whether they are to be case-blind and/or accent-blind
  `isDefault` -
    If true, this collation will be used as the default collation

### DeclareNamespace

    public void DeclareNamespace(string prefix,
                            string uri)

  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)

  Parameters:
  `prefix` -
    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).
  `uri` -
    The namespace URI. It is possible to specify a zero-length string to "undeclare" a namespace.

### Compile

    public XQueryExecutable Compile(System.IO.Stream query)

  Compile a query supplied as a Stream.

  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 `CanSeek` property. If no encoding information is present, UTF-8 is assumed.

  The base URI of the query is set to the value of the `BaseUri` 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.

  Parameters:
  `query` -
    A stream containing the source text of the query
  returns
    An `XQueryExecutable` which represents the compiled query object. The XQueryExecutable may be run as many times as required, in the same or a different thread. The `XQueryExecutable` is not affected by any changes made to the `XQueryCompiler` once it has been compiled.

### Compile

    public XQueryExecutable Compile(string query)

  Compile a query supplied as a String.

  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.

  Parameters:
  `query` -
    A string containing the source text of the query
  returns
    An `XQueryExecutable` which represents the compiled query object. The XQueryExecutable may be run as many times as required, in the same or a different thread. The `XQueryExecutable` is not affected by any changes made to the `XQueryCompiler` once it has been compiled.