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

RE: [XSLT] [Q] Recursion Question/Concern

Subject: RE: [XSLT] [Q] Recursion Question/Concern
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Thu, 22 Mar 2001 03:42:32 -0000
xslt count records
> I need to count and number "records" in an XML file.
> It would seem that recursion is the answer, but I am
> concerned about performance.

You have already had responses showing you how to do this without recursion.
>
> When using recursion I have noticed a 10:1 performance
> decrease over not using recursion.  I assume that user
> error is responsible.
>
> In my XSL document I do the following:
>
> <xsl:template name="NumberStuff">
>   <xsl:param name="Counter" />
>
>   <xsl:if test="count(//RECORD) + 1 > $Counter">
>
The performance problem is not because your stylesheet is recursive, it is
because each time this template is called it is calculating count(//RECORD),
the number of RECORD elements in the document, which is an expensive
operation. A good optimizer would avoid doing it repeatedly, but this is
more difficult than you might think, because it has to reckon with the
possibility of multiple source documents, which would cause count(//RECORD)
to give different answers on different occasions. You could get a massive
performance boost by calculating count(//RECORD) in a global variable.

Mike Kay
Software AG


 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.