Saxon.Api

Class DocumentBuilder

Class DomDestination

Class DynamicContext

Class DynamicError

Class EmptyEnumerator

Class ExtensionFunctionCall

Class ExtensionFunctionDefinition

Class InvalidityHandlerWrapper

Class NamespaceConstant

Class NullDestination

Class Processor

Class QName

Class SchemaManager

Class SchemaValidator

Class Serializer

Class StandardLogger

Class StaticContext

Class StaticError

Class TextWriterDestination

Class WhitespacePolicy

Class XPathCompiler

Class XPathExecutable

Class XPathSelector

Class XQueryCompiler

Class XQueryEvaluator

Class XQueryExecutable

Class XdmAnyFunctionType

Class XdmAnyItemType

Class XdmAnyNodeType

Class XdmArray

Class XdmAtomicType

Class XdmAtomicValue

Class XdmDestination

  - Class TreeProtector

Class XdmEmptySequence

Class XdmExternalObjectValue

Class XdmFunctionItem

Class XdmItem

Class XdmItemType

Class XdmMap

Class XdmNode

Class XdmNodeKind

Class XdmSequenceType

Class XdmValue

Class XmlDestination

Class Xslt30Transformer

Class XsltCompiler

Class XsltExecutable

  - Class ParameterDetails

Class XsltPackage

Class XsltTransformer

Enum RecoveryPolicy

Enum SchemaValidationMode

Enum TreeModel

Enum XdmAxis

Interface IInvalidityHandler

Interface IMessageListener

Interface IQueryResolver

Interface IResultDocumentHandler

Interface IXdmEnumerator

Interface IXmlLocation

Interface SchemaResolver

 

Saxon.Api
Class XPathSelector


public class XPathSelector
implements IEnumerable

An XPathSelector represents a compiled and loaded XPath expression ready for execution. The XPathSelector holds details of the dynamic evaluation context for the XPath expression.

An XPathSelector should not be used concurrently in multiple threads. It is safe, however, to reuse the object within a single thread to evaluate the same XPath expression several times. Evaluating the expression does not change the context that has been established.

An XPathSelector is always constructed by running the Load method of an XPathExecutable.


Property Summary
 XdmItem ContextItem

The context item for the XPath expression evaluation.

 XmlResolver InputXmlResolver

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

 
Method Summary
 void SetVariable(QName name, XdmValue value)

Set the value of a variable

 XdmValue Evaluate()

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

 XdmItem EvaluateSingle()

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

 Boolean EffectiveBooleanValue()

Evaluate the effective boolean value of the XPath expression, returning the result as a Boolean

 IEnumerator GetEnumerator()

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

 
Property Detail

ContextItem

public XdmItem ContextItem {get; set; }

The context item for the XPath expression evaluation.

This may be either a node or an atomic value. Most commonly it will be a document node, which might be constructed using the Build method of the DocumentBuilder 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.


Method Detail

SetVariable

public void SetVariable(QName name,
XdmValue value)

Set the value of a variable

Parameters:
name -
The name of the variable. This must match the name of a variable that was declared to the XPathCompiler. No error occurs if the expression does not actually reference a variable with this name.
value -
The value to be given to the variable.

Evaluate

public XdmValue Evaluate()
throws
Saxon.Api.DynamicError

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

Although a singleton result may be represented as an XdmItem, there is no guarantee that this will always be the case. If you know that the expression will return at most one node or atomic value, it is best to use the EvaluateSingle method, which does guarantee that an XdmItem (or null) will be returned.

Returns:
An XdmValue representing the results of the expression.
Throws:
Saxon.Api.DynamicError - Throws Saxon.Api.DynamicError if the evaluation of the XPath expression fails with a dynamic error.

EvaluateSingle

public XdmItem EvaluateSingle()
throws
Saxon.Api.DynamicError

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

Returns:
An XdmItem representing the result of the expression, or null if the expression returns an empty sequence. If the expression returns a sequence of more than one item, any items after the first are ignored.
Throws:
Saxon.Api.DynamicError - Throws Saxon.Api.DynamicError if the evaluation of the XPath expression fails with a dynamic error.

EffectiveBooleanValue

public Boolean EffectiveBooleanValue()
throws
Saxon.Api.DynamicError

Evaluate the effective boolean value of the XPath expression, returning the result as a Boolean

Returns:
A Boolean representing the result of the expression, converted to its effective boolean value as if by applying the XPath boolean() function
Throws:
Saxon.Api.DynamicError - Throws Saxon.Api.DynamicError if the evaluation of the XPath expression fails with a dynamic error.

GetEnumerator

public IEnumerator GetEnumerator()
throws
Saxon.Api.DynamicError

Evaluate the expression, 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 expression. Each object in this sequence will be an instance of XdmItem. Note that the expression may be evaluated lazily, which means that a successful response from this method does not imply that the expression has executed successfully: failures may be reported later while retrieving items from the iterator.
Throws:
Saxon.Api.DynamicError - May throw a Saxon.Api.DynamicError if the evaluation of the XPath expression fails with a dynamic error. However, some errors will not be detected during the invocation of this method, but only when stepping through the returned SequenceEnumerator.