xsl-list
[Top] [All Lists]

Re: [xsl] Saxon command-line: How to assign a sequence of multiple strings to a global param

2018-11-05 11:56:38
In recent releases you can do

"?MY_ARRAY=('one', 'two', 'three')"

but note that the exact rules for use of double-quotes around a string 
containing special characters depend on which command line processor (shell) 
you use.

I don't know if this syntax was available in 9.2, you will have to check. The 
question-mark signals that what follows the parameter name is an XPath 
expression rather than a simple string literal.

Note that the normal syntax name=value interprets value as xs:untypedAtomic, 
which is therefore cast to the required/declared type of the xsl:param. This 
will work for parameters declared as integer, boolean or string, but not for a 
sequence.

Michael Kay
Saxonica

On 5 Nov 2018, at 17:38, Jorge . chocolate(_dot_)camera(_at_)gmail(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Running Saxon from the command line (testing with Saxon-HE 9.2.1.2J—yes, old 
as heck—on Bash 3.2.57(1)), is there a way to set the value of a global 
parameter of an XSLT2 stylesheet to a sequence of strings?

    <xsl:param name="MY_ARRAY" as="xs:string*"/>

When attempting to do it like this:

    java  -jar saxon9he.jar [options] 'MY_ARRAY="one" "two" "three"'
    java  -jar saxon9he.jar [options] MY_ARRAY='"one" "two" "three"'

Saxon seemingly interprets spaces as literal, and the value of the parameter 
becomes one single string

    <xsl:message select="count($MY_ARRAY)"/>
→ 1

instead of interpreting them as separators so that the value of the parameter 
contains those three.
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by 
email <>)
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>