[Re-sending to the mailing list.]
Mon, 16 Sep 2024 11:34:38 +0000, /Jeff Thomas/:
I have a problem after switching from the external Xalan JAR to the
internal Xalan packaged with JRE 17.
I am trying to call a non-static java method on an object reference
passed as a parameter.
My XSLT looks like this (abbreviated).
<xsl:stylesheet ...
xmlns:mapping_engine="http://xml.apache.org/xalan/java/com.tsystems.pwc.commons.data.handler.MappingEngine"
...>
<!-- Parameter given from transforming method: Contains object of type
MappingEngine -->
<xsl:param name="Handler" .../>
[...]
As a workaround I have created a helper class which has static methods
which I am calling with the object as the first parameter and that is
working.
I just wanted to know if it should be possible with the non-static
function call.
The JDK-bundled XSLT processor is compiling-only (vs. interpretive),
thus it needs to know the parameter types at parse-time to link to the
necessary methods. Are you able to use the Xalan XSLTC processor [1]
with the same sources successfully?
In my previous experience there are two ways to specify
parameter/variable types [2]:
1. Constructor expression:
<xsl:variable name="Engine" select="mapping_engine:new(...)" />
<!-- $Engine type is known -->
<xsl:variable name="MappedClass"
select="mapping_engine:getMappedValue($Engine, name())"/>
2. Static method return type:
<!-- $Handler type unknown:
MappedEngine.cast(Object) : MappedEngine -->
<xsl:variable name="Engine"
select="mapping_engine:cast($Handler)" />
<!-- $Engine type is known -->
<xsl:variable name="MappedClass"
select="mapping_engine:getMappedValue($Engine, name())"/>
I don't know if it is possible to specify style sheet parameter type
hints for the purpose of Java extensions – I've once wondered this
myself, and I must admit I haven't tried the Xalan XSLTC, but just the
JDK one.
[1] https://xalan.apache.org/xalan-j/xsltc_usage.html#api
[2] https://xalan.apache.org/xalan-j/extensions_xsltc.html#java_ext
--
Stanimir