use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class XQueryEvaluator method call.
@Override
public XdmValue call() throws Exception {
XdmValue value = null;
try {
final Processor proc = new Processor(false);
final Configuration config = proc.getUnderlyingConfiguration();
final NodeInfo doc = new DocumentWrapper(mSession, config);
final XQueryCompiler comp = proc.newXQueryCompiler();
final XQueryExecutable exp = comp.compile(mExpression);
final net.sf.saxon.s9api.XQueryEvaluator exe = exp.load();
exe.setSource(doc);
value = exe.evaluate();
} catch (final SaxonApiException e) {
LOGGER.error("Saxon Exception: " + e.getMessage(), e);
throw e;
}
return value;
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class XQueryEvaluatorOutputStream method call.
@Override
public Void call() throws Exception {
try {
final Processor proc = new Processor(false);
final Configuration config = proc.getUnderlyingConfiguration();
final NodeInfo doc = new DocumentWrapper(mSession, config);
final XQueryCompiler comp = proc.newXQueryCompiler();
final XQueryExecutable exp = comp.compile(mExpression);
if (mSerializer == null) {
final Serializer out = new Serializer();
out.setOutputProperty(Serializer.Property.METHOD, "xml");
out.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes");
out.setOutputStream(mOut);
mSerializer = out;
}
final net.sf.saxon.s9api.XQueryEvaluator exe = exp.load();
exe.setSource(doc);
exe.run(mSerializer);
return null;
} catch (final SaxonApiException e) {
LOGGER.error("Saxon Exception: " + e.getMessage(), e);
throw e;
}
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class TestNodeWrapperXPath method testElementBCount.
@Test
public void testElementBCount() throws Exception {
final XPathExpression findLine = xpe.compile("count(//b)");
final NodeInfo doc = new DocumentWrapper(mHolder.getSession(), config);
// Execute XPath.
final double result = Double.parseDouble(findLine.evaluate(doc, XPathConstants.NUMBER).toString());
assertNotNull(result);
assertEquals(2D, result, 0D);
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class TestNodeWrapperXPath method testB1.
@Test
public void testB1() throws Exception {
xpe.setNamespaceContext(new DocNamespaceContext());
final XPathExpression findLine = xpe.compile("//b[1]");
final NodeInfo doc = new DocumentWrapper(mHolder.getSession(), config);
// Execute XPath.
final String result = (String) findLine.evaluate(doc, XPathConstants.STRING);
assertNotNull(result);
assertEquals("foo", result);
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class TestNodeWrapperXPath method testDefaultNamespaceText2.
@Test
public void testDefaultNamespaceText2() throws Exception {
xpe.setNamespaceContext(new DocNamespaceContext());
final XPathExpression findLine = xpe.compile("//p:a/text()[2]");
final NodeInfo doc = new DocumentWrapper(mHolder.getSession(), config);
// Execute XPath.
final String result = (String) findLine.evaluate(doc, XPathConstants.STRING);
assertNotNull(result);
assertEquals("oops2", result);
}
Aggregations