Re: [xsl] How do I properly define a unix saxon script command line

Subject: Re: [xsl] How do I properly define a unix saxon script command line
From: "Wolfgang Laun wolfgang.laun@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 12 Nov 2014 11:00:55 -0000
What I use for invoking Saxon is similar to this:

#! /bin/sh

# Make sure we have at least one parameter: the XML input document
# Additional arguments will be passed to Saxon.
case $# in
0) echo "no pathname for xml input file"
    exit;;
esac
xml=$1
shift

# Set JAVA_HOME (to make it stand out) and define path to java.
JAVA_HOME=/extra/JDK8u20/jdk1.8.0_20
java=$JAVA_HOME/bin/java

# Set Saxon jar (to make it stand out)
SAXON_JAR=/extra/saxon/saxon9he.jar

# Set stylesheet pathname (to make it stand out)
XML2CSV_XSL=/home/cwilbur/stylesheets/xml2csv.xsl

# Call transformation using the shell variables set before
# and pass additional parameters.
$java -cp $SAXON_JAR net.sf.saxon.Transform \
   -xsl:$XML2CSV_XSL -s:$xml "$@"
# end of script

You store this on a file  /home/cwilbur/bin/xml2csv
Make sure to
   $ chmod ugo+x /home/cwilbur/bin/xml2csv
and then you (and everybody else on this system) can invoke this using

   ~cwilbur/bin/xml2csv todays.xml

The variables commented "to make it stand out" need to be adapted to your
system. Also, I'm using cwilbur as your user name, which is just a guess.
Finally, your ~cwilbur/bin may not be the best place for a shell script to
be used by everybody on this system,

HTH
Wolfgang








On 11 November 2014 22:47, Catherine Wilbur cwilbur@xxxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Want to write a command line to call Saxon processor from a unix script
> line. Am using Saxon-HE from Unix command line to convert my XML file into
> a CSV file so it can be uploaded into a DB Table. We are using the DB table
> as input into our AP interface in ERP E1. Had to switch to Saxon processor
> because xsltproc does not work with xsl 2.0.
>
> In the command line call I need to specify two classpaths  (Classpath for
> JAVA, Classpath for SAXON jar files)
>
> How would I call the saxon processor in a unix script and pass it the
> following information
> JavaClassPath, SaxonJarClassPath, InputFile, StylesheetFile, OutputFile
>
> So far this is the unix command line I came across on the web.  Read thru
> page 853-854 of XSLT 2.0 3rd Edition Programmer's Reference and it does not
> quite give me what I am looking for.  Where would I find all the Saxon
> command line options
> Want to do saxon conversion of XML file within a unix shell script.  We
> have Java on Unix box.  Loaded Saxon jar files in a different directory on
> unix box.  Loaded stylesheet on unix box.  Loaded InputFile on unix box.
>
> *saxon -r saxonjarclasspath/saxon.jar -m javaclasspath -s:Input_File
> -xsl:Stylesheet_File  -o Output_File*
>
> _____________________________________________________________________
> Catherine Wilbur  |  Senior Application Programmer  |  IT Services
> 401 Sunset Avenue, Windsor ON Canada  N9B 3P4
> (T) 519.253.3000 Ext. 2745  |  (F) 519.973.7083  |  (E)
> cwilbur@xxxxxxxxxxx
> www.uwindsor.ca/its
>  XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <-list/528976> (by
> email <>)

Current Thread