xsl-list
[Top] [All Lists]

Re: [xsl] Relationships in for-each statement

2006-09-07 16:47:46

. How would I implement keys to clean up and speed up this expression?

the expression is of the form //something[path/to/@attribute=expression]
which is exactly (more or less:-) the meaning of
key('k',expression)
if you first go
<xsl:key name="k" match="something" use="path/to/@attribute"/>

using a key gives a strong hint to the system that you're going to be
looking these things up a lot and it should do it once, stick them in a
hash table of some sort and then return the results quickly when asked.
Of course if you only do the lookup once it can be slower to use the key
as it has to do the search once to build the index, and allocate space
for the index etc. Conversely if you use the same // expression more
than once your xslt engine may get smart and index the thing anyway so
explictly using a key doesn't help much, so it's hard to say exactly but
on balance it's usualy  better to use a key and anyway makes the code
look neater and more understandable.

David

--~------------------------------------------------------------------
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>
--~--