xsl-list
[Top] [All Lists]

RE: recursion with xsl:apply-templates

2003-08-27 07:39:32

   <xsl:template match="*[(_at_)index]">
     <xsl:copy>
       <xsl:copy-of select="@*[not(name()='index')]"/>
       <xsl:variable name="p" select="count(preceding::*[(_at_)index])+1"/>

This is fine if it does what you need, but you should be aware that
using the preceding::* axis in this way leads to O(n^2) performance.

It's much better practise to store the data you need in a nodeset, and
then query that.  This means you will do one pass for the nodeset, and
one pass for the data regardless of the number of elements in your
source.

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