Dear XSLT List,
I have a set of <node> elements with @n identifier attributes, which are
unique in the document. The <node> elements nest within one another to
describe a tree. Given a list of some of those @n identifiers (in the
token list attribute value of another element elsewhere in the
document), which point to a set of <node> elements, I need to find the
common ancestors of all <node> elements referenced in that list.
Assuming the list of identifiers is in the @wit attribute of some <app>
element, I think I can state my problem as: Find all <node> elements
that are the shared ancestors of all <node> elements whose @n attribute
value is one of the values in the @wit token list. I tried, without
success, several variants of:
<xsl:foreach select="//app">
<xsl:value-of select="//node[@n=tokenize(@wit, ' ')]/ancestor::node"/>
</xsl:foreach
This doesn't work, apparently because it looks for <node> elements whose
@n value is the entire tokenized list, instead of any member of the
list. That is, it seems to work when @wit is a one-item list, but it
returns empty if there is more than one item specified in @wit.
Furthermore, even if it did work, I fear that it might get the union of
ancestors of *any* of the nodes in question, while I need the much more
restricted intersection of common ancestors shared by *all* the nodes.
Have I conceptualized the problem incorrectly? Is there an obvious XPath
function that would help me out that I'm overlooking? I'm using XSLT 2.0
and XPath 2.0.
Thanks,
David
djbpitt@xxxxxxxx