Abbey Workshop

Ant: Using Saxon and XSLT 2.0 with Ant

Well I have been wondering for some time how to make Saxon your Ant XSLT processor instead of Xalan. Recently, troubleshooting an issue allowed me some deeper exploration. It turns out that making Saxon your XSLT processor is pretty easy. Basically all you need is a test XSLT 2.0 file to verify that your are using Saxon and a minor tweak to the xslt task in Ant.

First, take a look at the sample xslt 2.0 code.

xslt2-test.xsl

Download source for: xslt2-test.xsl

This small snippet of XSLT 2.0 code calls the XPath 2.0 currentdate() function. If an XSLT 2.0 processor is called, you get an output XML document with the current date in it. If an XSLT 1.0 processor like Xalan is called, the processor chokes and you get an error message like this.

Buildfile: build.xml

xslt2:
     [xslt] Processing /home/howto/xslt/ant-saxon/test.xml to
	 /home/howto/xslt/ant-saxon/xslt2-test.xml
     [xslt] Loading stylesheet
	 /home/howto/xslt/ant-saxon/xslt2-test.xsl
     [xslt] : Error! Error checking type of the expression
	 'funcall(current-date, [])'.
     [xslt] : Fatal Error! Could not compile stylesheet
     [xslt] Failed to process /home/howto/xslt/ant-saxon/test.xml

BUILD FAILED
/home/howto/xslt/ant-saxon/build.xml:5: Fatal error during
transformation

Total time: 1 second
		

Since there is no currentdate() XPath function in an XSLT 1.0 processor, it is a pretty easy way to check.

Now for the Ant code. Here is the modified build file to make Ant use Saxon.

build.xml

Download source for: build.xml

You mean you only have to put the path to the saxon8.jar file in the classpath? That's it?

That's it boys and girls, that is all it takes. That small change should allow to easily plug-in Saxon into your Ant XSLT build scripts. Have fun.

For more information, see the following books

Google
  Web abbeyworkshop.com   

Copyright © Abbey Workshop 2006

Music Only Search
The Black MP3 Album
The MP3 Album Lyrics
Wprld Music Plus
Mp3 Songs Blog
Music Search Store
First Music Search
Mega MP3 Blog
E MP3 BLog
My MP3 Diary
Fast MP3 Finder
My Blog MP3
Mp3 Songs Mart
My MP3 Songs Album
Top Music Group
Mp3 Tune Records
Song Album Guide
Music DataDite
MP3 Buying Guide
Top MP3 Downloads
MP3 Tune Festival
FAST MP3 Downloads
MP3 Mart Online
Upper MP3
Premium MP3 Site
Music Data online
Fine MP3 Audio
Cheap Music Albums
Fine mp3 downloads
World MP3 Music Records
Mp3 Music Data Direct
The Fine Mp3
MP3 Files World
Home Music Store
DatMP3
Fat MP3 Audio
MP3 ZigZag
MP3 Songs Direct
MP3 Tune World
E MP3 Log
Boom MP3 Music
Speedy MP3
Top 20 MP3 music
Deep MP3 World
Deep MP3 Download
Best-20 MP3
Top Twenty MP3
Deep MP3
Big MP3 Guide
Deep MP3 Audio
Mp3 R.O.B.
MP3-Pop Online
Greate-20-MP3
MP3 Appear
3T-MP3