xsl-list
[Top] [All Lists]

Re: Specify/determine element's "logical" parent

2004-09-23 12:47:10
On Thu, 23 Sep 2004 20:29:59 +0100, Jeni Tennison wrote

Hi, thanks for your response (I was beginning to think it was not possible).

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.

I'm not sure where the infinite recursion might occur, unless you 
want to get the parent of the parent once you find it?

Any item could have a parentid defined as any other itme.  I think this could
result in infinite recursion when I try to generate left nav.  This condition
seems illogical but could be possible if I don't take steps to avoid it.  For
instance:

<items>
  <item id="A1" parentid="B2">
    <item id="A2" />
  </item>
  <item id="B1">
    <item id="B2" parentid="A2" />
  </item>
</items>

Trying to find B2's top-level parent would result in infinite recursion.