RE: [xsl] recursion with xsl:apply-templates

Subject: RE: [xsl] recursion with xsl:apply-templates
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Wed, 27 Aug 2003 15:39:32 +0100
>    <xsl:template match="*[@index]">
>      <xsl:copy>
>        <xsl:copy-of select="@*[not(name()='index')]"/>
>        <xsl:variable name="p" select="count(preceding::*[@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


Current Thread