I have an XML document that looks something like the following:
<item id="A3" />
<item id="B3" parentid="A1" parentpath="/items/item[id='A1']" />
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