use of org.eclipse.wst.xml.xpath2.processor.internal.ParentAxis in project webtools.sourceediting by eclipse.
the class PrecedingAxis method iterate.
// XXX DOCUMENT ORDER.... dunno
/**
* returns preceding nodes of the context node
*
* @param node
* is the node type.
* @throws dc
* is the Dynamic context.
*/
public void iterate(NodeType node, ResultBuffer result, Node limitNode) {
if (limitNode != null && limitNode.isSameNode(node.node_value())) {
// no further, we have reached the limit node
return;
}
// get the parent
NodeType parent = null;
ResultBuffer parentBuffer = new ResultBuffer();
new ParentAxis().iterate(node, parentBuffer, limitNode);
if (parentBuffer.size() == 1) {
parent = (NodeType) parentBuffer.item(0);
// if we got a parent, we gotta repeat the story for the parent
// and add the results
iterate(parent, result, limitNode);
}
// get the following siblings of this node, and add them
PrecedingSiblingAxis psa = new PrecedingSiblingAxis();
ResultBuffer siblingBuffer = new ResultBuffer();
psa.iterate(node, siblingBuffer, limitNode);
// for each sibling, get all its descendants
DescendantAxis da = new DescendantAxis();
for (Iterator i = siblingBuffer.iterator(); i.hasNext(); ) {
result.add((NodeType) i);
da.iterate((NodeType) i.next(), result, null);
}
}
use of org.eclipse.wst.xml.xpath2.processor.internal.ParentAxis in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit a reverse step expression
*
* @param e
* is the reverse step.
* @return a new function
*/
// XXX unify with top
public Object visit(ReverseStep e) {
// get context node
AnyType ci = focus().context_item();
if (!(ci instanceof NodeType))
report_error(TypeError.ci_not_node(ci.string_type()));
NodeType cn = (NodeType) ci;
// get the nodes on the axis
ReverseAxis axis = e.iterator();
ResultBuffer result = new ResultBuffer();
// short for "gimme da parent"
if (e.axis() == ReverseStep.DOTDOT) {
new ParentAxis().iterate(cn, result, _dc.getLimitNode());
return result.getSequence();
}
assert axis != null;
axis.iterate(cn, result, null);
// get all nodes in the axis, and principal node
Pair arg = new Pair(axis.principal_node_kind().string_type(), result.getSequence());
// do the name test
_param = arg;
ResultSequence rs = (ResultSequence) e.node_test().accept(this);
return rs;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.ParentAxis in project webtools.sourceediting by eclipse.
the class FollowingAxis method iterate.
/**
* Return the result of FollowingAxis expression
*
* @param node
* is the type of node.
*/
public void iterate(NodeType node, ResultBuffer result, Node limitNode) {
if (limitNode != null && limitNode.isSameNode(node.node_value())) {
// no further, we have reached the limit node
return;
}
// get the parent
NodeType parent = null;
ResultBuffer parentBuffer = new ResultBuffer();
new ParentAxis().iterate(node, parentBuffer, limitNode);
if (parentBuffer.size() == 1)
parent = (NodeType) parentBuffer.item(0);
// get the following siblings of this node, and add them
FollowingSiblingAxis fsa = new FollowingSiblingAxis();
ResultBuffer siblingBuffer = new ResultBuffer();
fsa.iterate(node, siblingBuffer, limitNode);
// for each sibling, get all its descendants
DescendantAxis da = new DescendantAxis();
for (Iterator i = siblingBuffer.iterator(); i.hasNext(); ) {
result.add((NodeType) i);
da.iterate((NodeType) i.next(), result, null);
}
// and add the results
if (parent != null) {
iterate(parent, result, limitNode);
}
}
Aggregations