xsl-list
[Top] [All Lists]

Re: [xsl] improving performance in creating ids

2019-04-23 09:57:00
On 23.04.2019 16:28, Pieter Lamers pieter(_dot_)lamers(_at_)benjamins(_dot_)nl 
wrote:

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?


It is difficult for me to suggest that without knowing the XML input
structure and whether you want to generate that id based on a count or
numbering only for certain nodes or some particular element type. In
general if I wanted to delegate counting to xsl:number similar to your
function I would define a template in a mode for that e.g.

   <xsl:template match="*" mode="number">
      <xsl:number level="any" from="*[@id]"/>
   </xsl:template>

and then, where you need that number, you would use e.g.

   <xsl:apply-templates select="." mode="number"/>

Both the template or the or the select of the apply-templates can of
course be adapted to more particular needs.

As for being more efficient that using count, that then depends on the
implementation but I would think there is some optimization to be
expected in an XSLT processor for xsl:number.
--~----------------------------------------------------------------
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>