I have long done with the default XML libraries provided by Java (Xerces2-J and Xalan-J) - sometimes directly using the latest versions of these libraries when necessary. It looks like I am facing some limitations of these libraries, especially with Xalan-J, which is no longer supported and has not been released for almost 6 years ...
I need to provide some custom functions to retrieve information from external services when called, so they must be implemented in Java. (i.e. I cannot implement them in XSLT itself, as XSLT or JavaScript functions, etc.). I did this before using Xalan-Java Extensions . However, provided this seems either permissive or nothing:
I need to be able to provide access to the Java extension, but without resolving any arbitrary calls to Java (for example, think of the built-in call to System.exit() ) and, ideally, without XSLT authors who even need to know that it is Java -function (for example, using xmlns:java="http://xml.apache.org/xalan/java" ). Ideally, I could also save TransformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); .
I can (almost) accomplish what I'm looking for using XPath.setXPathFunctionResolver , but this only works for direct XPath calls - and I have not found a way to set up custom XPath for use in XSLT Xalan. (It also requires that FEATURE_SECURE_PROCESSING should not be set to XPathFactory , although I could leave if it was set to TransformerFactory only - ignoring this if it is set to TransformerFactory, TransformerFactory also automatically sets the same flag in XPathFactory that it uses. )
So, I decided to try Saxon (Saxon-HE 9.5.1-1), and immediately noticed 2 questions:
When you just use XPath, XPath.setXPathFunctionResolver does not seem to affect Saxon. The set call completes without problems, but resolveFunction on the passed XPathFunctionResolver never called under Saxon. (It just โjust worksโ under Xalan.) Is there some additional configuration needed for Saxon โ or could it be a limitation of the HE version?
I looked at http://www.saxonica.com/documentation/#!extensibility/integratedfunctions/ext-simple-J - which for the author is provided even under the HE version. It also looks like what I need - however (as with XPathFunctionResolver under Xalan), I donโt see how to connect this to XSLT processing. (This is answered by the XALAN Extension Function, as in SAXON , in the question itself.)
source share