- By Javier Chacana
- ·
- Posted 30 Sep 2021
JBCNConf in times of COVID
This year, the 2021 edition of the traditional JBCNConf was held. Unfortunately, the 2020 event didn't take place the year prior due to difficulties..
Saxon is a wonderful API for XML processing. It provides complete support for XPath, XQuery and XSLT. Although I'm always baffled with it's lack of adoption compared to Xalan and Xerces. Having said that the online documentation can definitely do with some improvement. The following is a quick example of of how you may execute an XQuery that takes multiple XML documents as input. [sourcecode language="java"] @Test public void runXQueryWithMultipleInputDocuments() throws SaxonApiException { Processor processor = new Processor(false);
DocumentBuilder documentBuilder = processor.newDocumentBuilder();
XdmNode document = documentBuilder.build(
new StreamSource(new StringReader("<my><document>content</document></my>")));
XdmNode document2 = documentBuilder.build(
new StreamSource(new StringReader("<my><document>content2</document></my>")));
XQueryCompiler xQueryCompiler = processor.newXQueryCompiler();
XQueryExecutable xQueryExecutable = xQueryCompiler.compile(
"declare variable $mydoc external; " +
"declare variable $mydoc2 external; " +
"<newdoc><doc1>{$mydoc/my/document/text()}</doc1>" +
"<doc2>{$mydoc2/my/document/text()}</doc2></newdoc>");
XQueryEvaluator xQueryEvaluator = xQueryExecutable.load();
QName name = new QName("mydoc");
xQueryEvaluator.setExternalVariable(name, document);
QName name2 = new QName("mydoc2");
xQueryEvaluator.setExternalVariable(name2, document2);
System.out.println(xQueryEvaluator.evaluate());
} [/sourcecode] This result is an output of: [sourcecode language="xml"] content content2 [/sourcecode]
This year, the 2021 edition of the traditional JBCNConf was held. Unfortunately, the 2020 event didn't take place the year prior due to difficulties..
We already spoke about the different type systems and how they work here, now it's time to write some code and see how type can help us.
Integration tests can be slow and unreliable because they depend on too many components in the system. Up to a certain point, this is unavoidable:..
Join our newsletter for expert tips and inspirational case studies
Join our newsletter for expert tips and inspirational case studies