Class XPathExecutable
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 XPathCompiler.compile(java.lang.String)
method
on the XPathCompiler
class.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
XPathExecutable
(XPathExpression exp, Processor processor, IndependentContext env) -
Method Summary
Modifier and TypeMethodDescriptionasStep()
Treat the compiled XPath expression as aStep
, so that it can be used in a call onXdmValue.select(net.sf.saxon.s9api.streams.Step<T>)
.getRequiredCardinalityForVariable
(QName variableName) Get the required cardinality of a declared variable in the static context of the expression.getRequiredItemTypeForVariable
(QName variableName) Get the required item type of a declared variable in the static context of the expression.Get the statically-determined cardinality of the result of the expression.Get the ItemType of the items in the result of the expression, as determined by static analysis.Get the underlying implementation object representing the compiled XPath expression.Get the underlying implementation object representing the static context of the compiled XPath expression.Get an iterator over the names of all the external variables.load()
Load the compiled XPath expression to prepare it for execution.
-
Constructor Details
-
XPathExecutable
-
-
Method Details
-
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.
-
asStep
Treat the compiled XPath expression as aStep
, so that it can be used in a call onXdmValue.select(net.sf.saxon.s9api.streams.Step<T>)
.Example usage:
node.select(c.compile(".//x[a=b+2]").asStep()).asXdmValue()
- Returns:
- a Step, whose effect is to evaluate the XPath expression (with the origin item as the initial context item)
-
getResultItemType
Get the ItemType of the items in the result of the expression, as determined by static analysis. This is the most precise ItemType that the processor is able to determine from static examination of the expression; the actual items in the expression result are guaranteed to belong to this ItemType or to a subtype of this ItemType.- Returns:
- the statically-determined ItemType of the result of the expression
- Since:
- 9.1
-
getResultCardinality
Get the statically-determined cardinality of the result of the expression. This is the most precise cardinality that the processor is able to determine from static examination of the expression.- Returns:
- the statically-determined cardinality of the result of the expression
- Since:
- 9.1
-
iterateExternalVariables
Get an iterator over the names of all the external variables. This includes both variables that have been explicitly declared using a call todeclareVariable()
, and variables that are implicitly declared by reference in the case where theallowUndeclaredVariables
option is set. It does not include range variables bound in afor
,some
, orevery
expression.If the
allowUndeclaredVariables
option is set, this method allows discovery of the variable references that appear in the compiled expression.- Returns:
- an iterator over the names of the external variables defined in the XPath expression
- Since:
- 9.2
-
getRequiredItemTypeForVariable
Get the required item type of a declared variable in the static context of the expression.- Parameters:
variableName
- the name of a declared variable- Returns:
- the required item type.
If the variable was explicitly declared, this will be the item type that was set when the variable was declared. If no item type was set, it will be
ItemType.ANY_ITEM
.If the variable was implicitly declared by reference (which can happen only when the
allowUndeclaredVariables
option is set), the returned type will beItemType.ANY_ITEM
.If no variable with the specified QName has been declared either explicitly or implicitly, the method returns null.
- Since:
- 9.2
-
getRequiredCardinalityForVariable
Get the required cardinality of a declared variable in the static context of the expression.- Parameters:
variableName
- the name of a declared variable- Returns:
- the required cardinality.
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
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 beOccurrenceIndicator.ZERO_OR_MORE
.If no variable with the specified QName has been declared either explicitly or implicitly, the method returns null.
- Since:
- 9.2
-
getUnderlyingExpression
Get the underlying implementation object representing the compiled XPath expression. This method provides access to lower-level Saxon classes and methods which may be subject to change from one release to the next.- Returns:
- the underlying compiled XPath expression.
-
getUnderlyingStaticContext
Get the underlying implementation object representing the static context of the compiled XPath expression. This method provides access to lower-level Saxon classes and methods which may be subject to change from one release to the next.- Returns:
- the underlying static context.
-