use of org.sirix.saxon.wrapper.DocumentWrapper 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 org.sirix.saxon.wrapper.DocumentWrapper 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 org.sirix.saxon.wrapper.DocumentWrapper 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 org.sirix.saxon.wrapper.DocumentWrapper 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 org.sirix.saxon.wrapper.DocumentWrapper 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;
}
Aggregations