Re: [xsl] initial template parameters

Subject: Re: [xsl] initial template parameters
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Fri, 19 Mar 2010 09:48:32 +0000
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