Search in sources :

Example 11 with Function

use of org.eclipse.wst.xml.xpath2.api.Function in project webtools.sourceediting by eclipse.

the class DateAddYMDTest method test_op_add_yearMonthDuration_to_date_6.

// Evaluates the "op:add-yearMonthDuration-to-date" operator as an argument to the "fn:number" function.
public void test_op_add_yearMonthDuration_to_date_6() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/Expressions/Operators/ArithExpr/DurationArith/DateAddYMD/op-add-yearMonthDuration-to-date-6.xq";
    String resultFile = "/ExpectedTestResults/Expressions/Operators/ArithExpr/DurationArith/DateAddYMD/op-add-yearMonthDuration-to-date-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 {
        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 12 with Function

use of org.eclipse.wst.xml.xpath2.api.Function in project webtools.sourceediting by eclipse.

the class DateAddYMDTest method test_op_add_yearMonthDuration_to_date_2.

// Evaluates the "op:add-yearMonthDuration-to-date" operator as part of a boolean expression (and operator) and the "fn:false" function.
public void test_op_add_yearMonthDuration_to_date_2() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/Expressions/Operators/ArithExpr/DurationArith/DateAddYMD/op-add-yearMonthDuration-to-date-2.xq";
    String resultFile = "/ExpectedTestResults/Expressions/Operators/ArithExpr/DurationArith/DateAddYMD/op-add-yearMonthDuration-to-date-2.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 13 with Function

use of org.eclipse.wst.xml.xpath2.api.Function in project webtools.sourceediting by eclipse.

the class DateAddYMDTest method test_op_add_yearMonthDuration_to_date_1.

// Evaluates the "op:add-yearMonthDuration-to-date" operator as per example 1 (for this function) of the Functions and Operators spec.
public void test_op_add_yearMonthDuration_to_date_1() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/Expressions/Operators/ArithExpr/DurationArith/DateAddYMD/op-add-yearMonthDuration-to-date-1.xq";
    String resultFile = "/ExpectedTestResults/Expressions/Operators/ArithExpr/DurationArith/DateAddYMD/op-add-yearMonthDuration-to-date-1.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 Function

use of org.eclipse.wst.xml.xpath2.api.Function in project webtools.sourceediting by eclipse.

the class DateEdgeCasesTest method test_op_divide_dayTimeDuration_by_dTD_11.

// Evaluates the "op:divide-dayTimeDuration-by-dayTimeDuration" function,
// which is part of a div expression.
public void test_op_divide_dayTimeDuration_by_dTD_11() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/Expressions/Operators/ArithExpr/DurationArith/DayTimeDurationDivideDTD/op-divide-dayTimeDuration-by-dTD-11.xq";
    String resultFile = "/ExpectedTestResults/Expressions/Operators/ArithExpr/DurationArith/DayTimeDurationDivideDTD/op-divide-dayTimeDuration-by-dTD-11.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 15 with Function

use of org.eclipse.wst.xml.xpath2.api.Function in project webtools.sourceediting by eclipse.

the class DateEdgeCasesTest method test_op_subtract_dayTimeDurations_11.

// Evaluates the "op:subtract-dayTimeDurations" function, which is part of a
// div expression.
public void test_op_subtract_dayTimeDurations_11() throws Exception {
    String inputFile = "/TestSources/emptydoc.xml";
    String xqFile = "/Queries/XQuery/Expressions/Operators/ArithExpr/DurationArith/DayTimeDurationSubtract/op-subtract-dayTimeDurations-11.xq";
    String resultFile = "/ExpectedTestResults/Expressions/Operators/ArithExpr/DurationArith/DayTimeDurationSubtract/op-subtract-dayTimeDurations-11.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)3073 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)3073 XSModel (org.apache.xerces.xs.XSModel)3072 DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)3072 StaticError (org.eclipse.wst.xml.xpath2.processor.StaticError)3072 XPathParserException (org.eclipse.wst.xml.xpath2.processor.XPathParserException)3072 Schema (javax.xml.validation.Schema)19 XSAnyURI (org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI)15 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)14 Item (org.eclipse.wst.xml.xpath2.api.Item)13 BigInteger (java.math.BigInteger)12 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)10 Collection (java.util.Collection)8 Iterator (java.util.Iterator)8 ArrayList (java.util.ArrayList)6 Function (org.eclipse.wst.xml.xpath2.api.Function)6 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)4 QName (org.eclipse.wst.xml.xpath2.processor.internal.types.QName)4 Map (java.util.Map)3 Duration (javax.xml.datatype.Duration)3