This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
variables numbers and apply templates
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] variables numbers and apply templates
- From: Gerrit Kuilder <gkuilder at portalyx dot com>
- Date: Wed, 24 Oct 2001 19:10:50 +0200
- Organization: Portalyx BV
- References: <200110241617.MAA07095@biglist.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi All,
this has kept me busy for an hour or two, have found a solution but I would like to find out what I ran into.
I wrote a recursive template which I pass as a parameter, a number
<xsl:template match="sect1|sect2|sect3|sect4|sect5" mode="createtoc">
<xsl:param name = "TocLevel" />
<xsl:variable name="CurrLevel">toclevel<xsl:value-of select="$TocLevel></xsl:variable>
<xsl:variable name="NextElement" select="concat('sect',$TocLevel+1)"/>
<xsl:element name="{$CurrLevel}">
<xsl:if test="$NextElement">
<xsl:apply-templates select="*[name()=$NextElement]" mode="createtoc">
<xsl:with-param name = "TocLevel" select="$TocLevel+1"/>
</xsl:apply-templates>
</xsl:if>
</xsl:element>
Two things I cant'do
a) <xsl:if test="count($NextElement)>0">
b) <xsl:apply-templates select="$NextElement" mode="createtoc">
I have no idea why I get errors when I try the above
if $NextElement would have been only characters :'secttwo' I would have no problem doing the above.
if I declare the varaible as <xsl:variable name="NextElement" select="sect2"/> it is ok too
I could read out the values with value-of select='$NextElement'
I played around with both versions of declaring the variable to no avail.
Wondering minds need to know....
Regards
Gerrit
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list