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

Subject: Re: [xsl] Saxon command-line: How to assign a sequence of multiple strings to a global param
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 6 Nov 2018 10:56:13 -0000
Indeed, I often use this approach, especially in cases where the stylesheet is
designed to be called from the command line. But if you want to invoke a
stylesheet that wasn't designed with that in mind, it's still possible to set
any parameter using the ?name=expression notation.

Sometimes it's appropriate to provide multiple "top-level" overlay stylesheets
offering different APIs.

Michael Kay
Saxonica

> On 6 Nov 2018, at 10:33, Mukul Gandhi gandhi.mukul@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Mon, Nov 5, 2018 at 11:07 PM Jorge . chocolate.camera@xxxxxxxxx
<mailto:chocolate.camera@xxxxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx
<mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>> wrote:
> Running Saxon from the command line (testing with Saxon-HE 9.2.1.2Jbyes,
old as heckbon 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)"/>
> b 1
>
> instead of interpreting them as separators so that the value of the
parameter contains those three.
>
>  This could be done as follows, I think.
>
> Pass a parameter to stylesheet as follows,
> MY_ARRAY="one;two;three"
>
> (there's only one string parameter. but we use a delimiter between words. in
this example ; is a delimiter)
>
> In the stylesheet, we declare as follows
> <xsl:param name="MY_ARRAY" as="xs:string"/>
>
> Then we need to use fn:tokenize on MY_ARRAY.
>
> You may choose a convenient delimiter for your environment.
>
>
> --
> Regards,
> Mukul Gandhi
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by
email <>)

Current Thread