use of net.sf.saxon.s9api.XPathCompiler in project sirix by sirixdb.
the class XPathEvaluator method call.
@Override
public XPathSelector call() throws Exception {
final Processor proc = new Processor(false);
final Configuration config = proc.getUnderlyingConfiguration();
final NodeInfo doc = new DocumentWrapper(mSession, mRevision, config);
final XPathCompiler xpath = proc.newXPathCompiler();
final DocumentBuilder builder = proc.newDocumentBuilder();
final XdmItem item = builder.wrap(doc);
final XPathSelector selector = xpath.compile(mExpression).load();
selector.setContextItem(item);
return selector;
}
use of net.sf.saxon.s9api.XPathCompiler in project jmeter by apache.
the class XPathUtilTest method testBug63033.
@Test
public void testBug63033() throws SaxonApiException {
Processor p = new Processor(false);
XPathCompiler c = p.newXPathCompiler();
c.declareNamespace("age", "http://www.w3.org/2003/01/geo/wgs84_pos#");
String xPathQuery = "//Employees/Employee[1]/age:ag";
XPathExecutable e = c.compile(xPathQuery);
XPathSelector selector = e.load();
selector.setContextItem(p.newDocumentBuilder().build(new StreamSource(new StringReader(xmlDoc))));
XdmValue nodes = selector.evaluate();
XdmItem item = nodes.itemAt(0);
assertEquals("<age:ag xmlns:age=\"http://www.w3.org/2003/01/geo/wgs84_pos#\">29</age:ag>", item.toString());
}
use of net.sf.saxon.s9api.XPathCompiler in project jmeter by apache.
the class XPathQueryCacheLoader method load.
@Override
public XPathExecutable load(ImmutablePair<String, String> key) throws Exception {
String xPathQuery = key.left;
String namespacesString = key.right;
Processor processor = XPathUtil.getProcessor();
XPathCompiler xPathCompiler = processor.newXPathCompiler();
List<String[]> namespacesList = XPathUtil.namespacesParse(namespacesString);
log.debug("Parsed namespaces:{} into list of namespaces:{}", namespacesString, namespacesList);
for (String[] namespaces : namespacesList) {
xPathCompiler.declareNamespace(namespaces[0], namespaces[1]);
}
log.debug("Declared namespaces:{}, now compiling xPathQuery:{}", namespacesList, xPathQuery);
return xPathCompiler.compile(xPathQuery);
}
Aggregations