public class XPathExpression extends Object
XPathEvaluator
class.
It is modelled on the XPath API defined in JAXP 1.3, but is free-standing, and is more strongly typed.
In Saxon 9.6, the methods that returned Object and did implicit conversion to a native Java object have been removed; all conversions must now be done explicitly.
Modifier | Constructor and Description |
---|---|
protected |
XPathExpression(StaticContext env,
Expression exp,
Executable exec)
The constructor is protected, to ensure that instances can only be
created using the createExpression() or createPattern() method of XPathEvaluator
|
Modifier and Type | Method and Description |
---|---|
XPathDynamicContext |
createDynamicContext()
Create a dynamic context suitable for evaluating this expression, without supplying a context
item
|
XPathDynamicContext |
createDynamicContext(Controller controller,
Item contextItem)
Create a dynamic context suitable for evaluating this expression within an environment
represented by an existing controller.
|
XPathDynamicContext |
createDynamicContext(Item contextItem)
Create a dynamic context suitable for evaluating this expression
|
boolean |
effectiveBooleanValue(XPathDynamicContext context)
Evaluate the expression, returning its effective boolean value
|
List<Item> |
evaluate(XPathDynamicContext context)
Execute the expression, returning the result as a List, whose members will be instances
of the class
Item |
Item |
evaluateSingle(XPathDynamicContext context)
Execute the expression, returning the result as a single
Item
If the result of the expression is a sequence containing more than one item, items after
the first are discarded. |
Executable |
getExecutable()
Get the Executable associated with this expression
|
Expression |
getInternalExpression()
Low-level method to get the internal Saxon expression object.
|
SequenceIterator |
iterate(XPathDynamicContext context)
Execute the expression, returning the result as a
SequenceIterator , whose members will be instances
of the class Item
|
protected void |
setStackFrameMap(SlotManager map,
int numberOfExternalVariables)
Define the number of slots needed for local variables within the expression
|
protected XPathExpression(StaticContext env, Expression exp, Executable exec)
env
- the static context of the expressionexp
- the internal representation of the compiled expressionexec
- the Executable associated with this expressionpublic Executable getExecutable()
protected void setStackFrameMap(SlotManager map, int numberOfExternalVariables)
map
- the stack frame map identifying all the variables used by the expression, both
those declared internally, and references to variables declared externallynumberOfExternalVariables
- the number of slots in the stack frame allocated to
externally-declared variables. These must be assigned a value before execution startspublic XPathDynamicContext createDynamicContext()
public XPathDynamicContext createDynamicContext(Item contextItem) throws XPathException
contextItem
- the initial context item, which may be null if no
context item is required, or if it is to be supplied laterXPathException
- if the context item does not match the required context item type
set up in the static contextpublic XPathDynamicContext createDynamicContext(Controller controller, Item contextItem) throws XPathException
controller
- an existing controller. May be null, in which case the method is
equivalent to calling createDynamicContext(net.sf.saxon.om.Item)
contextItem
- the initial context item, which may be null if no
context item is required, or if it is to be supplied laterXPathException
- if the context item does not match the required context item type
set up in the static contextpublic SequenceIterator iterate(XPathDynamicContext context) throws XPathException
SequenceIterator
, whose members will be instances
of the class Item
Note that if evaluation of the expression fails with a dynamic error, this will generally
be reported in the form of an exception thrown by the next() method of the SequenceIterator
context
- the XPath dynamic contextXPathException
- if a dynamic error occurs during the expression evaluation (though in many
cases, the error will only be detected when the iterator is actually used).public List<Item> evaluate(XPathDynamicContext context) throws XPathException
Item
context
- the XPath dynamic contextXPathException
- if a dynamic error occurs while evaluation the expressionpublic Item evaluateSingle(XPathDynamicContext context) throws XPathException
Item
If the result of the expression is a sequence containing more than one item, items after
the first are discarded. If the result is an empty sequence, the method returns null.context
- the XPath dynamic contextXPathException
- if a dynamic error occurs during the expression evaluationpublic boolean effectiveBooleanValue(XPathDynamicContext context) throws XPathException
context
- the XPath dynamic contextXPathException
- if a dynamic error occurs, or if the result is a value for which
no effective boolean value is definedpublic Expression getInternalExpression()
Copyright (c) 2004-2014 Saxonica Limited. All rights reserved.