Search in sources :

Example 1 with ForExpr

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

the class ForExprWithoutTest method test_ForExpr018.

// Multiple in statements for single variable binding.
public void test_ForExpr018() throws Exception {
    String inputFile = "/TestSources/fsx.xml";
    String xqFile = "/Queries/XQuery/Expressions/FLWORExpr/ForExpr/ForExpr018.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 2 with ForExpr

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

the class ForExprWithoutTest method test_ForExpr009.

// For+Return - error, use variable in it's own declaration.
public void test_ForExpr009() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/Expressions/FLWORExpr/ForExpr/ForExpr009.xq";
    String expectedResult = "XPST0008";
    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 3 with ForExpr

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

the class ForExprWithoutTest method test_ForExpr015.

// Return expression contains nested for expression.
public void test_ForExpr015() throws Exception {
    String inputFile = "/TestSources/fsx.xml";
    String xqFile = "/Queries/XQuery/Expressions/FLWORExpr/ForExpr/ForExpr015.xq";
    String resultFile = "/ExpectedTestResults/Expressions/FLWORExpr/ForExpr/ForExpr015.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 ForExpr

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

the class ForExprWithoutTest method test_ForExpr017.

// Multiple return statements from single for expression.
public void test_ForExpr017() throws Exception {
    String inputFile = "/TestSources/fsx.xml";
    String xqFile = "/Queries/XQuery/Expressions/FLWORExpr/ForExpr/ForExpr017.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 5 with ForExpr

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

the class ForExprWithoutTest method test_ForExpr016.

// Interate over nodes in document and constant sequence. Return value based on both.
public void test_ForExpr016() throws Exception {
    String inputFile = "/TestSources/fsx.xml";
    String xqFile = "/Queries/XQuery/Expressions/FLWORExpr/ForExpr/ForExpr016.xq";
    String resultFile = "/ExpectedTestResults/Expressions/FLWORExpr/ForExpr/ForExpr016.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)

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