xsl-list
[Top] [All Lists]

Re: [xsl] improving performance in creating ids

2019-04-23 09:53:24

Thanks for your quick reply. the node identity comparison helped quite a bit, 
although I am still around a minute for a full book of ids. I am not sure how 
xsl:number would help here, and what kind of performance win it would give 
over count(). I tried something with a nested transformation, but what should 
I feed it?

    <xsl:number select="*[last()]"/>
works (given a set of preceding nodes) but it is slightly slower than a 
count() in the xquery. Maybe I should be using xsl:number differently?

Saxon attempts to optimise xsl:number for the case where you are numbering many 
nodes: it will try to detect cases where the result is going to be the same as 
the previous execution plus 1. In fact in recent releases it is rewritten to 
use an internal accumulator. Another way you can achieve a similar effect "by 
hand" is with a memo function: if the ID for a node is computed as the ID of 
the previous node plus 1, and the function that does that is a memo function, 
then numbering N nodes will have performance increasing linearly with N.

Michael Kay
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>