## Saxon.Api

Class DocumentBuilder

Class DomDestination

Class DynamicError

Class NullDestination

Class Processor

Class QName

Class SchemaManager

Class SchemaValidator

Class SequenceEnumerator

Class Serializer

Class StaticError

Class TextWriterDestination

Class XPathCompiler

Class XPathExecutable

Class XPathSelector

Class XQueryCompiler

Class XQueryEvaluator

Class XQueryExecutable

Class XdmAtomicValue

Class XdmDestination

Class XdmEmptySequence

Class XdmItem

Class XdmNode

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 IXmlLocation

Interface SchemaResolver

## Saxon.Api
Class XPathCompiler

    public class XPathCompiler

implements object

  An XPathCompiler object allows XPath queries to be compiled. The compiler holds information that represents the static context for the expression.

  To construct an XPathCompiler, use the factory method `newXPathCompiler` on the `Processor` object.

  An XPathCompiler may be used repeatedly to compile multiple queries. Any changes made to the XPathCompiler (that is, to the static context) do not affect queries that have already been compiled. An XPathCompiler may be used concurrently in multiple threads, but it should not then be modified once initialized.

Property Summary
`String` | `BaseUri` The base URI of the expression, which forms part of the static context of the expression. This is used for resolving any relative URIs appearing within the expression, for example in references to library modules, schema locations, or as an argument to the `doc()` function.
`Boolean` | `BackwardsCompatible` XPath 1.0 Backwards Compatibility Mode. If true, backwards compatibility mode is set. In backwards compatibility mode, more implicit type conversions are allowed in XPath expressions, for example it is possible to compare a number with a string. The default is false (backwards compatibility mode is off).

Method Summary
`void` | `DeclareNamespace(string prefix, string uri)` Declare a namespace for use by the XPath expression.
`void` | `ImportSchemaNamespace(string uri)` Import schema definitions for a specified namespace. That is, add the element and attribute declarations and type definitions contained in a given namespace to the static context for the XPath expression.
`void` | `DeclareVariable(QName name)` Declare a variable for use by the XPath expression. If the expression refers to any variables, then they must be declared here.
`XPathExecutable` | `Compile(string source)` Compile an expression supplied as a String.

Property Detail

### BaseUri

    public String BaseUri {get; set; }

  The base URI of the expression, which forms part of the static context of the expression. This is used for resolving any relative URIs appearing within the expression, for example in references to library modules, schema locations, or as an argument to the `doc()` function.

### BackwardsCompatible

    public Boolean BackwardsCompatible {get; set; }

  XPath 1.0 Backwards Compatibility Mode. If true, backwards compatibility mode is set. In backwards compatibility mode, more implicit type conversions are allowed in XPath expressions, for example it is possible to compare a number with a string. The default is false (backwards compatibility mode is off).

Method Detail

### DeclareNamespace

    public void DeclareNamespace(string prefix,
                            string uri)

  Declare a namespace for use by the XPath expression.

  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.

### ImportSchemaNamespace

    public void ImportSchemaNamespace(string uri)

  Import schema definitions for a specified namespace. That is, add the element and attribute declarations and type definitions contained in a given namespace to the static context for the XPath expression.

  This method will not cause the schema to be loaded. That must be done separately, using the `SchemaManager`}. This method will not fail if the schema has not been loaded (but in that case the set of declarations and definitions made available to the XPath expression is empty). The schema document for the specified namespace may be loaded before or after this method is called.

  This method does not bind a prefix to the namespace. That must be done separately, using the `declareNamespace` method.

  Parameters:
  `uri` -
    The namespace URI whose declarations and type definitions are to be made available for use within the XPath expression.

### DeclareVariable

    public void DeclareVariable(QName name)

  Declare a variable for use by the XPath expression. If the expression refers to any variables, then they must be declared here.

  Parameters:
  `name` -
    The name of the variable, as a `QName`

### Compile

    public XPathExecutable Compile(string source)

  Compile an expression supplied as a String.

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