[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: variables and calling templates

Subject: Re: variables and calling templates
From: Goetz Bock <bock@xxxxxxxxxxx>
Date: Wed, 3 Oct 2001 01:34:41 +0200
the name goetz
On Tue, Oct 02 '01 at 18:06, Chris d'Aquin wrote:
> [ ... variables and named templates ... ]
AFAIK, your variable is only valid in the first template and you must
pass it as a parameter to the named template:


<xsl:template match="/">
  <xsl:for-each select="//*[@foo]">
    <xsl:variable name="element">
      <xsl:value-of select="name()" />
    </xsl:variable>
    <xsl:if test="@foo='bar'">
      <xsl:call-template="foobar">
        <xsl:with-parameter name="element">
          <xsl:value-of select="$element"/>
        </xsl:with-parameter>
      </xsl:call-template>  
    </xsl:if>
  </xsl:for-each>
</xsl:template>
 
<xsl:template name="foobar">
  <xsl:param name="element" /> 
[ ... various statements here that use the $element variable set above 
  ... ]
</xsl:template>

note, that your context position remains the same, you could access @foo
or name().

-- 
Goetz Bock                                              IT Consultant
Dipl.-Inf. Univ.

Attachment: pgp00009.pgp
Description: PGP signature

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.