xsl-list
[Top] [All Lists]

RE: tail-recursion

2003-08-28 08:19:36
Your template parseRows is intrinsically tail-recursive - basically
this
means that after calling itself, it does nothing else before
returning.

Isn't the template head-recursive... it does all of the xsl:value-of 's
as it unwinds from the stack.

I thought if it was tail recursive it would do the value-of first, then
call itself.  




<xsl:template name="parseRows">
    <xsl:param name="catContents"/>
    <xsl:param name="font-size" select="'-1'"/>
    <xsl:choose>
            <xsl:when test="contains($catContents,'~!~')">
                    <xsl:call-template name="parseRow">
                            <xsl:with-param name="rowContents"
select="substring-before($catContents,'~!~')"/>
                            <xsl:with-param
name="font-size" select="$font-size"/>
                    </xsl:call-template>
                    <xsl:call-template name="parseRows">
                            <xsl:with-param name="catContents"
select="substring-after($catContents,'~!~')"/>
                            <xsl:with-param
name="font-size" select="$font-size"/>
                    </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                    <xsl:value-of select="$catContents"/>
            </xsl:otherwise>
    </xsl:choose>
</xsl:template>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>