I found this Using Xalan alongside Saxon but I don't get it to work.
I insert the dependecy for camel-saxon
in my pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-saxon</artifactId>
<version>2.14.0</version>
</dependency>
and get this Error:
java.util.ArrayList cannot be cast to org.w3c.dom.NodeList
in this Code:
public NodeList getXPathFromFile(String xpathStr, String xmlfile) {
NodeList nodes = null;
try {
System.setProperty(XPathFactory.DEFAULT_PROPERTY_NAME + ":"
+ XPathFactory.DEFAULT_OBJECT_MODEL_URI,
"org.apache.xpath.jaxp.XPathFactoryImpl");
XPathFactory jaxpFactory = XPathFactory.newInstance(XPathFactory.DEFAULT_OBJECT_MODEL_URI);
XPath xpath = jaxpFactory.newXPath(); /*XPathFactory.newInstance()*/
String expression = xpathStr;
InputSource inputSource = new InputSource(xmlfile);
nodes = (NodeList) xpath.compile(expression).evaluate(inputSource, XPathConstants.NODESET); <-- here come's the error
} catch (XPathExpressionException | XPathFactoryConfigurationException e) {
e.printStackTrace();
}
return nodes;
}
If I remove the dependency my code work well. But I need xslt 2.0 for my Camel Routes and don't want to change my code. What do I wrong?
Do I need to IMPORT something?