Re: [xsl] XSL sheet Optimisation

Subject: Re: [xsl] XSL sheet Optimisation
From: David_Marston@xxxxxxxxx
Date: Tue, 24 Apr 2001 11:10:04 -0400
Robert Koberg writes:
>Would it be better (faster) to create keys for all the sections and access
>the particular section with its key:
>  <xsl:apply-templates select="key('mykey', $id)"/>
>or would it be better to do something like:
>  <xsl:apply-templates select="//*[@id=$id]"/>
[The "id" attributes are not genuine IDs.]

I think the former approach ought to be way better. Have one keyspace for
all the sections if you don't care about their depth. Notice that since
the processor has no way of knowing whether "id" values repeat, the select
of "//*[@id=$id]" always has to scan the entire tree. That expression
could be improved, but I don't think it can get better than the key()

However, bear in mind that keys really begin to pay off when a given key
is used more than once. After a node is found the first time and an
entry is made in some internal table representing the keyspace, then
subsequent selects can go straight to the node(s) with that key.
.................David Marston

 XSL-List info and archive:

Current Thread