batch mode xslt

Batch Mode

1. XSL Processors in batch mode
2. Batch XSLT Processing
3. Access to a list of files

1.

XSL Processors in batch mode

Bob Lyons

 
> Does anyone know offhand if either XT or Xalan can run an entire
> subdirectory's XML files through a stylesheet from one command on the
> command line? What're the arguments to use?

XT can do this by invoking it as follows:

	xt source_dir stylesheet result_dir

XT will apply the stylesheet to each file in the source_dir
directory and put the output files in the result_dir
directory.

Note that XT will re-parse the stylesheet for each source
file in the source directory.

The stylesheet should not be in the source_dir. When XT
creates an output file, it will use the same file name as
the corresponding input file.

Let's say that your input XML documents are in the IN
directory, and your stylesheet (xlate.xsl) is in the current
directory, and you want the output files to be placed in the
OUT directory. Then you would execute the following command:

	xt in xlate.xsl out

I don't think that this XT feature is documented. I found
out about it by reading the source code of the
com.jclark.xsl.sax.Driver class (the 19991102 version of
XT).

2.

Batch XSLT Processing

Joshua Allen

Most all XSLT processors can be called command line in a batch. Below I include the command lines I use for various processors. I have also written a simple wrapper for MSXML3 that allows batching XSLT;

java -classpath c:\saxon\saxon.jar com.icl.saxon.StyleSheet -o tmpout.xml
tmpdata.xml tmpxform.xml

java -classpath c:\xalan\xalan.jar;c:\xalan\xerces.jar
org.apache.xalan.xslt.Process -in tmpdata.xml -xsl tmpxform.xml -out
tmpout.xml

java -classpath c:\xt\xt.jar;c:\xerces\xerces.jar
- -Dcom.jclark.xsl.sax.parser=org.apache.xerces.parsers.SAXParser
com.jclark.xsl.sax.Driver tmpdata.xml tmpxform.xml tmpout.xml

java -classpath c:\oraxml\lib\xmlparserv2.jar oracle.xml.parser.v2.oraxsl
tmpdata.xml tmpxform.xml tmpout.xml

URLs to download the above parsers, in order: Saxon Xalan XT Oracle

Note: You need to point to the actual location you have unzipped the .jar files. Also note that I explicitly include classpath, since I seem to have strange behavior if the processors all use the same global classpath. Finally note that most of the above allow mixing and matching SAX processors; this is just the config I use.

3.

Access to a list of files

Michael Kay


There are a list of files listed in XYZ.XML. Is there a way by which I
can process these files by XSLT by saxon. Basically I want a batch
processing.  I want to put files into server alongwith XYZ.xml and
need to pass one commandline to process all the XML.

XYZ.XML
<dir>
<xmlFile>input.xml</xmlFile>
<xmlFile>input_meta.xml</xmlFile>
<xmlFile>sample.xml</xmlFile>
<xmlFile>x.xml</xmlFile>
</dir>

With <dir> as your current node, do

<xsl:apply-templates select="document(xmlFile)" mode="m"/>

and it will cause each of these input documents to be processed.