## 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 XQueryEvaluator

    public class XQueryEvaluator

implements IEnumerable

  An `XQueryEvaluator` represents a compiled and loaded query ready for execution. The `XQueryEvaluator` holds details of the dynamic evaluation context for the query.

  An `XQueryEvaluator` should not be used concurrently in multiple threads. It is safe, however, to reuse the object within a single thread to run the same query several times. Running the query does not change the context that has been established.

  An `XQueryEvaluator` is always constructed by running the `Load` method of an `XQueryExecutable`.

Property Summary
`XdmItem` | `ContextItem` The context item for the query.
`XmlResolver` | `InputXmlResolver` The `XmlResolver` to be used at run-time to resolve and dereference URIs supplied to the `doc()` function.
`Stream` | `TraceFunctionDestination` Destination for output of messages produced using <trace()>. If no specific destination is supplied by the caller, message information will be written to the standard error stream.

Method Summary
`void` | `SetExternalVariable(QName name, XdmValue value)` Set the value of an external variable declared in the query.
`XdmValue` | `Evaluate()` Evaluate the query, returning the result as an `XdmValue` (that is, a sequence of nodes and/or atomic values).
`XdmItem` | `EvaluateSingle()` Evaluate the query, returning the result as an `XdmItem` (that is, a single node or atomic value).
`IEnumerator` | `GetEnumerator()` Evaluate the query, returning the result as an `IEnumerator` (that is, an enumerator over a sequence of nodes and/or atomic values).
`void` | `Run(XmlDestination destination)` Evaluate the query, sending the result to a specified destination.
`XdmNode[]` | `RunUpdate()` Execute an updating query.

Property Detail

### ContextItem

    public XdmItem ContextItem {get; set; }

  The context item for the query.

  This may be either a node or an atomic value. Most commonly it will be a document node, which might be constructed using the `LoadDocument` method of the `Processor` object.

### InputXmlResolver

    public XmlResolver InputXmlResolver {get; set; }

  The `XmlResolver` to be used at run-time to resolve and dereference URIs supplied to the `doc()` function.

### TraceFunctionDestination

    public Stream TraceFunctionDestination {get; set; }

  Destination for output of messages produced using <trace()>.

  If no specific destination is supplied by the caller, message information will be written to the standard error stream.

  The supplied destination is ignored if a `TraceListener` is in use.

  Property added in Saxon 9.1

Method Detail

### SetExternalVariable

    public void SetExternalVariable(QName name,
                               XdmValue value)

  Set the value of an external variable declared in the query.

  Parameters:
  `name` -
    The name of the external variable, expressed as a QName. If an external variable of this name has been declared in the query prolog, the given value will be assigned to the variable. If the variable has not been declared, calling this method has no effect (it is not an error).
  `value` -
    The value to be given to the external variable. If the variable declaration defines a required type for the variable, then this value must match the required type: no conversions are applied.

### Evaluate

    public XdmValue Evaluate()

  Evaluate the query, returning the result as an `XdmValue` (that is, a sequence of nodes and/or atomic values).

  returns
    An `XdmValue` representing the results of the query

### EvaluateSingle

    public XdmItem EvaluateSingle()

  Evaluate the query, returning the result as an `XdmItem` (that is, a single node or atomic value).

  returns
    An `XdmItem` representing the result of the query, or null if the query returns an empty sequence. If the query returns a sequence of more than one item, any items after the first are ignored.

### GetEnumerator

    public IEnumerator GetEnumerator()

  Evaluate the query, returning the result as an `IEnumerator` (that is, an enumerator over a sequence of nodes and/or atomic values).

  returns
    An enumerator over the sequence that represents the results of the query. Each object in this sequence will be an instance of `XdmItem`. Note that the query may be evaluated lazily, which means that a successful response from this method does not imply that the query has executed successfully: failures may be reported later while retrieving items from the iterator.

### Run

    public void Run(XmlDestination destination)

  Evaluate the query, sending the result to a specified destination.

  Parameters:
  `destination` -
    The destination for the results of the query. The class `XmlDestination` is an abstraction that allows a number of different kinds of destination to be specified.

### RunUpdate

    public XdmNode[] RunUpdate()

  Execute an updating query.

  returns
    An array containing the root nodes of documents that have been updated by the query.