This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: How to define a global parameter and change its value
- From: Oleg Tkachenko <olegt at multiconn dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 13 Feb 2002 20:21:44 +0200
- Subject: Re: [xsl] How to define a global parameter and change its value
- Organization: Multiconn International
- References: <3C6A9A2C.8ACCACB6@transcanada.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Chi Lin wrote:
> I would like to use a value from one of my template to pass to a
> different template.
You can do it, sure.
>
> I tried to declare a global parameter and assign the value in the
> template, so I can use it in a different template.
Oh boy :) There isn't assignment operator in xslt.
> I can assign the value for the parameter in the template, but the
> following template can not pick the changed value.
It can do it, just declare parameter in the second template and pass
param's value from the first template.
<xsl:template match="chapter">
<xsl:apply-templates select="para">
<xsl:with-param name="myParam" select="2"/>
<xsl:apply-templates>
</xsl:tempalte>
<xsl:template match="para">
<xsl:param name="myParam" select="0"/>
...
</xsl:tempalte>
It still contains
> the original value that I have initialized.
If you pass param's value by applying templates that value may be lost
in bult-in templates, be aware abot it.
It seems to me that the
> "global parameter" does not really work, the local one is always
> "shadow" the global one.
That's right.
>
> Is there anyway that I can change the global parameter's value after it
> has been declared, and used in different templates?
No way.
--
Oleg Tkachenko
Multiconn International, Israel
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list