Search in sources :

Example 26 with FilterExpr

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

the class FilterExprTest method test_filterexpressionhc2.

// Simple filter expression returning a sequence of integers between 1 and 25 divisible by 2.
public void test_filterexpressionhc2() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/Expressions/SeqExpr/FilterExpr/filterexpressionhc2.xq";
    String resultFile = "/ExpectedTestResults/Expressions/SeqExpr/FilterExpr/filterexpressionhc2.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 27 with FilterExpr

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

the class TestWTPDOMXPath2 method test_filterexpressionhc1.

// Simple filter using data query from xml source and the "gt" operator.
public void test_filterexpressionhc1() throws Exception {
    String inputFile = "/TestSources/works.xml";
    String xqFile = "/Queries/XQuery/Expressions/SeqExpr/FilterExpr/filterexpressionhc1.xq";
    String resultFile = "/ExpectedTestResults/Expressions/SeqExpr/FilterExpr/filterexpressionhc1.txt";
    String expectedResult = "<result>" + getExpectedResult(resultFile) + "</result>";
    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 = "<result>" + buildXMLResultString(rs) + "</result>";
    } 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)

Aggregations

URL (java.net.URL)23 XSModel (org.apache.xerces.xs.XSModel)23 DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)23 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)23 StaticError (org.eclipse.wst.xml.xpath2.processor.StaticError)23 XPathParserException (org.eclipse.wst.xml.xpath2.processor.XPathParserException)23 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)2 Focus (org.eclipse.wst.xml.xpath2.processor.internal.Focus)2 FilterExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.FilterExpr)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 ListIterator (java.util.ListIterator)1 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)1 DefaultEvaluator (org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator)1 DynamicContext (org.eclipse.wst.xml.xpath2.processor.DynamicContext)1 Evaluator (org.eclipse.wst.xml.xpath2.processor.Evaluator)1 XPath (org.eclipse.wst.xml.xpath2.processor.ast.XPath)1 AddExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.AddExpr)1 AndExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.AndExpr)1