Re: [xsl] How can I use a variable out of it scope ?

Subject: Re: [xsl] How can I use a variable out of it scope ?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 31 Jan 2001 10:54:41 GMT
> The following code puts on "my_var" the totality of the Name attributes of 
> each element "Level_1" :

Yes, slightly strangely, just concatenates them all together as a text
node, which is a very unusual thing to want to do.

> Now myvar contains "Name_1Name_2...Name_n..." as a string.
> And I want to use it on the Level_2 match:

If you really want to do that, you don't want a variable at all, you
want a parameter:

	<xsl:with-param name="my_var">
		<xsl:for-each select="Level_2">
			<xsl:value-of select="./@Name"/>


<xsl:template match="Level_2">
 <xsl:param name="my_var"/>
  .... $my_var...

However, you don't _need_ to use any kind of variable or parameter at
all if you don't want to. The entire source tree is available to every
template, so the information is there anyway, whether or not you copy it
into a vraiable.

You could just as well have gone

<xsl:template match="Level_2">
          <xsl:for-each select="../Level_2">
			<xsl:value-of select="./@Name"/>


 XSL-List info and archive:

Current Thread