use of org.eclipse.wst.xml.xpath2.processor.internal.DefaultStaticContext 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);
}
Aggregations