Search in sources :

Example 16 with NodeTest

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

the class NodeTestTest method test_NodeTest013_1.

// processing-instruction() gets descendant PIs of the given name.
public void test_NodeTest013_1() throws Exception {
    String inputFile = "/TestSources/TreeCompass.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTest013.xq";
    String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTest013-1.xml";
    String expectedResult = getExpectedResult(resultFile);
    URL fileURL = bundle.getEntry(inputFile);
    loadDOMDocument(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = getGrammar();
    setupDynamicContext(schema);
    String xpath = "fn:count($input-context//center/processing-instruction('a-pi'))";
    String actual = null;
    try {
        compileXPath(xpath);
        ResultSequence rs = evaluate(domDoc);
        actual = "<out>" + buildResultString(rs) + "</out>";
    } 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 17 with NodeTest

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

the class NameTestTest method test_nametest_3.

// Name test that uses an unknown prefix.
public void test_nametest_3() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/nametest-3.xq";
    String expectedResult = "XPST0081";
    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 = "./child::pr:b";
    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 18 with NodeTest

use of org.eclipse.wst.xml.xpath2.processor.internal.ast.NodeTest 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)

Example 19 with NodeTest

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

the class NameTestTest method test_NodeTest005.

// Simple test for . and * node test.
public void test_NodeTest005() throws Exception {
    String inputFile = "/TestSources/nw_Customers.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTest005.xq";
    String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTest005.xml";
    String expectedResult = formatResultString(resultFile);
    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 = buildXMLResultString(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 20 with NodeTest

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

the class NameTestTest method test_NodeTest004.

// Simple test for . node test.
public void test_NodeTest004() throws Exception {
    String inputFile = "/TestSources/nw_Customers.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTest004.xq";
    String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTest004.xml";
    String expectedResult = formatResultString(resultFile);
    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 = buildXMLResultString(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

URL (java.net.URL)29 XSModel (org.apache.xerces.xs.XSModel)29 DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)29 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)29 StaticError (org.eclipse.wst.xml.xpath2.processor.StaticError)29 XPathParserException (org.eclipse.wst.xml.xpath2.processor.XPathParserException)29 NodeTest (org.eclipse.wst.xml.xpath2.processor.internal.ast.NodeTest)2 ReverseAxis (org.eclipse.wst.xml.xpath2.processor.internal.ReverseAxis)1 AnyKindTest (org.eclipse.wst.xml.xpath2.processor.internal.ast.AnyKindTest)1 AxisStep (org.eclipse.wst.xml.xpath2.processor.internal.ast.AxisStep)1 ForwardStep (org.eclipse.wst.xml.xpath2.processor.internal.ast.ForwardStep)1 ReverseStep (org.eclipse.wst.xml.xpath2.processor.internal.ast.ReverseStep)1 Step (org.eclipse.wst.xml.xpath2.processor.internal.ast.Step)1