I am working with an open source version of the Saxon XSLT processor “Saxon 9.0.0.2J from Saxonica” and am trying to make use of the java extensibility for the first time. I am running
into an issue I suspect may be a limitation on the open source version, but wanted to check first whether there might be something I am just missing here.
From the snippet below, my result is that the final value of $c1 does not change as a result of the call to greg:setTime() – i.e. the $c1 variable within Saxon appears to be unhooked from the underlying Java object and there is no apparent way to access the object as updated by the setTime() call.
NOTE that all code in the snippet is tested and working otherwise – i.e. $c1 is properly instantiated by the getInstance() call, $startdate is of the proper format and $d1 is properly instantiated.
Thoughts?
<xsl:transform
.....
xmlns:sql="java:java.sql.Date"
xmlns:greg="java:java.util.GregorianCalendar"
.....
>
....
<xsl:element name="JobExpireDate">
<xsl:variable name="c1" select="greg:getInstance()" />
<xsl:variable name="d1" select="sql:valueOf($startdate)" />
<xsl:variable name="void" select="greg:setTime($c1,$d1)" />
<xsl:value-of select="$c1" />
</xsl:element>
I just tried with saxonb9-0-0-8j.
Calls to void functions are sometimes ignored, as demonstrated by the following.
The input file:
The transform:
The result:
So it seems that
setTime()is not called for date1, but for date2.Saxon has a nice
explainfeature that displayes the parsed transformation in a readable format:As you see, for date1, the call to
setTime()is ignored, but is there for date2.