SAXONICA |
Saxon's implementation of XPathExpression
(namely net.sf.saxon.xpath.XPathExpressionImpl
)
provides additional methods for evaluating the XPath expression. In particular the rawIterator()
method with no arguments returns a Saxon SequenceIterator
which allows the application to process
the results of any XPath expression, with no conversion: all values will be represented using a native Saxon class,
for example a node will be represented as a NodeInfo
and a QName as a QNameValue
.
The NodeInfo
interface is described in the next section.
The native Saxon methods rely on the dynamic context being established using separate setXX()
calls on the XPathExpressionImpl
object. If these methods are used, the XPathExpression
object will not be thread-safe.
XPath itself provides no sorting capability. You can therefore specify a sort order in which you want
the results of an expression returned. This is done by nominating another expression, via the setSortKey
method: this second expression is applied to each item in the result sequence, and its value determines
the position of that item in the sorted result order.
An alternative approach if you need sorting would be to use XQuery rather than XPath.
You can call methods directly on the NodeInfo
object to get information about a node: for
example getDisplayName()
gets the name of the node in a form suitable for display, and
getStringValue()
gets the string value of the node, as defined in the XPath data model. You
can also use the node as the context node for evaluation of subsequent expressions.