Subject: Re: [xsl] recursive call of template - how to find parents From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Wed, 5 Nov 2003 13:12:41 +0000 |
Hi Michael, > It is that way, because I still used my old sitemap template, which > you recommended to replace with the sitemap template you wrote. So I > did replace also the sitemap template. And now, I get a stack > overflow error, when I try to generate the homepage. That usually indicates infinite recursion, but I can't see anything in the code I recommended that would give you infinite recursion. I tried: XML document: <homepage> <topic name="point1" filename="asdf"> <topic name="subpoint1" filename="asdf1"> <topic name="subsubpoint1" filename="asdf2"> <topic name="subsubsubpoint1" filename="asdf3" /> </topic> </topic> <topic name="subpoint2" filename="asdf4" /> </topic> <topic name="point2" filename="asdf5" /> <topic name="point3" filename="asdf6" /> <topic name="point4" filename="asdf7" /> </homepage> XSLT: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" /> <xsl:template match="/"> <xsl:call-template name="sitemap" /> </xsl:template> <xsl:template name="sitemap"> <ul> <xsl:apply-templates select="homepage/topic" /> </ul> </xsl:template> <xsl:template match="topic"> <li> <a> <xsl:attribute name="href"> <xsl:for-each select="ancestor-or-self::topic"> <xsl:value-of select="@filename" /> <xsl:if test="position() != last()">/</xsl:if> </xsl:for-each> </xsl:attribute> <xsl:value-of select="@name"/> </a> <xsl:if test="topic"> <ul> <xsl:apply-templates select="topic"/> </ul> </xsl:if> </li> </xsl:template> </xsl:stylesheet> and got, as the result: <ul> <li> <a href="asdf">point1</a> <ul> <li> <a href="asdf/asdf1">subpoint1</a> <ul> <li> <a href="asdf/asdf1/asdf2">subsubpoint1</a> <ul> <li> <a href="asdf/asdf1/asdf2/asdf3">subsubsubpoint1</a> </li> </ul> </li> </ul> </li> <li> <a href="asdf/asdf4">subpoint2</a> </li> </ul> </li> <li> <a href="asdf5">point2</a> </li> <li> <a href="asdf6">point3</a> </li> <li> <a href="asdf7">point4</a> </li> </ul> So I guess the problem is somewhere that you haven't shown us. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] recursive call of templat, Michael Olszynski | Thread | Re: [xsl] recursive call of templat, Michael Olszynski |
Re: [xsl] recursive call of templat, Michael Olszynski | Date | Re: [xsl] recursive call of templat, Michael Olszynski |
Month |