Search in sources :

Example 51 with Evaluator

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

the class TestWTPDOMXPath2 method test_nodeexpression27.

// Evaluation of a Node expression With the operands/operator set with the
// following format: Single Node Element "<<" Single Node Element.
public void test_nodeexpression27() throws Exception {
    String inputFile = "/TestSources/works.xml";
    String xqFile = "/Queries/XQuery/Expressions/Operators/NodeOp/NodeBefore/nodeexpression27.xq";
    String resultFile = "/ExpectedTestResults/Expressions/Operators/NodeOp/NodeBefore/nodeexpression27.txt";
    String expectedResult = getExpectedResult(resultFile);
    URL fileURL = bundle.getEntry(inputFile);
    domDoc = load(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = null;
    DynamicContext dc = setupDynamicContext(schema);
    String xpath = extractXPathExpression(xqFile, inputFile);
    String actual = null;
    try {
        XPath path = compileXPath(dc, xpath);
        Evaluator eval = new DefaultEvaluator(dc, domDoc);
        ResultSequence rs = eval.evaluate(path);
        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 : XPath(org.eclipse.wst.xml.xpath2.processor.ast.XPath) XPathParserException(org.eclipse.wst.xml.xpath2.processor.XPathParserException) ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) DefaultEvaluator(org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator) XSModel(org.apache.xerces.xs.XSModel) StaticError(org.eclipse.wst.xml.xpath2.processor.StaticError) Evaluator(org.eclipse.wst.xml.xpath2.processor.Evaluator) DefaultEvaluator(org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator) DynamicError(org.eclipse.wst.xml.xpath2.processor.DynamicError) URL(java.net.URL) DynamicContext(org.eclipse.wst.xml.xpath2.processor.DynamicContext)

Example 52 with Evaluator

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

the class TestWTPDOMXPath2 method test_Axes075_4.

// elem//child::name gets several elements.
public void test_Axes075_4() throws Exception {
    String inputFile = "/TestSources/TreeStack.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes075.xq";
    String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/Axes/Axes075-4.txt";
    String expectedResult = getExpectedResult(resultFile);
    URL fileURL = bundle.getEntry(inputFile);
    domDoc = load(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = null;
    DynamicContext dc = setupDynamicContext(schema);
    String xpath = extractXPathExpression(xqFile, inputFile);
    String actual = null;
    try {
        XPath path = compileXPath(dc, xpath);
        Evaluator eval = new DefaultEvaluator(dc, domDoc);
        ResultSequence rs = eval.evaluate(path);
        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 : XPath(org.eclipse.wst.xml.xpath2.processor.ast.XPath) XPathParserException(org.eclipse.wst.xml.xpath2.processor.XPathParserException) ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) DefaultEvaluator(org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator) XSModel(org.apache.xerces.xs.XSModel) StaticError(org.eclipse.wst.xml.xpath2.processor.StaticError) Evaluator(org.eclipse.wst.xml.xpath2.processor.Evaluator) DefaultEvaluator(org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator) DynamicError(org.eclipse.wst.xml.xpath2.processor.DynamicError) URL(java.net.URL) DynamicContext(org.eclipse.wst.xml.xpath2.processor.DynamicContext)

Example 53 with Evaluator

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

the class TestWTPDOMXPath2 method test_unabbreviatedSyntax_20.

// Evaluates unabbreviated syntax. Evaluate
// "child::employee[fn:position() = 1]". Selects the first employee child of
// the context node.
public void test_unabbreviatedSyntax_20() throws Exception {
    String inputFile = "/TestSources/works-mod.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/UnabbrAxes/unabbreviatedSyntax-20.xq";
    String resultFile = "/ExpectedTestResults/Expressions/PathExpr/UnabbrAxes/unabbreviatedSyntax-20.txt";
    String expectedResult = formatResultString(resultFile);
    URL fileURL = bundle.getEntry(inputFile);
    domDoc = load(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = null;
    DynamicContext dc = setupDynamicContext(schema);
    String xpath = extractXPathExpression(xqFile, inputFile);
    String actual = null;
    try {
        XPath path = compileXPath(dc, xpath);
        Evaluator eval = new DefaultEvaluator(dc, domDoc);
        ResultSequence rs = eval.evaluate(path);
        actual = buildXMLResultString(rs);
    } catch (XPathParserException ex) {
        actual = ex.code();
    } catch (StaticError ex) {
        actual = ex.code();
    } catch (DynamicError ex) {
        actual = ex.code();
    }
    assertXMLEqual("XPath Result Error " + xqFile + ":", expectedResult, actual);
}
Also used : XPath(org.eclipse.wst.xml.xpath2.processor.ast.XPath) XPathParserException(org.eclipse.wst.xml.xpath2.processor.XPathParserException) ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) DefaultEvaluator(org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator) XSModel(org.apache.xerces.xs.XSModel) StaticError(org.eclipse.wst.xml.xpath2.processor.StaticError) Evaluator(org.eclipse.wst.xml.xpath2.processor.Evaluator) DefaultEvaluator(org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator) DynamicError(org.eclipse.wst.xml.xpath2.processor.DynamicError) URL(java.net.URL) DynamicContext(org.eclipse.wst.xml.xpath2.processor.DynamicContext)

Example 54 with Evaluator

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

the class TestWTPDOMXPath2 method test_Axes001_1.

// No children for child::*.
public void test_Axes001_1() throws Exception {
    String inputFile = "/TestSources/TreeTrunc.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes001.xq";
    String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/Axes/Axes001-1.txt";
    String expectedResult = getExpectedResult(resultFile);
    URL fileURL = bundle.getEntry(inputFile);
    super.domDoc = load(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = null;
    DynamicContext dc = setupDynamicContext(schema);
    String xpath = extractXPathExpression(xqFile, inputFile);
    String actual = null;
    try {
        XPath path = compileXPath(dc, xpath);
        Evaluator eval = new DefaultEvaluator(dc, domDoc);
        ResultSequence rs = eval.evaluate(path);
        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 : XPath(org.eclipse.wst.xml.xpath2.processor.ast.XPath) XPathParserException(org.eclipse.wst.xml.xpath2.processor.XPathParserException) ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) DefaultEvaluator(org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator) XSModel(org.apache.xerces.xs.XSModel) StaticError(org.eclipse.wst.xml.xpath2.processor.StaticError) Evaluator(org.eclipse.wst.xml.xpath2.processor.Evaluator) DefaultEvaluator(org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator) DynamicError(org.eclipse.wst.xml.xpath2.processor.DynamicError) URL(java.net.URL) DynamicContext(org.eclipse.wst.xml.xpath2.processor.DynamicContext)

Example 55 with Evaluator

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

the class TestWTPDOMXPath2 method test_Axes076_3.

// elem//child::node() gets 1 child text node.
public void test_Axes076_3() throws Exception {
    String inputFile = "/TestSources/Tree1Text.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes076.xq";
    String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/Axes/Axes076-3.txt";
    String expectedResult = getExpectedResult(resultFile);
    URL fileURL = bundle.getEntry(inputFile);
    domDoc = load(fileURL);
    // Get XML Schema Information for the Document
    XSModel schema = null;
    DynamicContext dc = setupDynamicContext(schema);
    String xpath = extractXPathExpression(xqFile, inputFile);
    String actual = null;
    try {
        XPath path = compileXPath(dc, xpath);
        Evaluator eval = new DefaultEvaluator(dc, domDoc);
        ResultSequence rs = eval.evaluate(path);
        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 : XPath(org.eclipse.wst.xml.xpath2.processor.ast.XPath) XPathParserException(org.eclipse.wst.xml.xpath2.processor.XPathParserException) ResultSequence(org.eclipse.wst.xml.xpath2.processor.ResultSequence) DefaultEvaluator(org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator) XSModel(org.apache.xerces.xs.XSModel) StaticError(org.eclipse.wst.xml.xpath2.processor.StaticError) Evaluator(org.eclipse.wst.xml.xpath2.processor.Evaluator) DefaultEvaluator(org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator) DynamicError(org.eclipse.wst.xml.xpath2.processor.DynamicError) URL(java.net.URL) DynamicContext(org.eclipse.wst.xml.xpath2.processor.DynamicContext)

Aggregations

ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)79 URL (java.net.URL)77 DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)77 StaticError (org.eclipse.wst.xml.xpath2.processor.StaticError)77 XPathParserException (org.eclipse.wst.xml.xpath2.processor.XPathParserException)77 XSModel (org.apache.xerces.xs.XSModel)74 DefaultEvaluator (org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator)74 Evaluator (org.eclipse.wst.xml.xpath2.processor.Evaluator)74 XPath (org.eclipse.wst.xml.xpath2.processor.ast.XPath)74 DynamicContext (org.eclipse.wst.xml.xpath2.processor.DynamicContext)72 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)2 DefaultDynamicContext (org.eclipse.wst.xml.xpath2.processor.DefaultDynamicContext)1 JFlexCupParser (org.eclipse.wst.xml.xpath2.processor.JFlexCupParser)1 StaticChecker (org.eclipse.wst.xml.xpath2.processor.StaticChecker)1 StaticNameResolver (org.eclipse.wst.xml.xpath2.processor.StaticNameResolver)1 XPathParser (org.eclipse.wst.xml.xpath2.processor.XPathParser)1 FnFunctionLibrary (org.eclipse.wst.xml.xpath2.processor.function.FnFunctionLibrary)1 DefaultStaticContext (org.eclipse.wst.xml.xpath2.processor.internal.DefaultStaticContext)1 XSDecimal (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDecimal)1