use of org.eclipse.wst.xml.xpath2.processor.DynamicContext in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_Axes077_1.
// No children for elem//*.
public void test_Axes077_1() throws Exception {
String inputFile = "/TestSources/TreeTrunc.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes077.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/Axes/Axes077-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.DynamicContext in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_nodeexpression17.
// Evaluation of a Node expression With the operands/operator set with the
// following format: empty Sequence "<<" empty Sequence.
public void test_nodeexpression17() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/Operators/NodeOp/NodeBefore/nodeexpression17.xq";
String resultFile = "/ExpectedTestResults/Expressions/Operators/NodeOp/NodeBefore/nodeexpression17.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.DynamicContext in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method testWTPDOMWithTypes.
public void testWTPDOMWithTypes() throws Exception {
// Test for the fix, for xpathDefaultNamespace
bundle = Platform.getBundle("org.eclipse.wst.xml.xpath2.wtptypes.tests");
URL fileURL = bundle.getEntry("/bugTestFiles/attrNodeTest.xml");
super.domDoc = load(fileURL);
// set up XPath default namespace in Dynamic Context
DynamicContext dc = setupDynamicContext2(new XsdDOMTypeProvider.XsdTypeModel((IDOMDocument) domDoc));
assertXPathTrue("/Example/x[1] instance of element(*, x_Type)", dc, domDoc);
assertXPathTrue("not (/Example/x[1] instance of element(*, y_Type))", dc, domDoc);
assertXPathTrue("/Example/x instance of x_Type+", dc, domDoc);
assertXPathTrue("/Example/x instance of element(x, x_Type)+", dc, domDoc);
assertXPathTrue("not (/Example/x instance of element(z, x_Type)+)", dc, domDoc);
assertXPathTrue("/Example/x[2]/@mesg instance of mesg_Type", dc, domDoc);
assertXPathTrue("/Example/x[2]/@mesg instance of attribute(mesg, mesg_Type)", dc, domDoc);
assertXPathTrue("not (/Example/x[2]/@mesg instance of attribute(mesg, xs:integer))", dc, domDoc);
assertXPathTrue("not (/Example/x[2]/@mesg instance of attribute(cesc, mesg_Type))", dc, domDoc);
assertXPathTrue("/Example/y/@intAttr instance of attribute(intAttr, xs:integer)", dc, domDoc);
}
use of org.eclipse.wst.xml.xpath2.processor.DynamicContext in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_unabbreviatedSyntax_23.
// Evaluates unabbreviated syntax. Evaluate
// "child::hours[fn:position() > 1]". Selects all the para children of the
// context node other than the first "hours" child of the context node.
public void test_unabbreviatedSyntax_23() throws Exception {
String inputFile = "/TestSources/works-mod.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/UnabbrAxes/unabbreviatedSyntax-23.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/UnabbrAxes/unabbreviatedSyntax-23.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);
}
use of org.eclipse.wst.xml.xpath2.processor.DynamicContext in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_Axes075_3.
// elem//child::name gets the 1 descendant of that name.
public void test_Axes075_3() throws Exception {
String inputFile = "/TestSources/TreeCompass.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/Axes/Axes075.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/Axes/Axes075-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);
}
Aggregations