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.
Examples
Single input, single output
<calabash in="in.xml" out="out1.xml" pipeline="pipeline.xpl"/>
What could be simpler?
Implicit fileset plus mapper on additional input port
<calabash includes="doc.xml" inport="source" destdir="out" extension=".compare.xml" pipeline="compare-001.xpl"> <input port="alternate"> <globmapper from="*.xml" to="*-alt.xml" /> </input> </calabash>
Fixed input, multiple mapped outputs
<calabash in="group-003_input1.xml" pipeline="group-003_pipeline.xpl"> <output port="result"> <globmapper from="*_input1.xml" to="out/*_result.xml" /> </output> <output port="result2"> <globmapper from="*_input1.xml" to="out/*_result2.xml" /> </output> </calabash>
QNames
<calabash in="in.xml" out="out.xml" pipeline="pipeline.xpl"> <namespace prefix="hi" uri="low" /> <parameter name="{hi}there" value="a value" /> <parameter name="hi:there" value="a value" /> </calabash>
{hi}there
is a QName in Clark notation, where hi
is the namespace URI and there
is the local name; whereas hi
in hi:there
is a namespace prefix that is bound to the low
namespace URI.