Search in sources :

Example 6 with Axis

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

the class DefaultEvaluator method descendant_or_self_node.

private ResultSequence descendant_or_self_node(ResultSequence rs) {
    ResultBuffer res = new ResultBuffer();
    Axis axis = new DescendantOrSelfAxis();
    // for all nodes, get descendant or self nodes
    for (Iterator i = rs.iterator(); i.hasNext(); ) {
        NodeType item = (NodeType) i.next();
        axis.iterate(item, res, _dc.getLimitNode());
    }
    return res.getSequence();
}
Also used : ResultBuffer(org.eclipse.wst.xml.xpath2.api.ResultBuffer) NodeType(org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) ParentAxis(org.eclipse.wst.xml.xpath2.processor.internal.ParentAxis) SelfAxis(org.eclipse.wst.xml.xpath2.processor.internal.SelfAxis) ReverseAxis(org.eclipse.wst.xml.xpath2.processor.internal.ReverseAxis) DescendantOrSelfAxis(org.eclipse.wst.xml.xpath2.processor.internal.DescendantOrSelfAxis) ForwardAxis(org.eclipse.wst.xml.xpath2.processor.internal.ForwardAxis) Axis(org.eclipse.wst.xml.xpath2.processor.internal.Axis) DescendantOrSelfAxis(org.eclipse.wst.xml.xpath2.processor.internal.DescendantOrSelfAxis)

Example 7 with Axis

use of org.eclipse.wst.xml.xpath2.processor.internal.Axis 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 8 with Axis

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

the class DefaultEvaluator method visit.

/**
 * visit a forward step expression
 *
 * @param e
 *            is the forward step.
 * @return a new function
 */
public Object visit(ForwardStep e) {
    // get context node
    AnyType ci = focus().context_item();
    if (ci == null)
        report_error(DynamicError.contextUndefined());
    if (!(ci instanceof NodeType))
        report_error(TypeError.ci_not_node(ci.string_type()));
    NodeType cn = (NodeType) ci;
    // get the nodes on the axis
    ForwardAxis axis = e.iterator();
    ResultBuffer rb = new ResultBuffer();
    axis.iterate(cn, rb, _dc.getLimitNode());
    // get all nodes in the axis, and principal node
    Pair arg = new Pair(axis.principal_node_kind().string_type(), rb.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) AnyType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType) ForwardAxis(org.eclipse.wst.xml.xpath2.processor.internal.ForwardAxis) VarExprPair(org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)

Example 9 with Axis

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

the class DefaultEvaluator method root_self_node.

private ResultSequence root_self_node() {
    Axis axis = new SelfAxis();
    ResultBuffer buffer = new ResultBuffer();
    // XXX the cast!!!
    axis.iterate((NodeType) focus().context_item(), buffer, _dc.getLimitNode());
    ResultSequence rs = kind_test(buffer.getSequence(), NodeType.class);
    List records = new ArrayList();
    records.add(rs);
    rs = FnRoot.fn_root(records, _ec);
    return rs;
}
Also used : SelfAxis(org.eclipse.wst.xml.xpath2.processor.internal.SelfAxis) DescendantOrSelfAxis(org.eclipse.wst.xml.xpath2.processor.internal.DescendantOrSelfAxis) ResultBuffer(org.eclipse.wst.xml.xpath2.api.ResultBuffer) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) NodeList(org.w3c.dom.NodeList) ParentAxis(org.eclipse.wst.xml.xpath2.processor.internal.ParentAxis) SelfAxis(org.eclipse.wst.xml.xpath2.processor.internal.SelfAxis) ReverseAxis(org.eclipse.wst.xml.xpath2.processor.internal.ReverseAxis) DescendantOrSelfAxis(org.eclipse.wst.xml.xpath2.processor.internal.DescendantOrSelfAxis) ForwardAxis(org.eclipse.wst.xml.xpath2.processor.internal.ForwardAxis) Axis(org.eclipse.wst.xml.xpath2.processor.internal.Axis)

Example 10 with Axis

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

the class DefaultEvaluator method visit.

/**
 * visit axis step.
 *
 * @param e
 *            is the axis step.
 * @return a result sequence
 */
public Object visit(AxisStep e) {
    ResultSequence rs = (ResultSequence) e.step().accept(this);
    if (e.predicate_count() == 0)
        return rs;
    // I take it predicates are logical ANDS...
    Focus original_focus = focus();
    // go through all predicates
    for (Iterator i = e.iterator(); i.hasNext(); ) {
        // empty results... get out of here ? XXX
        if (rs.size() == 0)
            break;
        set_focus(new Focus(rs));
        rs = do_predicate((Collection) i.next());
    }
    // restore focus [context switching ;D ]
    set_focus(original_focus);
    return rs;
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) Focus(org.eclipse.wst.xml.xpath2.processor.internal.Focus) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) Collection(java.util.Collection)

Aggregations

StaticError (org.eclipse.wst.xml.xpath2.processor.StaticError)9 URL (java.net.URL)8 XSModel (org.apache.xerces.xs.XSModel)8 DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)8 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)8 XPathParserException (org.eclipse.wst.xml.xpath2.processor.XPathParserException)8 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)4 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)4 NodeType (org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType)4 ForwardAxis (org.eclipse.wst.xml.xpath2.processor.internal.ForwardAxis)3 ParentAxis (org.eclipse.wst.xml.xpath2.processor.internal.ParentAxis)3 ReverseAxis (org.eclipse.wst.xml.xpath2.processor.internal.ReverseAxis)3 Iterator (java.util.Iterator)2 ListIterator (java.util.ListIterator)2 Axis (org.eclipse.wst.xml.xpath2.processor.internal.Axis)2 DescendantOrSelfAxis (org.eclipse.wst.xml.xpath2.processor.internal.DescendantOrSelfAxis)2 SelfAxis (org.eclipse.wst.xml.xpath2.processor.internal.SelfAxis)2 VarExprPair (org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)2 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)2 ArrayList (java.util.ArrayList)1