Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 16th, 2005, 01:23 PM
Registered User
 
Join Date: Aug 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Recursion

hey
How can I do this recursively to an infinite depth:
Code:
 
<xsl:for-each select="li">
<dt><a href="{@href}"><xsl:value-of select="@name"/></a></dt>
<xsl:if test="count(*) &gt; 0">
<dd id="smenu1">[list]
<xsl:for-each select="li">
<li><a href="{@href}"><xsl:value-of select="@name"/></a></li>  </xsl:for-each>
</ul>
</dd>
</xsl:if>
</xsl:for-each>
cheers


 
Old August 16th, 2005, 04:26 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Not really sure what you're trying to achieve here, but start by doing it using template rules rather than xsl:for-each. Something like:

<xsl:template match="li">
<dt><a href="{@href}"><xsl:value-of select="@name"/></a></dt>
<xsl:if test="*">
 <dd id="smenu1">[list]
   <xsl:apply-templates select="li"/>
 </ul></dd>
</xsl:if>
</xsl:template>


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
xslt recursion (need help ) newbiexslt XSLT 4 March 26th, 2007 10:59 AM
recursion in XSL jekkos XSLT 8 January 2nd, 2007 06:16 PM
recursion yui0329 C# 6 April 28th, 2005 09:36 AM
Recursion shan9 JSP Basics 0 November 17th, 2004 09:29 PM
recursion nulogix PHP How-To 1 June 28th, 2004 03:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.