public final class XPathAxis extends AbsAxis
Evaluates a given XPath query.
Axis to iterate over the items (more precisely the item keys) of the query's result sequence.
XPathAxis
extends treetanks IAxis
that extends the well-known Java
Iterator<Long>
and Iterable<Long>
interfaces.
In order to use it, at first a treetank session has to be bound to the XML document in question or an tnk
file and a NodeReadTrx
with an IItemList
as argument has to be started on
it. (For more information how to do that, see the treetank documentation.) Then the XPathAxis
can be used like this:
... INodeReadTrx rtx = session.beginReadTransaction(new ItemList()); final String query = "for $a in /articles/article[@name = \"book\"] return $a/price"; final IAxis axis = new XPathAxis(rtx, query); while (axis.hasNext()) { // Move transaction cursor to do something. axis.next(); System.out.println(rtx.getValueAsInt());); } ...
... for (final long key : new XPathAxis(rtx, query)) { ... } ...
Modifier and Type | Field and Description |
---|---|
static boolean |
XPATH_10_COMP
Declares if the evaluation is compatible to XPath 1.0 or not.
|
Constructor and Description |
---|
XPathAxis(INodeReadTrx rtx,
String mQuery)
Constructor initializing internal state.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext() |
addAtomicToItemList, close, getItemList, getNode, getStartKey, isSelfIncluded, iterator, moveTo, next, remove, reset, resetToLastKey, resetToStartKey
public static final boolean XPATH_10_COMP
public XPathAxis(INodeReadTrx rtx, String mQuery) throws TTXPathException
Constructor initializing internal state.
Starts the query scanning and parsing and retrieves the builded query execution plan from the parser.
rtx
- Transaction to operate with.mQuery
- XPath query to process.TTXPathException
- throw a treetank xpath exception.Copyright © 2013. All Rights Reserved.