This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to define a global parameter and change its value


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]