use of org.eclipse.wst.xml.xpath2.processor.DynamicContext in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_unabbreviatedSyntax_22.
// Evaluates unabbreviated syntax. Evaluate
// "child::employee[fn:position() = fn:last()-1]. Selects the previous to the last one "employee"
// child of the context node.
public void test_unabbreviatedSyntax_22() throws Exception {
String inputFile = "/TestSources/works-mod.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/UnabbrAxes/unabbreviatedSyntax-22.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/UnabbrAxes/unabbreviatedSyntax-22.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.DynamicContext in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method testSimpleWTPDOM.
public void testSimpleWTPDOM() throws Exception {
// Test for the fix, for xpathDefaultNamespace
bundle = Platform.getBundle("org.eclipse.wst.xml.xpath2.wtptypes.tests");
URL fileURL = bundle.getEntry("/bugTestFiles/bug273719.xml");
super.domDoc = load(fileURL);
// set up XPath default namespace in Dynamic Context
DynamicContext dc = setupDynamicContext(null);
String xpath = "string-length(x) > 2";
XPath path = compileXPath(dc, xpath);
Evaluator eval = new DefaultEvaluator(dc, domDoc);
ResultSequence rs = eval.evaluate(path);
AnyType result = rs.first();
String actual = result.string_value();
assertEquals("true", actual);
}
use of org.eclipse.wst.xml.xpath2.processor.DynamicContext in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_unabbreviatedSyntax_28.
// Evaluates unabbreviated syntax. Evaluate
// "child::employee[attribute::name eq "Jane Doe 11"]". Selects all
// "employee" children of the context node that have a "name" attribute with
// value "Jane Doe 11".
public void test_unabbreviatedSyntax_28() throws Exception {
String inputFile = "/TestSources/works-mod.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/UnabbrAxes/unabbreviatedSyntax-28.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/UnabbrAxes/unabbreviatedSyntax-28.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.DynamicContext in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_unabbreviatedSyntax_30.
// Evaluates unabbreviated syntax. Evaluate
// "child::employee[child::empnum = 'E3']". Selects the employee children of
// the context node that have one or more empnum children whose typed value
// is equal to the string "E3".
public void test_unabbreviatedSyntax_30() throws Exception {
String inputFile = "/TestSources/works-mod.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/UnabbrAxes/unabbreviatedSyntax-30.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/UnabbrAxes/unabbreviatedSyntax-30.txt";
String expectedResult = "<result>" + getExpectedResult(resultFile) + "</result>";
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 = "<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.DynamicContext in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_unabbreviatedSyntax_18.
// Evaluates unabbreviated syntax. Evaluate /descendant::pnum - Selects all
// the pnum elements in the same document as the context node.
public void test_unabbreviatedSyntax_18() throws Exception {
String inputFile = "/TestSources/works-mod.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/UnabbrAxes/unabbreviatedSyntax-18.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/UnabbrAxes/unabbreviatedSyntax-18.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 = 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);
}
Aggregations