Re: xxRe: [xsl] efficient use of key element and function

Subject: Re: xxRe: [xsl] efficient use of key element and function
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 7 Sep 2005 16:42:31 +0100
  <xsl:key name="find" match="name" use="text()"/>
  Is this the best (most efficient) solution?

If you only use the key a small fixed number of times, then it's
probably not worth using a key at all (it may be, you'd need to do
timings to check) the system has to traverse the entire tree to build
the key table and take memory and time to build the table. If you are
going to make lots of accesses to find different name elements (as in
repeatedly for each of thousands of input elements) then building the
key index is definitely worth it, but if it is just for a small number
fixed in the stylesheet then probably not.

especially in use such as

<xsl:value-of select="empty(key('find', 'prunauer_regina', $Index-alt))"/>

as here you are interested just if there is any such node, so you don't
need to traverse the whole tree at all you can stop as soon as you find
one, so I'd not use a key at all and just do


but it depends whether your real case really is like this or whether
it's just over simplified while generating a small example to post.


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

Current Thread