This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: variables and calling templates
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] variables and calling templates
- From: Goetz Bock <bock at blacknet dot de>
- Date: Wed, 3 Oct 2001 01:34:41 +0200
- References: <OF1A79BB98.08370DD4-ON86256AD9.007E2DCC@questia.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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.
PGP signature