Page 1 of 1

Ant + Saxon9b + multiple files

Posted: Fri Jan 18, 2008 10:37 pm
by kleb
Oxygen supports applying a XSL transform to a directory of files, but in doing so, it invokes a separate instance of the transform engine for each file, adding a large amount of overhead.

In contacting Oxygen tech support about this, I was recommended to use Ant as a solution. I am posting the results here in the hope that it will be helpful to someone in the same situation (make changes to xsl, run on all files and check output to see if output is as expected).

First, Ant needs to be installed: http://ant.apache.org/manual/install.html#getting

Then an Ant build file needs to be created in the project directory. This is the one I used.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<project default="cleanup">
<target name="cleanup">
<xslt
basedir="${sourcefiles}"
destdir="${destdir}"
extension="htm"
includes="*.htm"
style="${stylesheet}"
classpath="${oxy_dir}\lib\saxon9.jar"
></xslt>
</target>
</project>
Note: the extension attribute specifies the output file extension.

Then, create a custom External Tool in Oxygen: Tools > External Tools > Preferences > New
Insert this text into the command line field:

ant.bat -f ${pd}\<name-of-ant-buildfile> -Dsourcefiles=${cfd} -Ddestdir="<destination-directory>" -Dstylesheet=${pd}\<stylesheet-to-use>.xsl -Doxy_dir=${oxygenInstallDir}

To do a batch transformation, open a file in the source directory and execute the custom External Tool command that you created.

Speed difference for transforming 278 files with Saxon 9B:
Oxygen batch transform: 1 minute 30 seconds
Ant: 4 seconds

And Oxygen has autocomplete for Ant files. Just make a new xml file with <project> as the root element.

-Caleb

files existing

Posted: Fri Jan 18, 2008 10:52 pm
by kleb
I just noticed that if the transformed files already exist, the Ant file will not overwrite them. You could add a force="yes" attribute to the <xslt> element to override this behavior.

-Caleb

Posted: Sat Jan 19, 2008 12:34 am
by kleb
Note: the extension attribute of <xslt> should be ".htm" not "htm"