Differences between revisions 8 and 9
Revision 8 as of 2006-10-04 22:32:50
Size: 3232
Editor: antoine
Revision 9 as of 2009-09-20 22:07:53
Size: 3234
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
You can find them at the [http://saxon.sourceforge.net/ SourceForge Saxon Web Page] You can find them at the [[http://saxon.sourceforge.net/|SourceForge Saxon Web Page]]

Using Ant With XSLT 2.0 and Saxon

You will first have to download the Saxon libraries. You can find them at the SourceForge Saxon Web Page I put the files in my C:/Apps/saxon8 folder

I then add the following to a properties file:

-- content of my.properties file --

# used to make sure Saxon gets the right XSLT 2.0 processor

-- end of my.properties file --

Here is an excerpt from my build file

-- contents of build.xml --

<!-- load the local properties file -->
<property file="my.properties"/>

<!-- a sample task that demonstrates the use of Saxon 8 -->
<target name="XSL using Saxon"
        description="Demonstration of XSL using Saxon">
      processor="${processor}" >

The following is an handy transform for printing the XSLT 2.0 and system related variables -- MyTransform.xsl --

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
   <xsl:output method="html"/>
      <xsl:template match="/">
               <title>Print XSLT Related Environment Variables</title>
                   <li><b>Version: </b><xsl:value-of select="system-property('xsl:version')"/>
                   <li><b>Vendor: </b><xsl:value-of select="system-property('xsl:vendor')"/>
                   <li><b>Vendor URL: </b><xsl:value-of select="system-property('xsl:vendor-url')"/>
                   <li><b>Java Version: </b><xsl:value-of select="system-property('java.version')"/>
                   <li><b>OS Name: </b><xsl:value-of select="system-property('os.name')"/>
                   <li><b>File Seperator: </b><xsl:value-of select="system-property('file.separator')"/>

This should display something like the following:

-- output of MyOutput.htm --

  • Version: 2.0
  • Vendor: SAXON 8.4 from Saxonica
  • Vendor URL: http://www.saxonica.com/

  • Java Version: 1.5.0_02
  • OS Name: Windows XP
  • File Seperator: \

To use this just create an empty XML input file with a valid root: -- MyInput.xml --

<?xml version="1.0" encoding="UTF-8"?>

Or once you have downloaded saxon8.jar, simply call Ant with -lib path/to/saxon8.jar on the command line, and use <xslt> as usual. Since Saxon implements the TraX API, and is now first on Ant's classpath, <xslt> will automatically pick it up. Wrap the appropriate -lib option in a custom startup script, or use an ANT_OPTS EnvironmentVariable to avoid having to type it all the time. --DD

UsingAntWithXSLT20AndSaxon (last edited 2009-09-20 22:07:53 by localhost)