Search in sources :

Example 1 with DocumentWrapper

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;
}
Also used : DocumentWrapper(org.sirix.saxon.wrapper.DocumentWrapper) Processor(net.sf.saxon.s9api.Processor) Configuration(net.sf.saxon.Configuration) XPathCompiler(net.sf.saxon.s9api.XPathCompiler) DocumentBuilder(net.sf.saxon.s9api.DocumentBuilder) NodeInfo(net.sf.saxon.om.NodeInfo) XPathSelector(net.sf.saxon.s9api.XPathSelector) XdmItem(net.sf.saxon.s9api.XdmItem)

Example 2 with DocumentWrapper

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;
}
Also used : XdmValue(net.sf.saxon.s9api.XdmValue) XQueryExecutable(net.sf.saxon.s9api.XQueryExecutable) DocumentWrapper(org.sirix.saxon.wrapper.DocumentWrapper) Processor(net.sf.saxon.s9api.Processor) Configuration(net.sf.saxon.Configuration) NodeInfo(net.sf.saxon.om.NodeInfo) XQueryCompiler(net.sf.saxon.s9api.XQueryCompiler) SaxonApiException(net.sf.saxon.s9api.SaxonApiException)

Example 3 with DocumentWrapper

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;
    }
}
Also used : XQueryExecutable(net.sf.saxon.s9api.XQueryExecutable) DocumentWrapper(org.sirix.saxon.wrapper.DocumentWrapper) Processor(net.sf.saxon.s9api.Processor) Configuration(net.sf.saxon.Configuration) NodeInfo(net.sf.saxon.om.NodeInfo) XQueryCompiler(net.sf.saxon.s9api.XQueryCompiler) SaxonApiException(net.sf.saxon.s9api.SaxonApiException) Serializer(net.sf.saxon.s9api.Serializer)

Example 4 with DocumentWrapper

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;
    }
}
Also used : XQueryExecutable(net.sf.saxon.s9api.XQueryExecutable) DocumentWrapper(org.sirix.saxon.wrapper.DocumentWrapper) Processor(net.sf.saxon.s9api.Processor) Configuration(net.sf.saxon.Configuration) NodeInfo(net.sf.saxon.om.NodeInfo) XQueryCompiler(net.sf.saxon.s9api.XQueryCompiler) SAXDestination(net.sf.saxon.s9api.SAXDestination) SaxonApiException(net.sf.saxon.s9api.SaxonApiException)

Example 5 with DocumentWrapper

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;
}
Also used : DocumentWrapper(org.sirix.saxon.wrapper.DocumentWrapper) Processor(net.sf.saxon.s9api.Processor) Configuration(net.sf.saxon.Configuration) NodeInfo(net.sf.saxon.om.NodeInfo) StreamSource(javax.xml.transform.stream.StreamSource) XsltTransformer(net.sf.saxon.s9api.XsltTransformer) SirixException(org.sirix.exception.SirixException) XsltCompiler(net.sf.saxon.s9api.XsltCompiler) XdmNode(net.sf.saxon.s9api.XdmNode) SaxonApiException(net.sf.saxon.s9api.SaxonApiException) XsltExecutable(net.sf.saxon.s9api.XsltExecutable) Serializer(net.sf.saxon.s9api.Serializer)

Aggregations

Configuration (net.sf.saxon.Configuration)5 NodeInfo (net.sf.saxon.om.NodeInfo)5 Processor (net.sf.saxon.s9api.Processor)5 DocumentWrapper (org.sirix.saxon.wrapper.DocumentWrapper)5 SaxonApiException (net.sf.saxon.s9api.SaxonApiException)4 XQueryCompiler (net.sf.saxon.s9api.XQueryCompiler)3 XQueryExecutable (net.sf.saxon.s9api.XQueryExecutable)3 Serializer (net.sf.saxon.s9api.Serializer)2 StreamSource (javax.xml.transform.stream.StreamSource)1 DocumentBuilder (net.sf.saxon.s9api.DocumentBuilder)1 SAXDestination (net.sf.saxon.s9api.SAXDestination)1 XPathCompiler (net.sf.saxon.s9api.XPathCompiler)1 XPathSelector (net.sf.saxon.s9api.XPathSelector)1 XdmItem (net.sf.saxon.s9api.XdmItem)1 XdmNode (net.sf.saxon.s9api.XdmNode)1 XdmValue (net.sf.saxon.s9api.XdmValue)1 XsltCompiler (net.sf.saxon.s9api.XsltCompiler)1 XsltExecutable (net.sf.saxon.s9api.XsltExecutable)1 XsltTransformer (net.sf.saxon.s9api.XsltTransformer)1 SirixException (org.sirix.exception.SirixException)1