[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: recursion and looping

Subject: RE: recursion and looping
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Thu, 23 Mar 2000 18:11:13 -0000
recursion and looping
> Question: is the looping induced by the following stylesheet 
> casued by a failure to shift context node? If so how can one pass a param 
> value that cause a shift in context node? Or is this totally wrong-tree
barking?
> 
> <xsl:param name="nodeset" select="//w[@n=$listname]"/>
> <xsl:param name="nextset" select="//w[@n!=$listname]a"/>

The infinite looping is caused by the fact that on each call of the
template, you process one element, and then call the template to process all
the other elements. There will always be other elements, so this never
terminates. You need to process a diminishing set of elements on each call.
The usual way is to use.

> <xsl:param name="nodeset" select="(//w)[1]"/>
> <xsl:param name="nextset" select="(//w)[position() &gt; 1]a"/>

Incidentally, using //w repeatedly is probably inefficient: set a global
variable to //w before you start.

Mike Kay


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.