Subject: Re: [xsl] recursive call of template - how to find parents From: Michael Olszynski <m.olszynski@xxxxxxxxxxxxx> Date: Wed, 05 Nov 2003 14:38:05 +0100 |
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/
-- Michael Olszynski Dipl.-Ing.(FH) Software Engineer
___ |X__________________________________________________________ X|
eXXcellent solutions gmbh In der Wanne 55
e | m.olszynski@xxxxxxxxxxxxx t | +49 [0]731-55026-39 f | +49 [0]731-55026-99 i | www.exxcellent.de ________________________________________________________________
Geschäftsführer: Dr. Martina Maier, Wilhelm Zorn, Gerhard Gruber Sitz der Gesellschaft: Ulm, Registergericht: Ulm HRB 4309
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] recursive call of templat, Jeni Tennison | Thread | Re: [xsl] recursive call of templat, Jeni Tennison |
Re: [xsl] recursive call of templat, Jeni Tennison | Date | Re: [xsl] recursive call of templat, Jeni Tennison |
Month |