Thursday, May 18, 2006

Java 1.5 update broke my xalan

Slightly against my better judgement, I allowed the mac to update Java from 1.4 to 1.5 the other day. Everything seemed OK at first. Then I tried using xalan for some XSL Transformations and they failed.

I'm a bit puzzled by this, as the copy of xalan I'm pointing to is from fop (0.20.4), which I have installed. I could understand that if I had been using the copy of xalan supplied with Java 1.4 and upgraded, its behaviour might have changed --- especially since xalan isn't supplied with Java 1.5. But it seems odd for the behaviour of xalan, sitting in a fixed jar file to change.

Anyway, what happened was that some XSLT code that I've used successfully with lots of different XSLT processors (xalan, xt, xsltproc etc.) suddenly barfed with the following error:


XSLT Error (javax.xml.transform.TransformerException):
Can not convert #RTREEFRAG to a NodeList!

After googling, it seems that the abandoned XSLT 1.1 and the new-ish XSLT 2.0 have both removed the XSLT 1.0 result tree fragments, which was the former type of parameters and variables.

In my case, the solution, rather oddly, was to convert this:


 <xsl:call-template name="showlink">
     <xsl:with-param name="link">
         <value-of select="."/>
     </xsl:with-param>
 </xsl:call-template>

to this:


 <xsl:call-template name="showlink">
     <xsl:with-param name="link" select="."/>
 </xsl:call-template>

Clearly, in this case, the working code is shorter, but I'm not looking forward to all the conversions. And I still don't understand why merely upgrading java has somehow changed fop's xalan to xslt-1.1 or xslt-2.0 or whatever.

0 Comments:

Post a Comment

<< Home