Re: [xsl] Specify/determine element's "logical" parent

Subject: Re: [xsl] Specify/determine element's "logical" parent
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 23 Sep 2004 22:05:11 +0100
Hi John,

It would certainly be easiest to use the parentid attribute. To do
that, all you have to do is set up a key that indexes the <item> elements based on their id attribute:

This data structure could be very large; would this have a performance impact (hashing or whatever the entire document) or would it just hash or whatever the keys when it needs them? If so, is it possible (in ASP.NET) to share these keys in memory for the entire application, or will these be processed each time this XSL is invoked? Sorry if this does not makse sense; I am somewhat new to XSL and .NET and have never worked with XSL key.

In most (good) XSLT implementations, a hash table for the key will only be generated when/if the key() function is first invoked, and that hash table will be around for the remainder of the transformation. Using a key is usually faster than using an equivalent path (and much faster than trying to interpret an XPath using XSLT). The only thing you really have to worry about if you're using keys with a large document is how much memory the key's hash table will take up.


I don't know details of ASP.NET, but keys are bound to single transformations and as such they won't be cachable across invocations of a stylesheet. If you run into performance problems, you might have more luck from an XQuery implementation, since they're designed to work with databases in which permanent indexes are possible.

Cheers,

Jeni
--
Jeni Tennison
http://www.jenitennison.com

Current Thread