This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: passing parameters with spaces to saxon


This has definitely been my week for posting dumb
questions on XSL-List. 

I hope I didn't waste anybody's time.

Here was the offence:

Warren Hedley wrote:
> 
> Can anyone tell me how to pass parameters with spaces in the value
> to saxon via the command line. I'm using a Unix system, though that
> probably shouldn't matter.
> 
> I've tried things like
> 
> java com.icl.saxon.StyleSheet file.xml file.xsl \
>   "HAS_SPACES=has spaces" \
>   HAS_SPACES='has spaces' \
>   HAS_SPACES=has\ spaces

Actually all of the above work. What I didn't mention was that I use
a shell script to set up the CLASSPATH to the saxon jar and properties
file and print the "java com.icl.saxon.StyleSheet" string. It then
echos the arguments it received. Unfortunately the quotes or escaped
spaces are not received (that's the whole idea) in the script, so the
actual Stylesheet.main() method gets a whole lot of one word arguments.

I've figured out how to wrap each of the arguments in quotes again, but
not quite how to send them on to the java executable.

If there are any "sh" experts around, what am I doing wrong? I should be
able to figure this one out on Monday, when our own "sh" experts get back
to work.

Here was my attempt.

----
#!/bin/sh
#
# This script sets up the environment variables to run the SAXON
# XSL processor on the arguments received. The offical usage is
#
# xslTransform [-u] [-t] [-o output-file] source-document style-sheet [ params...]
#
# The standard usage will look something like
#
# xslTransform file.xml file.xsl [ > output.html]
#
# Note that SAXON conforms to the XSLT 1.0 spec (November 1999), and requires
# the XSL namespace to be "http://www.w3.org/1999/XSL/Transform".

LIB_BASE=/usr/local/xml-utils
SAXON_JARS=$LIB_BASE/saxon:$LIB_BASE/saxon/saxon.jar
XML4J_JARS=$LIB_BASE/xml4j_2_0_15/xml4j.jar

CLASSPATH=$SAXON_JARS:$XML4J_JARS
export CLASSPATH

for arg ; do
  args="$args '$arg'" ;
done

# this doesn't work (same as using $* or $@)
exec java "com.icl.saxon.StyleSheet" $args

# this passes the entire $args string as a single argument
exec java "com.icl.saxon.StyleSheet" "$args"

----

-- 
Warren Hedley


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]