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

Subject: [xsl] Specify/determine element's "logical" parent
From: "john-xsl-list" <john-xsl-list@xxxxxxxx>
Date: Thu, 23 Sep 2004 12:34:43 -0400
I have an XML document that looks something like the following:

<items>
  <item id="A1">
    <item id="A2>
      <item id="A3" />
    </item>
  </item>
  <item id="B1">
    <item id="B2>
      <item id="B3" parentid="A1" parentpath="/items/item[id='A1']" />
    </item>
  </item>
</items>
  
I am hoping for a facility to easily retrieve the logical parent node for any
item.  Specifically, if an item has a parentpath defined, I would want the
node specified by that parentpath, otherwise I want the actual (XML) parent. 
Note that the parentpath/parentid may be stored in a child element/attribute
instead of an attribute of the item itself.  

Is this possible and/or a bad idea?  I read that XPath statements cannot be
dynamic, so I imagine I have to use parentid attributes rather than
parentpath, then somehow map the ID to an actual node; does that make sense? 
I also see the potential for infinite recursion; any suggestions on that topic
would be appreciated.

The long story, in case there are better suggestions: the XML contains the
entire information architecture and content of multiple websites.  In most
cases this XML matches site navigation, but for resources such as news
articles that are shared to multiple sites, the content is stored in the item
tree in a shared location (not in the normal navigation hierarchy).  I want to
be able to define these logical parents to facilitate navigation in this news
section.

Current Thread