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;
}
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();
}
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();
}
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;
}
}
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;
}
Aggregations