This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]