Search in sources :

Example 11 with Axis

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

the class AncestorAxis method iterate.

/**
 * Get the ancestors of the context node.
 *
 * @param node
 *            is the type of node.
 */
// XXX unify this with descendants axis ?
public void iterate(NodeType node, ResultBuffer copyInto, Node limitNode) {
    if (limitNode != null && limitNode.isSameNode(node.node_value()))
        return;
    int before = copyInto.size();
    // get the parent
    super.iterate(node, copyInto, limitNode);
    // no parent
    if (copyInto.size() == before)
        return;
    NodeType parent = (NodeType) copyInto.item(before);
    // get ancestors of parent
    iterate(parent, copyInto, limitNode);
}
Also used : NodeType(org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType)

Example 12 with Axis

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

the class AxesTest method test_axis_err_1.

// Evaluation of a step axis, which operates on a non node context item.
public void test_axis_err_1() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/axis-err-1.xq";
    String expectedResult = "XPTY0020";
    URL fileURL = bundle.getEntry(inputFile);
    loadDOMDocument(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = getGrammar();
    setupDynamicContext(schema);
    String xpath = extractXPathExpression(xqFile, inputFile);
    xpath = "20[child::text()]";
    String actual = null;
    try {
        compileXPath(xpath);
        ResultSequence rs = evaluate(domDoc);
        actual = buildResultString(rs);
    } catch (XPathParserException ex) {
        actual = ex.code();
    } catch (StaticError ex) {
        actual = ex.code();
    } catch (DynamicError ex) {
        actual = ex.code();
    }
    assertEquals("XPath Result Error " + xqFile + ":", expectedResult, actual);
}
Also used : XPathParserException(org.eclipse.wst.xml.xpath2.processor.XPathParserException) ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) XSModel(org.apache.xerces.xs.XSModel) StaticError(org.eclipse.wst.xml.xpath2.processor.StaticError) DynamicError(org.eclipse.wst.xml.xpath2.processor.DynamicError) URL(java.net.URL)

Example 13 with Axis

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

the class TestBugs method testNamespaceAxis.

public void testNamespaceAxis() {
    setupDynamicContext(null);
    String xpath = "count(namespace::*)";
    try {
        compileXPath(xpath);
        fail("This should have failed since we don't support the namespace axis");
    } catch (StaticError se) {
        assertEquals("XPST0010", se.code());
    }
}
Also used : StaticError(org.eclipse.wst.xml.xpath2.processor.StaticError) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)

Example 14 with Axis

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

the class STAxesTest method test_statictypingaxis_6.

// Evaluates static typing on descendant-or-self axis. Context item not a node.
public void test_statictypingaxis_6() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/StaticTyping/STPathExpr/STSteps/STAxes/statictypingaxis-6.xq";
    String expectedResult = "XPTY0019";
    URL fileURL = bundle.getEntry(inputFile);
    loadDOMDocument(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = getGrammar();
    setupDynamicContext(schema);
    String xpath = extractXPathExpression(xqFile, inputFile);
    String actual = null;
    try {
        compileXPath(xpath);
        ResultSequence rs = evaluate(domDoc);
        actual = buildResultString(rs);
    } catch (XPathParserException ex) {
        actual = ex.code();
    } catch (StaticError ex) {
        actual = ex.code();
    } catch (DynamicError ex) {
        actual = ex.code();
    }
    assertEquals("XPath Result Error " + xqFile + ":", expectedResult, actual);
}
Also used : XPathParserException(org.eclipse.wst.xml.xpath2.processor.XPathParserException) ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) XSModel(org.apache.xerces.xs.XSModel) StaticError(org.eclipse.wst.xml.xpath2.processor.StaticError) DynamicError(org.eclipse.wst.xml.xpath2.processor.DynamicError) URL(java.net.URL)

Example 15 with Axis

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

the class STAxesTest method test_statictypingaxis_3.

// Evaluates static typing on attribute axis. Context item not a node.
public void test_statictypingaxis_3() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/StaticTyping/STPathExpr/STSteps/STAxes/statictypingaxis-3.xq";
    String expectedResult = "XPTY0019";
    URL fileURL = bundle.getEntry(inputFile);
    loadDOMDocument(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = getGrammar();
    setupDynamicContext(schema);
    String xpath = extractXPathExpression(xqFile, inputFile);
    String actual = null;
    try {
        compileXPath(xpath);
        ResultSequence rs = evaluate(domDoc);
        actual = buildResultString(rs);
    } catch (XPathParserException ex) {
        actual = ex.code();
    } catch (StaticError ex) {
        actual = ex.code();
    } catch (DynamicError ex) {
        actual = ex.code();
    }
    assertEquals("XPath Result Error " + xqFile + ":", expectedResult, actual);
}
Also used : XPathParserException(org.eclipse.wst.xml.xpath2.processor.XPathParserException) ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) XSModel(org.apache.xerces.xs.XSModel) StaticError(org.eclipse.wst.xml.xpath2.processor.StaticError) DynamicError(org.eclipse.wst.xml.xpath2.processor.DynamicError) URL(java.net.URL)

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