Search in sources :

Example 1 with Evaluator

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

the class NodeBeforeTest method test_nodeexpression29.

// Evaluation of a Node expression With the operands/operator set with the following format: Single Node Element "<<" Sequence of single Element Node.
// public void test_nodeexpression28() throws Exception {
// String inputFile = "/TestSources/works.xml";
// String inputFile2 = "/TestSources/staff.xml";
// String xqFile = "/Queries/XQuery/Expressions/Operators/NodeOp/NodeBefore/nodeexpression28.xq";
// String resultFile = "/ExpectedTestResults/Expressions/Operators/NodeOp/NodeBefore/nodeexpression28.txt";
// String expectedResult = getExpectedResult(resultFile);
// URL fileURL = bundle.getEntry(inputFile);
// URL fileURL2 = bundle.getEntry(inputFile2);
// 
// loadDOMDocument(fileURL);
// 
// // Get XML Schema Information for the Document
// XSModel schema = getGrammar();
// 
// setupDynamicContext(schema);
// 
// String xpath = extractXPathExpression(xqFile, inputFile);
// String actual = null;
// try {
// XPath path = compileXPath(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);
// 
// 
// }
// Evaluation of a Node expression With the operands/operator set with the following format: Sequence of single Element Node "<<" empty Sequence.
public void test_nodeexpression29() throws Exception {
    String inputFile = "/TestSources/staff.xml";
    String xqFile = "/Queries/XQuery/Expressions/Operators/NodeOp/NodeBefore/nodeexpression29.xq";
    String resultFile = "/ExpectedTestResults/Expressions/Operators/NodeOp/NodeBefore/nodeexpression29.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 = 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 2 with Evaluator

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

the class AxesTest method test_Axes088.

// Use of // to get all elements of a given name.
// Not a valid XPath 2 script
// public void test_Axes085() throws Exception {
// String inputFile = "/TestSources/nw_Customers.xml";
// String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes085.xq";
// String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/Axes/Axes085.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 {
// XPath path = compileXPath(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);
// 
// 
// }
// Parent of attribute node.
// public void test_Axes086() throws Exception {
// String inputFile = "/TestSources/Tree1Text.xml";
// String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes086.xq";
// String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/Axes/Axes086.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 {
// XPath path = compileXPath(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);
// 
// 
// }
// Parent of text nodes.
// public void test_Axes087() throws Exception {
// String inputFile = "/TestSources/xq311B.xml";
// String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes087.xq";
// String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/Axes/Axes087.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 {
// XPath path = compileXPath(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);
// 
// 
// }
// Empty step should result in parse error.
public void test_Axes088() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes088.xq";
    String expectedResult = "XPST0003";
    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 3 with Evaluator

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

the class ReplaceFuncTest method test_fn_replace_28.

// Test of "replace" with the pattern set to "\n" for an input string that contains the newline character.
// Need to revisit.
// public void test_fn_replace_27() throws Exception {
// String inputFile = "/TestSources/emptydoc.xml";
// String xqFile = "/Queries/XQuery/Functions/AllStringFunc/MatchStringFunc/ReplaceFunc/fn-replace-27.xq";
// String resultFile = "/ExpectedTestResults/Functions/AllStringFunc/MatchStringFunc/ReplaceFunc/fn-replace-27.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 = extractXPathExpression(xqFile, inputFile);
// String actual = null;
// try {
// XPath path = compileXPath(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);
// }
// Evaluation of replace function with pattern set to "aa{1}" (exact quantity) for an input string that contains the "aa" string.
public void test_fn_replace_28() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/Functions/AllStringFunc/MatchStringFunc/ReplaceFunc/fn-replace-28.xq";
    String resultFile = "/ExpectedTestResults/Functions/AllStringFunc/MatchStringFunc/ReplaceFunc/fn-replace-28.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 = 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 4 with Evaluator

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

the class ContextCurrentDatetimeFuncTest method test_fn_current_datetime_7.

// Evaluation of "fn:current-dateTime" function as part of an addition operation and a dayTimeDuration.
// public void test_fn_current_dateTime_6() throws Exception {
// String inputFile = "/TestSources/emptydoc.xml";
// String xqFile = "/Queries/XQuery/Functions/ContextFunc/ContextCurrentDatetimeFunc/fn-current-dateTime-6.xq";
// String resultFile = "/ExpectedTestResults/Functions/ContextFunc/ContextCurrentDatetimeFunc/fn-current-dateTime-6.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 = extractXPathExpression(xqFile, inputFile);
// String actual = null;
// try {
// XPath path = compileXPath(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);
// 
// 
// }
// Evaluation of "fn:current-dateTime" function as part of a subtraction operation and a dayTimeDuration.
public void test_fn_current_datetime_7() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/Functions/ContextFunc/ContextCurrentDatetimeFunc/fn-current-datetime-7.xq";
    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();
        fail("Returned:" + actual);
    } catch (StaticError ex) {
        actual = ex.code();
        fail("Returned:" + actual);
    } catch (DynamicError ex) {
        actual = ex.code();
        fail("Returned:" + actual);
    }
// 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 5 with Evaluator

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

the class TestWTPDOMXPath2 method test_nodeexpression11.

// Evaluation of a Node expression With the operands/operator set with the
// following format: Single Node Element is Single Node Element.
public void test_nodeexpression11() throws Exception {
    String inputFile = "/TestSources/works.xml";
    String xqFile = "/Queries/XQuery/Expressions/Operators/NodeOp/NodeSame/nodeexpression11.xq";
    String resultFile = "/ExpectedTestResults/Expressions/Operators/NodeOp/NodeSame/nodeexpression11.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