Page 1 of 1

Batch XSLT 2.0 transformations fail when using build file

Posted: Fri Nov 08, 2013 12:21 pm
by amadkins
Hi there,

I'm new to Oxygen and ANT build files and a friend of mine referred me to ANT build files to process batches of xml files with XSLT. When I run using only XSLT 1.0 functions, it is fine. When I add an XSLT 2.0 function (base-uri() - I need to grab the file name information for something), it then dies spectacularly when running it through the build file. When the XSL is run alone, it runs and generates what is wanted.

This is the message I receive when it fails to run:

Executing:
"c:\program files\oxygen xml developer 15\jre/bin/java" -Xmx256m -classpath "C:\Program Files\Oxygen XML Developer 15/tools/ant/lib/ant-launcher.jar" "-Dant.home=C:\Program Files\Oxygen XML Developer 15/tools/ant" org.apache.tools.ant.launch.Launcher -f "build.xml"

Buildfile: J:\AA_Test\SessionsCourts\test\build.xml

dist:
[xslt] Transforming into J:\AA_Test\SessionsCourts\test\output
[xslt] Processing J:\AA_Test\SessionsCourts\test\content\001FH004.xml to J:\AA_Test\SessionsCourts\test\output\001FH004.xml
[xslt] Loading stylesheet J:\AA_Test\SessionsCourts\test\sessions.xsl
[xslt] : Error! Error checking type of the expression 'funcall(base-uri, [])'.
[xslt] : Fatal Error! Could not compile stylesheet
[xslt] Failed to process null

BUILD FAILED
J:\AA_Test\SessionsCourts\test\build.xml:4: Fatal error during transformation

Total time: 21 seconds

The process finished with exit code: 1

This is the contents of my build file:

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="dist" name="ANTProject">
<target name="dist">
<xslt basedir="content/" destdir="output/" extension=".xml" excludes=".dtd" style="sessions.xsl"/>

</target>
</project>

To double check that the build file worked with only XSLT 1.0 functions, I commented out all references to the XSLT 2.0 items and it worked with no problems! As soon as I added them back in, failure!

Any suggestions would be more than welcome.

Re: Batch XSLT 2.0 transformations fail when using build fil

Posted: Fri Nov 08, 2013 1:16 pm
by adrian
Hi,

You're using the default XSLT processor from the Java runtime which has some issues and does not support XSLT 2.0. Note the ANT documentation:
http://ant.apache.org/manual/Tasks/style.html
If you are using JDK 1.4 or higher, this task does not require external libraries not supplied in the Apache Ant distribution. However, often the built in XSL engine is not as up to date as a fresh download, so an update is still highly recommended in particular since the built-in XSLT processors of Java 5 (and to a certain extent Java 6) are known to have serious issues.
You can find various instructions on the web on how to run XSLT 2.0 with ANT.
http://stackoverflow.com/questions/9196 ... 0-with-ant
Press the Libraries button from the the ANT transformation scenario configuration dialog in Oxygen and add the required XSLT processor libraries (e.g. Saxon 9).

Regards,
Adrian

Re: Batch XSLT 2.0 transformations fail when using build fil

Posted: Fri Nov 08, 2013 1:18 pm
by amadkins
Many thanks for that information. I'll have a hunt around for that and add.

Anne