Thursday 4 September 2014

Ant XSLT task for saxon transformations

As the Saxon AntTransform is no longer supported it is recommended to use the standard Ant XSLT task (see XSLT Task for documentation.

Example code is given below

<?xml version="1.0" encoding="UTF-8"?>
<project name="opsi" default="transformer" basedir=".">

 <property file="ant.properties"/>
 <property name="source.xml" location="share.xml"/>
 <property name="output.xml" location="output.xml"/>
 <!-- home directroy for Saxon  -->
 <property name="saxon.jar" location="saxon/saxon9.jar"/>

 <path id="saxon.classpath">
  <pathelement location="${saxon.jar}"/>
  <pathelement location="saxon/saxon9he.jar"/>
 </path>

 <target name="transformer">  
  <xslt in="${source.xml}"
      out="${output.xml}"
      style="share.xslt"
      processor="trax">
   <factory name="net.sf.saxon.TransformerFactoryImpl"/>
   <classpath refid="saxon.classpath" />
  </xslt>  
 </target>

</project>

No comments:

Post a Comment