Search in sources :

Example 11 with Configuration

use of net.sf.saxon.Configuration in project camel by apache.

the class XQueryWithExtensionTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry jndi = super.createRegistry();
    conf = new Configuration();
    conf.registerExtensionFunction(new SimpleExtension());
    jndi.bind("saxonConf", conf);
    return jndi;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) Configuration(net.sf.saxon.Configuration)

Example 12 with Configuration

use of net.sf.saxon.Configuration in project sirix by sirixdb.

the class TestNodeWrapper method testCompareOrder.

@Test
public void testCompareOrder() throws XPathException, SirixException {
    final Processor proc = new Processor(false);
    final Configuration config = proc.getUnderlyingConfiguration();
    final Session session = generateSession();
    final NodeWriteTrx trx = session.beginNodeWriteTrx();
    trx.commit();
    trx.close();
    // Not the same document.
    NodeInfo node = new DocumentWrapper(session, config);
    NodeInfo other = new NodeWrapper(new DocumentWrapper(mHolder.getSession(), config), 3);
    try {
        node.compareOrder(other);
        fail();
    } catch (final IllegalStateException e) {
    }
    // Before.
    node = new DocumentWrapper(mHolder.getSession(), config);
    other = new NodeWrapper(new DocumentWrapper(mHolder.getSession(), config), 3);
    assertEquals(-1, node.compareOrder(other));
    // After.
    node = new NodeWrapper(new DocumentWrapper(mHolder.getSession(), config), 3);
    other = new NodeWrapper(new DocumentWrapper(mHolder.getSession(), config), 0);
    assertEquals(1, node.compareOrder(other));
    // Same.
    node = new NodeWrapper(new DocumentWrapper(mHolder.getSession(), config), 3);
    other = new NodeWrapper(new DocumentWrapper(mHolder.getSession(), config), 3);
    assertEquals(0, node.compareOrder(other));
    session.close();
    mDatabase.close();
}
Also used : Processor(net.sf.saxon.s9api.Processor) Configuration(net.sf.saxon.Configuration) DatabaseConfiguration(org.sirix.access.conf.DatabaseConfiguration) ResourceConfiguration(org.sirix.access.conf.ResourceConfiguration) SessionConfiguration(org.sirix.access.conf.SessionConfiguration) NodeInfo(net.sf.saxon.om.NodeInfo) NodeWriteTrx(org.sirix.api.NodeWriteTrx) Session(org.sirix.api.Session) NameTest(net.sf.saxon.pattern.NameTest) Test(org.junit.Test)

Example 13 with Configuration

use of net.sf.saxon.Configuration in project sirix by sirixdb.

the class TestNodeWrapper method beforeMethod.

@Before
public void beforeMethod() throws SirixException {
    Databases.truncateDatabase(DB_CONFIG);
    Databases.createDatabase(DB_CONFIG);
    TestHelper.createTestDocument();
    mHolder = Holder.generateRtx();
    final Processor proc = new Processor(false);
    final Configuration config = proc.getUnderlyingConfiguration();
    node = new DocumentWrapper(mHolder.getSession(), config).getNodeWrapper();
}
Also used : Processor(net.sf.saxon.s9api.Processor) Configuration(net.sf.saxon.Configuration) DatabaseConfiguration(org.sirix.access.conf.DatabaseConfiguration) ResourceConfiguration(org.sirix.access.conf.ResourceConfiguration) SessionConfiguration(org.sirix.access.conf.SessionConfiguration) Before(org.junit.Before)

Example 14 with Configuration

use of net.sf.saxon.Configuration 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 15 with Configuration

use of net.sf.saxon.Configuration 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)16 Processor (net.sf.saxon.s9api.Processor)7 NodeInfo (net.sf.saxon.om.NodeInfo)6 DocumentWrapper (org.sirix.saxon.wrapper.DocumentWrapper)5 SaxonApiException (net.sf.saxon.s9api.SaxonApiException)4 StreamSource (javax.xml.transform.stream.StreamSource)3 XQueryCompiler (net.sf.saxon.s9api.XQueryCompiler)3 XQueryExecutable (net.sf.saxon.s9api.XQueryExecutable)3 DocumentInfo (net.sf.saxon.om.DocumentInfo)2 Item (net.sf.saxon.om.Item)2 DynamicQueryContext (net.sf.saxon.query.DynamicQueryContext)2 Serializer (net.sf.saxon.s9api.Serializer)2 Test (org.junit.Test)2 DatabaseConfiguration (org.sirix.access.conf.DatabaseConfiguration)2 ResourceConfiguration (org.sirix.access.conf.ResourceConfiguration)2 SessionConfiguration (org.sirix.access.conf.SessionConfiguration)2 MapBasedXPathFunctionResolver (com.helger.xml.xpath.MapBasedXPathFunctionResolver)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 SQLException (java.sql.SQLException)1