Search in sources :

Example 1 with ReverseAxis

use of org.eclipse.wst.xml.xpath2.processor.internal.ReverseAxis 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;
}
Also used : ResultBuffer(org.eclipse.wst.xml.xpath2.api.ResultBuffer) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) NodeType(org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType) ParentAxis(org.eclipse.wst.xml.xpath2.processor.internal.ParentAxis) ReverseAxis(org.eclipse.wst.xml.xpath2.processor.internal.ReverseAxis) AnyType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType) VarExprPair(org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)

Example 2 with ReverseAxis

use of org.eclipse.wst.xml.xpath2.processor.internal.ReverseAxis in project webtools.sourceediting by eclipse.

the class StaticNameResolver method visit.

/**
 * Validate a reverse step.
 *
 * @param e
 *            is the expression.
 * @return null.
 */
public Object visit(ReverseStep e) {
    NodeTest nt = e.node_test();
    if (nt != null)
        nt.accept(this);
    ReverseAxis iterator = e.iterator();
    if (iterator != null)
        _axes.add(iterator.name());
    return null;
}
Also used : ReverseAxis(org.eclipse.wst.xml.xpath2.processor.internal.ReverseAxis) NodeTest(org.eclipse.wst.xml.xpath2.processor.internal.ast.NodeTest)

Aggregations

ReverseAxis (org.eclipse.wst.xml.xpath2.processor.internal.ReverseAxis)2 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)1 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)1 ParentAxis (org.eclipse.wst.xml.xpath2.processor.internal.ParentAxis)1 NodeTest (org.eclipse.wst.xml.xpath2.processor.internal.ast.NodeTest)1 VarExprPair (org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)1 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)1 NodeType (org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType)1