use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class TestNodeWrapper method testGetAttributeValue.
@Test
public void testGetAttributeValue() throws SirixException {
final Processor proc = new Processor(false);
node = new NodeWrapper(new DocumentWrapper(mHolder.getSession(), proc.getUnderlyingConfiguration()), 1);
final AxisIterator iterator = node.iterateAxis(Axis.ATTRIBUTE);
final NodeInfo attribute = (NodeInfo) iterator.next();
node.getNamePool().allocate(attribute.getPrefix(), attribute.getURI(), attribute.getLocalPart());
// Only supported on element nodes.
// node = (NodeWrapper) node.getParent();
assertEquals("j", node.getAttributeValue(attribute.getFingerprint()));
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class XQueryEvaluatorSAXHandler 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);
final net.sf.saxon.s9api.XQueryEvaluator exe = exp.load();
exe.setSource(doc);
exe.run(new SAXDestination(mHandler));
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 XSLTEvaluator method call.
@Override
public OutputStream call() {
final Processor proc = new Processor(false);
final XsltCompiler comp = proc.newXsltCompiler();
XsltExecutable exp;
XdmNode source;
try {
final Configuration config = proc.getUnderlyingConfiguration();
final NodeInfo doc = new DocumentWrapper(mSession, config);
exp = comp.compile(new StreamSource(mStylesheet));
source = proc.newDocumentBuilder().build(doc);
if (mSerializer == null) {
final Serializer out = new Serializer();
out.setOutputProperty(Serializer.Property.METHOD, "xml");
out.setOutputProperty(Serializer.Property.INDENT, "yes");
out.setOutputStream(mOut);
mSerializer = out;
} else {
mSerializer.setOutputStream(mOut);
}
final XsltTransformer trans = exp.load();
trans.setInitialContextNode(source);
trans.setDestination(mSerializer);
trans.transform();
} catch (final SaxonApiException e) {
LOGGER.error("Saxon exception: " + e.getMessage(), e);
} catch (final SirixException e) {
LOGGER.error("TT exception: " + e.getMessage(), e);
}
return mOut;
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class TestNodeWrapperXPath method testNamespaceAttributeValue.
@Test
public void testNamespaceAttributeValue() throws Exception {
xpe.setNamespaceContext(new DocNamespaceContext());
final XPathExpression findLine = xpe.compile("//p:a/@p:i");
final NodeInfo doc = new DocumentWrapper(mHolder.getSession(), config);
// Execute XPath.
final String result = findLine.evaluate(doc, XPathConstants.STRING).toString();
assertNotNull(result);
assertEquals("", result);
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class TestNodeWrapperXPath method testNamespaceElementCount.
@Test
public void testNamespaceElementCount() throws Exception {
xpe.setNamespaceContext(new DocNamespaceContext());
final XPathExpression findLine = xpe.compile("count(//p:a)");
final NodeInfo doc = new DocumentWrapper(mHolder.getSession(), config);
// Execute XPath.
final double result = Double.parseDouble(findLine.evaluate(doc, XPathConstants.NUMBER).toString());
assertNotNull(result);
assertEquals(1D, result, 0D);
}
Aggregations