Search in sources :

Example 11 with NodeTest

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

the class NodeTestTest method test_NodeTest011_2.

// processing-instruction() gets all descendant PIs.
public void test_NodeTest011_2() throws Exception {
    String inputFile = "/TestSources/TreeCompass.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTest011.xq";
    String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTest011-2.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())";
    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 12 with NodeTest

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

the class NodeTestTest method test_NodeTesthc_2.

// Simple test involving a text node and a boolean expression (or fn:true()).
public void test_NodeTesthc_2() throws Exception {
    String inputFile = "/TestSources/works-mod.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTesthc-2.xq";
    String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTesthc-2.txt";
    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 = "$input-context1//text() or fn:true()";
    String actual = null;
    try {
        compileXPath(xpath);
        ResultSequence rs = evaluate(domDoc);
        actual = "<result>" + buildResultString(rs) + "</result>";
    } 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 NodeTest

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

the class NodeTestTest method test_NodeTest001.

// Simple test for comment() node type.
public void test_NodeTest001() throws Exception {
    String inputFile = "/TestSources/bib2.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTest001.xq";
    String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTest001.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 = 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 14 with NodeTest

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

the class NodeTestTest method test_NodeTest010_2.

// //comment() gets all comments, including those off root.
public void test_NodeTest010_2() throws Exception {
    String inputFile = "/TestSources/TopMany.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTest010.xq";
    String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTest010-2.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//comment())";
    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 15 with NodeTest

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

the class NodeTestTest method test_NodeTesthc_7.

// Simple test involving Element node types and a boolean expression (and fn:false()).
public void test_NodeTesthc_7() throws Exception {
    String inputFile = "/TestSources/works-mod.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTesthc-7.xq";
    String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTesthc-7.txt";
    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 = "$input-context1//overtime/node() and fn:false()";
    String actual = null;
    try {
        compileXPath(xpath);
        ResultSequence rs = evaluate(domDoc);
        actual = "<result>" + buildResultString(rs) + "</result>";
    } 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