use of org.eclipse.wst.xml.xpath2.processor.XPathParser in project webtools.sourceediting by eclipse.
the class TestXPath20 method testParseValidXPathExpression.
public void testParseValidXPathExpression() throws Exception {
XPathParser xpp = new JFlexCupParser();
String xpath = "some $x in /students/student/name satisfies $x = \"Fred\"";
xpp.parse(xpath);
}
use of org.eclipse.wst.xml.xpath2.processor.XPathParser in project webtools.sourceediting by eclipse.
the class StaticContextAdapterTest method testFunctionCall.
public void testFunctionCall() {
XPathParser xpp = new JFlexCupParser();
XPath xpath = xpp.parse("fn:sum((1,2,3))");
DefaultStaticContext sc = new DefaultStaticContext(null);
sc.add_namespace("fn", "http://www.w3.org/2005/xpath-functions");
sc.add_function_library(new FnFunctionLibrary());
StaticChecker namecheck = new StaticNameResolver(sc);
namecheck.check(xpath);
DefaultDynamicContext dc = new DefaultDynamicContext(null, null);
dc.add_namespace("fn", "http://www.w3.org/2005/xpath-functions");
dc.add_function_library(new FnFunctionLibrary());
Evaluator eval = new DefaultEvaluator(dc, null);
ResultSequence rs = eval.evaluate(xpath);
assertEquals(1, rs.size());
XSDecimal result = (XSDecimal) rs.first();
String actual = result.getStringValue();
assertEquals("6", actual);
}
use of org.eclipse.wst.xml.xpath2.processor.XPathParser in project webtools.sourceediting by eclipse.
the class TestXPath20 method testParseInvalidXPathExpression.
public void testParseInvalidXPathExpression() throws Exception {
try {
XPathParser xpp = new JFlexCupParser();
String xpath = "for in /order/item return $x/price * $x/quantity";
xpp.parse(xpath);
fail("XPath parsing suceeded when it should have failed.");
} catch (XPathParserException ex) {
}
}
Aggregations