Multi-stage XSLT in Ant

Inasmuch as Ant is good at re-running an XSLT transformation or a series of transformations when the XML source changes but not so good at re-running when one of the transformations’ stylesheets’ sub-modules changes, it’s a simple thing to generate on-the-fly a temporary build file containing paths listing the dependencies of each stylesheet so Ant can do the right thing. Continue reading

XML Calabash Ant task

Inasmuch as I’d been threatening since the XML Summer School last year to do it, I’ve made a custom Ant task for running XML Calabash, currently only in my fork at git@github.com:MenteaXML/xmlcalabash1.git.

You can use this task to process:

  • A single input file to produce a single output file
  • A set of input files, processed one at a time, to produce a set of output files
  • Multiple input files as the input to one XProc input port processed to produce a single output file
  • Any of the above with additional input ports to each of which are applied one or more input files whose file names may be either fixed or mapped from the name(s) of the current main input file(s)
  • Any of the above with additional output ports whose file names may be either fixed or mapped from the name(s) of the current main input file(s)
  • Any of the above with Ant defaulting to not running the pipeline when the outputs are already up-to-date compared to the inputs and the pipeline

You can also specify options and parameters to be used by the pipeline. Continue reading

Saxon feature keys for initial template and mode

Inasmuch as a “feature key” is how you configure a Java JAXP XSLT processor, it’s good to see that Saxon 9.3 has added feature keys for setting the initial template and initial mode. In fact, Saxon has gone from 30 feature keys in Saxon 9.0 to 70 in 9.2 and now 79 in 9.3.

Where this becomes useful (outside of your own Java programs) is being able to specify the initial template and/or mode in the <xslt> task in Ant build files. Continue reading

When Ant is subsidiary to <oXygen/>

The <oXygen/> documentation has an example of setting up an “External Tool” to run Ant. The example is simple enough to illustrate its point, but there’s more that can be done, especially if you write the Ant build file knowing that it will be run from <oXygen/>.

This example is from the <oXygen/> “project” that I used for organising the exercises for my “Testing XSLT” tutorial at XTech 2008. Continue reading

“Could not find a valid processor version implementation” with Ant junitreport task

Running some JUnit tests with Ant 1.6.5 gave this error when the <junitreport> task ran:

build.xml:160: The following error occurred while executing this line:
build.xml:367: Could not find a valid processor version implementation
from net.sf.saxon.TransformerFactoryImpl

I know of two possible solutions:

  • Upgrade to using Ant 1.7.0, or
  • Set ANT_OPTS thus:
    declare -x \\
    ANT_OPTS=-Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl