Project

Profile

Help

Bug #6569

open

XSLT functions not found when using S9API

Added by Gerben Abbink 3 days ago. Updated 3 days ago.

Status:
New
Priority:
Low
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2024-10-23
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

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?

Actions #1

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

Also available in: Atom PDF