Saxon.Api

 

 

Saxon.Api

Class XPathExecutable


public class XPathExecutable

An XPathExecutable represents the compiled form of an XPath expression. To evaluate the expression, it must first be loaded to form an XPathSelector.

An XPathExecutable is immutable, and therefore thread-safe. It is simplest to load a new XPathSelector each time the expression is to be evaluated. However, the XPathSelector is serially reusable within a single thread.

An XPathExecutable is created by using the Compile method on the XPathCompiler class.

Property Summary

 net.sf.saxon.s9api.XPathExecutable Implementation

Escape hatch to the net.sf.saxon.s9api.XPathExecutable object in the underlying Java implementation

 

Method Summary

 IEnumerator EnumerateExternalVariables()

Get a list of external variables used by the expression. This will include both variables that were explicitly declared to the XPathCompiler, and (if the AllowUndeclaredVariables option was set) variables that are referenced within the expression but not explicitly declared.

 IEnumerator<QName> EnumerateExternalVariables2()

Get a list of external variables used by the expression. This will include both variables that were explicitly declared to the XPathCompiler, and (if the AllowUndeclaredVariables option was set) variables that are referenced within the expression but not explicitly declared.

 char GetRequiredCardinalityForVariable(QName variableName)

Get the required cardinality of a declared variable in the static context of the expression.

 XPathSelector Load()

Load the compiled XPath expression to prepare it for execution.

 

Property Detail

Implementation

public net.sf.saxon.s9api.XPathExecutable Implementation {get; }

Escape hatch to the net.sf.saxon.s9api.XPathExecutable object in the underlying Java implementation

Method Detail

EnumerateExternalVariables

public IEnumerator EnumerateExternalVariables()

Get a list of external variables used by the expression. This will include both variables that were explicitly declared to the XPathCompiler, and (if the AllowUndeclaredVariables option was set) variables that are referenced within the expression but not explicitly declared.

Returns:

An IEnumerator over the names of the external variables, as instances of QName.

EnumerateExternalVariables2

public IEnumerator<QName> EnumerateExternalVariables2()

Get a list of external variables used by the expression. This will include both variables that were explicitly declared to the XPathCompiler, and (if the AllowUndeclaredVariables option was set) variables that are referenced within the expression but not explicitly declared.

Returns:

An IEnumerator over the names of the external variables, as instances of QName.

GetRequiredCardinalityForVariable

public char GetRequiredCardinalityForVariable(QName variableName)

Get the required cardinality of a declared variable in the static context of the expression.

The result is given as an occurrence indicator, one of:

  • '?' (zero-or-one)
  • '*' (zero-or-more)
  • '+' (one-or-more)
  • ' ' (a single space) (exactly one)
  • 'º' (masculine ordinal indicator, xBA) (exactly zero)

The type empty-sequence() can be represented by an occurrence indicator of 'º' with any item type.

If the variable was explicitly declared, this will be the occurrence indicator that was set when the variable was declared. If no item type was set, it will be net.sf.saxon.s9api.OccurrenceIndicator#ZERO_OR_MORE.

If the variable was implicitly declared by reference (which can happen only when the allowUndeclaredVariables option is set), the returned type will be net.sf.saxon.s9api.OccurrenceIndicator#ZERO_OR_MORE.

If no variable with the specified QName has been declared either explicitly or implicitly, the method returns '0'.

Parameters:

variableName - the name of a declared variable

Returns:

The required cardinality, in the form of an occurrence indicator.

Load

public XPathSelector Load()

Load the compiled XPath expression to prepare it for execution.

Returns:

An XPathSelector. The returned XPathSelector can be used to set up the dynamic context, and then to evaluate the expression.