use of org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator in project webtools.sourceediting by eclipse.
the class NodeBeforeTest method test_nodeexpression29.
// Evaluation of a Node expression With the operands/operator set with the following format: Single Node Element "<<" Sequence of single Element Node.
// public void test_nodeexpression28() throws Exception {
// String inputFile = "/TestSources/works.xml";
// String inputFile2 = "/TestSources/staff.xml";
// String xqFile = "/Queries/XQuery/Expressions/Operators/NodeOp/NodeBefore/nodeexpression28.xq";
// String resultFile = "/ExpectedTestResults/Expressions/Operators/NodeOp/NodeBefore/nodeexpression28.txt";
// String expectedResult = getExpectedResult(resultFile);
// URL fileURL = bundle.getEntry(inputFile);
// URL fileURL2 = bundle.getEntry(inputFile2);
//
// loadDOMDocument(fileURL);
//
// // Get XML Schema Information for the Document
// XSModel schema = getGrammar();
//
// setupDynamicContext(schema);
//
// String xpath = extractXPathExpression(xqFile, inputFile);
// String actual = null;
// try {
// XPath path = compileXPath(xpath);
//
// Evaluator eval = new DefaultEvaluator(dc, domDoc);
// ResultSequence rs = eval.evaluate(path);
//
// 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 a Node expression With the operands/operator set with the following format: Sequence of single Element Node "<<" empty Sequence.
public void test_nodeexpression29() throws Exception {
String inputFile = "/TestSources/staff.xml";
String xqFile = "/Queries/XQuery/Expressions/Operators/NodeOp/NodeBefore/nodeexpression29.xq";
String resultFile = "/ExpectedTestResults/Expressions/Operators/NodeOp/NodeBefore/nodeexpression29.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);
}
use of org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator in project webtools.sourceediting by eclipse.
the class AxesTest method test_Axes088.
// Use of // to get all elements of a given name.
// Not a valid XPath 2 script
// public void test_Axes085() throws Exception {
// String inputFile = "/TestSources/nw_Customers.xml";
// String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes085.xq";
// String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/Axes/Axes085.xml";
// 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 {
// XPath path = compileXPath(xpath);
//
// Evaluator eval = new DefaultEvaluator(dc, domDoc);
// ResultSequence rs = eval.evaluate(path);
//
// 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);
//
//
// }
// Parent of attribute node.
// public void test_Axes086() throws Exception {
// String inputFile = "/TestSources/Tree1Text.xml";
// String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes086.xq";
// String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/Axes/Axes086.xml";
// 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 {
// XPath path = compileXPath(xpath);
//
// Evaluator eval = new DefaultEvaluator(dc, domDoc);
// ResultSequence rs = eval.evaluate(path);
//
// 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);
//
//
// }
// Parent of text nodes.
// public void test_Axes087() throws Exception {
// String inputFile = "/TestSources/xq311B.xml";
// String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes087.xq";
// String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/Axes/Axes087.xml";
// 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 {
// XPath path = compileXPath(xpath);
//
// Evaluator eval = new DefaultEvaluator(dc, domDoc);
// ResultSequence rs = eval.evaluate(path);
//
// 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);
//
//
// }
// Empty step should result in parse error.
public void test_Axes088() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes088.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);
}
use of org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator in project webtools.sourceediting by eclipse.
the class ReplaceFuncTest method test_fn_replace_28.
// Test of "replace" with the pattern set to "\n" for an input string that contains the newline character.
// Need to revisit.
// public void test_fn_replace_27() throws Exception {
// String inputFile = "/TestSources/emptydoc.xml";
// String xqFile = "/Queries/XQuery/Functions/AllStringFunc/MatchStringFunc/ReplaceFunc/fn-replace-27.xq";
// String resultFile = "/ExpectedTestResults/Functions/AllStringFunc/MatchStringFunc/ReplaceFunc/fn-replace-27.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 {
// XPath path = compileXPath(xpath);
//
// Evaluator eval = new DefaultEvaluator(dc, domDoc);
// ResultSequence rs = eval.evaluate(path);
//
// 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 replace function with pattern set to "aa{1}" (exact quantity) for an input string that contains the "aa" string.
public void test_fn_replace_28() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Functions/AllStringFunc/MatchStringFunc/ReplaceFunc/fn-replace-28.xq";
String resultFile = "/ExpectedTestResults/Functions/AllStringFunc/MatchStringFunc/ReplaceFunc/fn-replace-28.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);
}
use of org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator in project webtools.sourceediting by eclipse.
the class ContextCurrentDatetimeFuncTest method test_fn_current_datetime_7.
// Evaluation of "fn:current-dateTime" function as part of an addition operation and a dayTimeDuration.
// public void test_fn_current_dateTime_6() throws Exception {
// String inputFile = "/TestSources/emptydoc.xml";
// String xqFile = "/Queries/XQuery/Functions/ContextFunc/ContextCurrentDatetimeFunc/fn-current-dateTime-6.xq";
// String resultFile = "/ExpectedTestResults/Functions/ContextFunc/ContextCurrentDatetimeFunc/fn-current-dateTime-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 {
// XPath path = compileXPath(xpath);
//
// Evaluator eval = new DefaultEvaluator(dc, domDoc);
// ResultSequence rs = eval.evaluate(path);
//
// 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 "fn:current-dateTime" function as part of a subtraction operation and a dayTimeDuration.
public void test_fn_current_datetime_7() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Functions/ContextFunc/ContextCurrentDatetimeFunc/fn-current-datetime-7.xq";
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();
fail("Returned:" + actual);
} catch (StaticError ex) {
actual = ex.code();
fail("Returned:" + actual);
} catch (DynamicError ex) {
actual = ex.code();
fail("Returned:" + actual);
}
// assertEquals("XPath Result Error " + xqFile + ":", expectedResult, actual);
}
use of org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_nodeexpression11.
// Evaluation of a Node expression With the operands/operator set with the
// following format: Single Node Element is Single Node Element.
public void test_nodeexpression11() throws Exception {
String inputFile = "/TestSources/works.xml";
String xqFile = "/Queries/XQuery/Expressions/Operators/NodeOp/NodeSame/nodeexpression11.xq";
String resultFile = "/ExpectedTestResults/Expressions/Operators/NodeOp/NodeSame/nodeexpression11.txt";
String expectedResult = getExpectedResult(resultFile);
URL fileURL = bundle.getEntry(inputFile);
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 = 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);
}
Aggregations