Search in sources :

Example 11 with ForExpr

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

the class ForExprWithoutTest method test_ForExpr013.

// Multiple variables based off the same input context.
public void test_ForExpr013() throws Exception {
    String inputFile = "/TestSources/fsx.xml";
    String xqFile = "/Queries/XQuery/Expressions/FLWORExpr/ForExpr/ForExpr013.xq";
    String resultFile = "/ExpectedTestResults/Expressions/FLWORExpr/ForExpr/ForExpr013.xml";
    String expectedResult = "<result>" + getExpectedResult(resultFile) + "</result>";
    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 = "<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 : 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 ForExpr

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

the class ForExprWithoutTest method test_ForExpr025.

// Redefine existing bound variable. Second binding overrides first.
public void test_ForExpr025() throws Exception {
    String inputFile = "/TestSources/fsx.xml";
    String xqFile = "/Queries/XQuery/Expressions/FLWORExpr/ForExpr/ForExpr025.xq";
    String resultFile = "/ExpectedTestResults/Expressions/FLWORExpr/ForExpr/ForExpr025.xml";
    String expectedResult = "<result>" + getExpectedResult(resultFile) + "</result>";
    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 = "<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 : 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 ForExpr

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

the class ForExprWithoutTest method test_ForExpr021.

// Test order of iteration between two variables in the same 'for' statement.
public void test_ForExpr021() throws Exception {
    String inputFile = "/TestSources/fsx.xml";
    String xqFile = "/Queries/XQuery/Expressions/FLWORExpr/ForExpr/ForExpr021.xq";
    String resultFile = "/ExpectedTestResults/Expressions/FLWORExpr/ForExpr/ForExpr021.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 14 with ForExpr

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

the class ForExprWithoutTest method test_ForExpr026.

// Missing 'in'.
public void test_ForExpr026() throws Exception {
    String inputFile = "/TestSources/fsx.xml";
    String xqFile = "/Queries/XQuery/Expressions/FLWORExpr/ForExpr/ForExpr026.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 15 with ForExpr

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

the class ForExprWithoutTest method test_ForExpr001.

// For+Return - to iterate a constant sequence.
public void test_ForExpr001() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/Expressions/FLWORExpr/ForExpr/ForExpr001.xq";
    String resultFile = "/ExpectedTestResults/Expressions/FLWORExpr/ForExpr/ForExpr001.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)

Aggregations

URL (java.net.URL)18 DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)18 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)18 StaticError (org.eclipse.wst.xml.xpath2.processor.StaticError)18 XPathParserException (org.eclipse.wst.xml.xpath2.processor.XPathParserException)18 XSModel (org.apache.xerces.xs.XSModel)17 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 List (java.util.List)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 BinExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.BinExpr)1 CastExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.CastExpr)1 CastableExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.CastableExpr)1