[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 ?

Subject: Re: How can I use a variable out of it scope ?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 31 Jan 2001 10:54:41 GMT
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.