Ant, Eclipse and XSLT 2.0 Problem
From Aventine Solutions
[edit] The Problem
The problem (albeit a somewhat esoteric one) in a nutshell: if you try an XSLT transformation using an Ant task and are running your Ant build within Eclipse, you might run into mysterious errors that cause your transformations to fail.
[edit] The Short Answer
Out of the box, Eclipse does not support XSLT 2 with Ant builds. You must make an XSLT transformation library available to the Ant build runner in Eclipse.
Here, I'm setting the preferences in Eclipse 3.2 for the Global Entries of the Ant Runtime environment, using the Saxon8 library that comes with the Oxygen XML plug-in I already use:
You can of course, find and use another XSLT 2 implementation in the same place.
[edit] The Long Explanation
I discovered that with the default installations of Eclipse 3.2 and 3.3 (Europa), the ant tasks for doing |XSLT transformations will only work with version 1 stylesheets. If I have any syntax from XSLT 2 in my stylesheets, the ant build will fail.
I have, for instance, a simple XML schema, bookmarks.xsd for storing my bookmarks, then I use XSLT to output the data into formats which work for FireFox, Safari and Opera browsers.
A recent change I made was to provide a flag indicating that the bookmark item or folder should go on the Opera personal toolbar:
<xs:attribute use="optional" name="operaPanel" type="xs:boolean"/>...
... so my bookmark list entry in the sourcee XML file might look like:
<list heading="Cinema" operaPersonalBar="true">...
For the Opera XSLT bookmarks2opera.xsl, I wanted to allow Y, y, T, t, J or j all to be equal to true, so I wanted to do regular expression matching on the attribute value like this:
<xsl:if test="matches( @operaPersonalBar, '^[YyTtJj]' )">
ON PERSONALBAR=YES
</xsl:if>...
It turns out that matches is an XSLT 2 feature.
Now, if I manage all my bookmark data, the schema, the XSLT stylesheets and building the output with Eclipse and an Ant build, bookmarks-ant-build.xml, I get an error because out of the box, the Eclipse ant set-up works only for XSLT 1.
Having given you all that set-up, this is what the console looks like for this kind of error:



