xsl-list
[Top] [All Lists]

Re: [xsl] passing a sequence as a parameter

2008-02-26 09:22:17
On 26/02/2008, Mukul Gandhi <gandhi(_dot_)mukul(_at_)gmail(_dot_)com> wrote:
On Tue, Feb 26, 2008 at 8:47 PM, David Carlisle 
<davidc(_at_)nag(_dot_)co(_dot_)uk> 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:

<foo>1</foo>

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

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

If it's passed a string:

"<foo>1</foo>"

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
myself:

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



-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--