Re: [xsl] dynamic variable name/implementation question

Subject: Re: [xsl] dynamic variable name/implementation question
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 26 Aug 2005 06:39:00 +1000
On 8/26/05, Nathan Young <natyoung@xxxxxxxxx> wrote:
> Hi.
>
> I agree that the nodeset solution offered below is the most flexible
> solution (you can pass one in or load one with the document() function).
> Parsers differ in the way they handle this; using LibXML with perl I use
> the document function but haven't figured out how to pass a DOM as a param.
>
> However, the way you describe passing things in using parameters
> constrains you to a fixed set of params defined in your stylesheet so you
> could go with a choose block in your template match.


Not at all. The passed nodeset may contain elements with arbitrary
names. you get access to whatever parameter you need with something
like this:

  $pEnvironment[name() = 'myparamName']

In case you don't want the parameter name ('myparamName') fixed in the
stylesheet, it itself may be passed as a parameter to the stylesheet.

One way to implement dynamically created variables (such as in a
simple calculator) is described here:
     http://www.mulberrytech.com/Extreme/Proceedings/html/2003/Novatchev01/EM
L2003Novatchev01.html#t3.6

Cheers,
Dimitre Novatchev

Current Thread