[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: initial template parameters

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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.