xsl-list
[Top] [All Lists]

Re: [xsl] Benefits of using xsl:key

2009-11-03 04:21:21
2009/11/3 Jesper Tverskov <jesper(_dot_)tverskov(_at_)gmail(_dot_)com>:
On Tue, Nov 3, 2009 at 9:03 AM, David Carlisle 
<davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
However a typical
muenchian grouping example can easily be orders of magnitude faster and
so measurable on really quite small documents as you are avoiding
an order  n^2 along the sibling axis looking for duplicates.

What about XSLT 2.0 then, where we use xsl:for-each-group?

A set of XSLT 2.0 test files demonstrating a dramatic difference would
really be much appreciated?

Create a large index file along the lines of:

<entry id="nnn1" value="vvv1"/>
<entry id="nnn2" value="vvv2"/>

then in another stylesheet do multiple lookups into that file:

$entry-doc//entry[(_at_)id eq $id]/@value

then use a key instead:

<xsl:key name="entry-by-id" match="entry" use="@id"/>

with

key('entry-by-id', $id, $entry-doc)/@value

Provided the processor doesn't optimize // (such as the paid-for
version of Saxon) then you should see a measurable difference between
the former and the latter.


-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--