use of org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_Axes074_3.
// elem//child::* gets 1 child element.
public void test_Axes074_3() throws Exception {
String inputFile = "/TestSources/Tree1Child.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes074.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/Axes/Axes074-3.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);
}
use of org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_unabbreviatedSyntax_13.
// Evaluates unabbreviated syntax - self::employee - Selects the context
// node, if it is an "employee" element, otherwise returns empty sequence.
// This test retuns an "employee" element.
public void test_unabbreviatedSyntax_13() throws Exception {
String inputFile = "/TestSources/works-mod.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/UnabbrAxes/unabbreviatedSyntax-13.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/UnabbrAxes/unabbreviatedSyntax-13.txt";
String expectedResult = formatResultString(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 = buildXMLResultString(rs);
} 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);
}
use of org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_filterexpressionhc1.
// Simple filter using data query from xml source and the "gt" operator.
public void test_filterexpressionhc1() throws Exception {
String inputFile = "/TestSources/works.xml";
String xqFile = "/Queries/XQuery/Expressions/SeqExpr/FilterExpr/filterexpressionhc1.xq";
String resultFile = "/ExpectedTestResults/Expressions/SeqExpr/FilterExpr/filterexpressionhc1.txt";
String expectedResult = "<result>" + getExpectedResult(resultFile) + "</result>";
URL fileURL = bundle.getEntry(inputFile);
super.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 = "<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);
}
use of org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_Axes079_1.
// No children, elem//node() gets none.
public void test_Axes079_1() throws Exception {
String inputFile = "/TestSources/TreeTrunc.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes079.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/Axes/Axes079-1.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);
}
use of org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_nodeexpression4.
// Evaluation of a Node expression With the operands/operator set with the
// following format: empty Sequence is Sequence of single Element Node.
public void test_nodeexpression4() throws Exception {
String inputFile = "/TestSources/staff.xml";
String xqFile = "/Queries/XQuery/Expressions/Operators/NodeOp/NodeSame/nodeexpression4.xq";
String resultFile = "/ExpectedTestResults/Expressions/Operators/NodeOp/NodeSame/nodeexpression4.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