use of org.eclipse.wst.xml.xpath2.api.DynamicContext in project webtools.sourceediting by eclipse.
the class AbstractPsychoPathWTPTest method setupVariables.
protected DynamicContext setupVariables(DynamicContext dc) {
dc.add_variable(new QName("x"));
dc.add_variable(new QName("var"));
if (domDoc != null) {
AnyType docType = new DocType(domDoc, dc.getTypeModel(domDoc));
dc.set_variable(new QName("input-context1"), docType);
dc.set_variable(new QName("input-context"), docType);
if (domDoc2 == null) {
dc.set_variable(new QName("input-context2"), docType);
} else {
dc.set_variable(new QName("input-context2"), (AnyType) new DocType(domDoc2, dc.getTypeModel(domDoc2)));
}
}
return dc;
}
use of org.eclipse.wst.xml.xpath2.api.DynamicContext in project webtools.sourceediting by eclipse.
the class AbstractPsychoPathWTPTest method compileXPath.
protected XPath compileXPath(DynamicContext dc, String xpath) throws XPathParserException, StaticError {
XPathParser xpp = new JFlexCupParser();
XPath path = xpp.parse(xpath);
StaticChecker name_check = new StaticNameResolver(dc);
name_check.check(path);
return path;
}
use of org.eclipse.wst.xml.xpath2.api.DynamicContext in project webtools.sourceediting by eclipse.
the class AbstractPsychoPathWTPTest method setupDynamicContext.
protected DefaultDynamicContext setupDynamicContext(XSModel schema) {
XercesTypeModel typeModel = schema != null ? new XercesTypeModel(schema) : null;
DefaultDynamicContext dc = new DefaultDynamicContext(typeModel);
// DefaultDynamicContext dc = new DefaultDynamicContext(schema, domDoc);
dynamicContext = dc;
dc.add_namespace("xs", "http://www.w3.org/2001/XMLSchema");
dc.add_namespace("xsd", "http://www.w3.org/2001/XMLSchema");
dc.add_namespace("fn", "http://www.w3.org/2005/xpath-functions");
dc.add_namespace("xml", "http://www.w3.org/XML/1998/namespace");
dc.add_function_library(new FnFunctionLibrary());
dc.add_function_library(new XSCtrLibrary());
setupVariables(dc);
return dc;
}
use of org.eclipse.wst.xml.xpath2.api.DynamicContext in project webtools.sourceediting by eclipse.
the class AbstractPsychoPathWTPTest method compileXPath.
protected XPath compileXPath(DynamicContext dc, String xpath, boolean isRootlessAccess) throws XPathParserException, StaticError {
XPathParser xpp = new JFlexCupParser();
XPath path = null;
if (isRootlessAccess) {
path = xpp.parse(xpath, isRootlessAccess);
} else {
path = xpp.parse(xpath);
}
StaticChecker name_check = new StaticNameResolver(dc);
name_check.check(path);
return path;
}
use of org.eclipse.wst.xml.xpath2.api.DynamicContext in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method test_nodeexpression11.
// Evaluation of a Node expression With the operands/operator set with the
// following format: Single Node Element is Single Node Element.
public void test_nodeexpression11() throws Exception {
String inputFile = "/TestSources/works.xml";
String xqFile = "/Queries/XQuery/Expressions/Operators/NodeOp/NodeSame/nodeexpression11.xq";
String resultFile = "/ExpectedTestResults/Expressions/Operators/NodeOp/NodeSame/nodeexpression11.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