Re: [xsl] initial template parameters

Subject: Re: [xsl] initial template parameters
From: Max Toro <maxtoroq@xxxxxxxxx>
Date: Fri, 19 Mar 2010 10:34:21 -0400
Hopefully this won't be an issue on XSLT 2.1:
http://www.w3.org/Bugs/Public/show_bug.cgi?id=9277

--
Max

2010/3/19 Andrew Welch <andrew.j.welch@xxxxxxxxx>:
> On 18 March 2010 14:21, David Carlisle <davidc@xxxxxxxxx> wrote:
>> On 18/03/2010 14:13, Max Toro wrote:
>>>
>>> The only solution I can think of is using extension methods to pull
>>> the parameters from the environment, something like this:
>>>
>>> <xsl:param name="color" value="(ext:get-parameter('color'), 'red')[1]"
>>> as="xs:string"/>
>>
>> more portable you can have a simple stylesheet with just a named template
>> that initialises its parameters from global parameters and then
xsl:imports
>> the original stylesheet. this means you need a wrapper stylesheet for any
>> top level named template that you want to use, but most stylesheets don't
>> have _so_ many choices for initial named template.
>
> Yes, or a hack that uses a single global parameter to pass in a string
> containing the list of params that gets tokenised to extract the
> different values for each entry point, eg:
>
> <xsl:param name="str" select="'foo=bar;baz=bop;'"/>
>
> <xsl:template name="entrypoint1">
>  <xsl:param name="foo" select="f:getParam('foo')"/>
>
> <xsl:template name="entrypoint2">
>  <xsl:param name="baz" select="f:getParam('baz')"/>
>
> etc.
>
> So for -it=entrypoint1 you can pass in $str = 'foo=bar', and for
> -it=entrypoint2 you pass in $str = 'baz=bop'
>
>
> --
> Andrew Welch
> http://andrewjwelch.com
> Kernow: http://kernowforsaxon.sf.net/

Current Thread