an XProc (XML Pipeline) Implementation (original) (raw)

yax is an Java implementation of the XProc Specification, an XML Pipeline Language (XProc: An XML Pipeline Language W3C Working Draft 17 November 2006). yax processes XProc Scripts like:

<xproc:pipeline name="pipe1" xmlns:xproc="http://www.w3.org/TR/2006/xproc/1.0" xmlns:yax="" title="undefined" rel="noopener noreferrer">http://opsdesign.eu/yax/1.0"> <xproc:step name="trans1" type="xproc:XSLT" yax:description="transforms 'a*' elements to 'b*' elmenents."> <xproc:input port="stylesheet" href="test/transformation1.xsl"/> <xproc:step name="trans2" type="xproc:XSLT" yax:description="transforms 'b*' elements to 'c*' elmenents."> <xproc:input port="stylesheet" href="test/transformation2.xsl"/> <xproc:parameter name="transformer" value="Saxon6" /> <xproc:step name="trans3" type="xproc:XSLT" yax:description="transforms 'c*' elements to 'd*' elmenents."> <xproc:input port="stylesheet" href="test/transformation3.xsl"/> <xproc:parameter name="transformer" value="XSLTC" />

yax preferred logging system is log4j. yax comes with a log4j configuration containing a console appender and a rolling file appender which writes a log file each day.

To simplify the beginning the recent Log4j library comes with yax. You can find the library in YAX_HOME/lib.

In the root of YAX_HOME you can find the two bat-files 'runExample1.console.bat' and 'runExample1.log4j.bat. The two batches demonstrates who to use and how to avoid using log4j. Wether yax uses log4j or not depends simply on the fact whether yax finds log4j on the classpath or not.

While yax runs in ant mode yax redirects all log messages to ant's logger and all other log configuraiton take no effect.

An XML catalog maps (usually remote) URIs to other (usually local) URIs.

yax uses Norman Walsh's resolver. You can configure the resolver - especially the link to your catalog file - by editing the config/CatalogManager.properties file. How to configure the the resolver is explained in an excellent manner on the resolver's site

For your confinience the yax distribution contains the recent resolver library (lib/resolver.jar). If you want to use the xml catalog feature the config directory and the resolver.jar have to be part of your the classpath. Start yax with the '-noCatalog' option If you want to suppress the xml catalog usage.

At the present time the property reference mechanism known from http://ant.apache.org/manual/index.html is implemented.

You can use parameter references with the form ${} within href attribute (or parameter). This reference will be replaced by the value of parameter with the same name passed either by property file or by start parameter ('-D').

With a combination of start parameter and parameter references within the xproc script you can build your scripts in a more flexible way. Example:

java -classpath lib/yax-0.7.jar

   net.sf.yax.Yax 
   -Dexample.dir=examples 
   -Dtest.dir=test 
   -DoutputFilename=output1.xml 
   example1.xproc
        

<xproc:pipeline name="pipe1" xmlns:xproc="http://www.w3.org/TR/2006/xproc/1.0" xmlns:yax="" title="undefined" rel="noopener noreferrer">http://opsdesign.eu/yax/1.0"> <xproc:step name="Load1" type="xproc:Load" href="${examples.dir}/${inputFilename}"/> <xproc:step name="Store1" type="xproc:Store" href="${test.dir}/${outputFilename}"/>

the usage of the yax ant task is designed with the XSLT task in mind. if you are familiar with the XSLT task you will find some similarities. For the determination of single input and output files the attributes_in_ and out are used. The attributes which holds the script file location is called in the XSLT task style. The corresponding attribute in yax is called script.

As the XSLT task do not provide multiple input (and output) yax provides an own solution using ant's well known fileset feature in collaboration with the outDir and/or outPattern attributes.

Corresponding to the XSLT task yax also provides passing parameters to the pipeline processor and the used subsystems (as transformers). While these parameters are not exclusively passed for the usage in transformers to yax the different name 'property' was used. But these 'properties' will also be passed as parameters to the transformers.

If you intend to use other xslt processors than the system defualt processor please consider that all necessary libraries must be assigned to the classpath BEFORE starting ant. Passing the transformer libraries via ant's classpath features (either within taskdef or with classpathref attribute) do not work.

... <target name="runExample1" description="transforms an input file with concatenated transformation steps"

...