Re: [xsl] initial template parameters

Subject: Re: [xsl] initial template parameters
From: Max Toro <maxtoroq@xxxxxxxxx>
Date: Thu, 18 Mar 2010 10:13:20 -0400
Yes, if we can choose an entry point then why cannot we provide
parameters for it?
I think this restriction makes initial templates less useful, unless
we choose between a set of parameterless templates.

Using globals as defaults isn't really a solution, since that would
restrict the set of templates with parameters to choose from to one,
the one whose parameters are duplicated as global parameters.

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"/>

I suspect there isn't enough people concerned about this to get this
issue into the working group's todo list (sigh).
--
Max

2010/3/18 Michael Kay <mike@xxxxxxxxxxxx>:
>> "Parameters passed to the transformation by the client
>> application are matched against stylesheet parameters (see
>> 9.5 Global Variables and Parameters), not against the
>> template parameters declared within the initial template. All
>> template parameters within the initial template to be
>> executed will take their default values."
>>
>> Why? :-(
>
> Either because we were lazy, or because we wanted to keep things simple, or
> both. I think an interface in which you could supply both the values of
> stylesheet parameters and the values of parameters to the initial template
> might be confusing to many users. However, I can see why you want it:
> logically, the requirement makes sense.
>
> Regards,
>
> Michael Kay
> http://www.saxonica.com/
> http://twitter.com/michaelhkay

Current Thread