xsl-list
[Top] [All Lists]

Re: [xsl] initial template parameters

2010-03-19 04:48:50
On 18 March 2010 14:21, David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> 
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/

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>