| |
| /******************************************************************************* |
| * Copyright (c) 2009, 2017 Standards for Technology in Automotive Retail and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * David Carver - STAR - initial api and implementation bug 262765 |
| *******************************************************************************/ |
| package org.eclipse.wst.xml.xpath2.processor.testsuite.core; |
| |
| import java.net.URL; |
| |
| import org.apache.xerces.xs.XSModel; |
| import org.eclipse.wst.xml.xpath2.processor.DynamicError; |
| import org.eclipse.wst.xml.xpath2.processor.ResultSequence; |
| import org.eclipse.wst.xml.xpath2.processor.StaticError; |
| import org.eclipse.wst.xml.xpath2.processor.XPathParserException; |
| import org.eclipse.wst.xml.xpath2.processor.test.AbstractPsychoPathTest; |
| |
| |
| public class InternalContextExprTest extends AbstractPsychoPathTest { |
| |
| //Context Item expression that just uses the "." and no context item defined. |
| public void test_internalcontextitem_1() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-1.xq"; |
| String expectedResult = "XPDY0002"; |
| URL fileURL = bundle.getEntry(inputFile); |
| loadDOMDocument(fileURL); |
| |
| // Get XML Schema Information for the Document |
| XSModel schema = getGrammar(); |
| |
| setupDynamicContext(schema); |
| addNamespace("eg", "http://example.org"); |
| |
| String xpath = extractXPathExpression(xqFile, inputFile); |
| // Override, since we don't have XQuery syntax |
| xpath = "."; |
| String actual = null; |
| try { |
| compileXPath(xpath); |
| |
| ResultSequence rs = evaluate(null); // NO CONTEXT! |
| |
| 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 Internal context item expression where context item is used as a string. |
| public void test_internalcontextitem_2() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-2.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item is used as an integer. |
| public void test_internalcontextitem_3() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-3.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-3.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item is used as a decimal. |
| public void test_internalcontextitem_4() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-4.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-4.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item is used as a float. |
| public void test_internalcontextitem_5() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-5.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-5.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item is used as a double. |
| public void test_internalcontextitem_6() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-6.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item is used as a boolean value. |
| public void test_internalcontextitem_7() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-7.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-7.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item is used as aboolean with fn:not. |
| public void test_internalcontextitem_8() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-8.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-8.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item is the empty sequence. |
| public void test_internalcontextitem_9() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-9.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-9.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item used as part of addition operation. |
| public void test_internalcontextitem_10() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-10.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-10.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item used as part of a subtraction operation. |
| public void test_internalcontextitem_11() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-11.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item used as part of a multiplication operation. |
| public void test_internalcontextitem_12() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-12.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-12.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item used as part of a modulus operation. |
| public void test_internalcontextitem_13() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-13.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-13.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item used as part of a divison (div operator) operation. |
| public void test_internalcontextitem_14() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-14.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-14.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item used as part of a divison (idiv operator) operation. |
| public void test_internalcontextitem_15() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-15.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-15.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item used as part of a boolean expression (and operator). |
| public void test_internalcontextitem_16() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-16.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-16.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item used as part of a boolean expression (or operator). |
| public void test_internalcontextitem_17() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-17.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-17.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item used as argument to string-length function. |
| public void test_internalcontextitem_18() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-18.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-18.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item used as argument to "avg" function. |
| public void test_internalcontextitem_19() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-19.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-19.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item used as argument to "min" function. |
| public void test_internalcontextitem_20() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-20.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-20.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); |
| |
| |
| } |
| |
| //Evaluation of Internal context item expression where context item used as argument to "max" function. |
| public void test_internalcontextitem_21() throws Exception { |
| String inputFile = "/TestSources/emptydoc.xml"; |
| String xqFile = "/Queries/XQuery/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-21.xq"; |
| String resultFile = "/ExpectedTestResults/Expressions/ContextExpr/InternalContextExpr/internalcontextitem-21.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); |
| |
| |
| } |
| |
| } |
| |