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

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


Subject: Re: xxRe: [xsl] efficient use of key element and function
From: Manfred Staudinger <manfred.staudinger@xxxxxxxxx>
Date: Wed, 7 Sep 2005 18:09:27 +0200

In my real stylesheet I have 1500 names and
about the same number of uses for key(). The names represent files and
are used to avoid a file-not-found for doc(). They are retrieved by
means of collection() and
for each "not-found" a new file will be created.

I would like to thank you especially for your explanations
which helped me a lot!

Regards Manfred


On 9/7/05, David Carlisle <davidc@xxxxxxxxx> wrote:
>   <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
>
> select="empty(//name[.='prunauer_regina'])"
>
> 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.
>
> David
>
> ________________________________________________________________________
> 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:
> http://www.star.net.uk
> ________________________________________________________________________


Current Thread