|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How can I use a variable out of it scope ?
> 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:apply-templates>
<xsl:with-param name="my_var">
<xsl:for-each select="Level_2">
<xsl:value-of select="./@Name"/>
</xsl:for-each>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<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:for-each>
David
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








