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: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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How can I use a variable , frank Stein | Thread | Re: [xsl] How can I use a variable , Michael Beddow |
[xsl] xsl, position, template Probl, Partho Paul | Date | Re: [xsl] How can I use a variable , Michael Beddow |
Month |