Re: [xsl] passing a sequence as a parameter

Subject: Re: [xsl] passing a sequence as a parameter
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Tue, 26 Feb 2008 16:21:51 +0000
On 26/02/2008, Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote:
> On Tue, Feb 26, 2008 at 8:47 PM, David Carlisle <davidc@xxxxxxxxx> wrote:
>  > It's actually very common that you want to pass (for example) a document
>  > node rather than a string, and I think it's reasonable to declare this
>  > using as= on the xsl:param declaration.
> Could you please demonstrate this with an example (i.e. passing a
>  document node as a parameter to the stylesheet).

Say you pass:


as a parameter to the stylesheet with a param definition of:

<xsl:param name="foo" as="document-node()"/>

If it's passed a string:


you'll get an error, but if its passed as a document node then it will be fine.

The problem is constructing the document in the host language and then
passing it in - I've always found it to be a pain and it does limit
how your transform can be run (not from the command line for example)
so instead I would always pass in strings and manage the process

<xsl:param name="foo-str" as="xs:string"/>
<xsl:variable name="foo" select="saxon:parse($foo-str)" as="document-node()"/>

Andrew Welch

Current Thread