Bug #6569
openXSLT functions not found when using S9API
0%
Description
I try to evaluate this XPath expression using S9API (XPathCompiler, XPathExecutable):
replace(system-property('java.io.tmpdir'),'x', 'y')
I get an error that system-property() is not found. This is strange, because the function actually exists as an XSL function.
Do I have to tell XPathCompiler or XPathExecutable that I want XSLT functions in addition to the XPath functions?
Updated by Michael Kay 3 days ago
The XPathCompiler sets up a static context for XPath expressions which by default includes the standard functions in the XPath 3.1 function library.
Some of the XSLT-specific functions such as key()
don't make sense outside a stylesheet. That isn't the case for system-property(), except perhaps for properties like xsl:supports-streaming
.
You should be able to add the standard XSLT library to the static context using something like
FunctionLibraryList libs = (FunctionLibraryList)XPathCompiler.getUnderlyingStaticContext().getFunctionLibrary();
libs.addFunctionLibrary(XSLT30FunctionSet.getInstance());
but some of the functions may fail unpredictably due to not having parts of the XSLT static context available.
Not tested, and use at your own risk.
What is supported is using fn:transform()
from XPath to execute an XSLT stylesheet, and of course the XSLT stylesheet can be a simple call on system-property().
Please register to edit this issue