[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] [XSLT] [Q] Recursion


Subject: RE: [xsl] [XSLT] [Q] Recursion
From: Jonathan Calvert <jonathan_calvert@xxxxxxxxx>
Date: Fri, 23 Mar 2001 06:23:20 -0800 (PST)

> Date: Thu, 22 Mar 2001 03:42:32 -0000
> From: "Michael Kay" <mhkay@xxxxxxxxxxxx>

> > 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.

Yes.  This group has a bunch of kind, generous folks. 
Thanks to every; I did not take up bandwidth by
personally responding to everyone, but your
suggestions are most appreciated!

> > 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) ...

Good point.  To be honest, my "timed" performance
exercise was not really fair because when I removed
the recursive call I also removed the multiple counts.
 Thanks for pointing that out.


> You could get a massive performance boost by
> calculating count(//RECORD) in a global variable.


Excellent suggestion, and one that I obviously had not
thought of myself.  I am still learning the "ins and
outs," and this is an idea that I should be able to
implement in future projects.

Thanks again for taking the time to reply.

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

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



Current Thread
Keywords