Calling Saxon from Ant
From saxon
Calling Saxon from Ant
Using the <xslt> task
I checked the ant <xslt> doc again, found the description of <factory> and tried it. The weird thing is that having specified the saxon8.jar in the classpath attribute of <xslt> and the net.sf.saxon.TransformerFactoryImpl in the <factory> element, the <xslt> task failed to find the factory class. I had to add saxon8.jar to the classpath of my invocation of ant, and then everything worked beautifully.
I think ant's implementation for the <xslt> classpath attribute has got to be something really weird, because it certainly doesn't behave in any way that makes sense to me.
So here's the answer for anyone who wants to mix XSLT 1.0 and XSLT 2.0 invocations in the same ant script:
Make sure that the classpath passed into Ant has the necessary jars for both XSLT 1.0(either Xalan with Xerces or Saxon 6) and XSLT 2.0(Saxon 8). Then don't bother with the [b]classpath[/b] attribute of <xslt>. Instead use something like the following:
<!-- invokes Xalan to process XSLT 1.0 -->
<xslt
style="myXSLT_1_Transform.xslt"
basedir="${source.dir}"
destdir="${dest.dir}">
</xslt>
<!-- invokes Saxon 6 to process XSLT 1.0 -->
<xslt
style="myXSLT_1_Transform.xslt"
basedir="${source.dir}"
destdir="${dest.dir}">
<factory name="com.icl.saxon.TransformerFactoryImpl"/>
</xslt>
<!-- invokes Saxon 8 to process XSLT 2.0 -->
<xslt
style="myXSLT_2_Transform.xslt"
basedir="${source.dir}"
destdir="${dest.dir}">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
Using the <saxon-xslt> task
This feature which is new in Saxon 8.9 unfortunately requires Saxon-SA to be on the classpath even if you aren't using schema-aware transformations.
