Once again about the distinct nodes (basing on attribute values) in node set. Imagine u have the following structure:
<struct>
<a>
<x id="1">a_1</x>
<x id="2">a_2</x>
<x id="3">a_3</x>
</a>
<b inherits="a">
<x id="2">b_2</x>
</b>
</struct>
<struct/>
may contain multiple elements like <b/>
which inherit the same <a/>
. At the same time multiple elements like <a/>
are allowed. Order of <a/>
s and <b/>
s is arbitrary. Inheritance is single-level deep.
Question: How to create a single XPath that selects the following nodeset for a given <b/>
:
<x id="1">a_1</x>
<x id="2">b_2</x>
<x id="3">a_3</x>
Please note the b_2
value on the second line.
Any solutions to this?
Update:
The resuting XPath should have the following form: b[(magic_xpath)[@id=2]='b_2']
, where magic_xpath
selects distinct <x/>
s from <a/>
s and <b/>
s.
The real life <struct/>
can look like this:
<struct>
<a>
<x id="1">a_1</x>
<x id="2">a_2</x>
<x id="3">a_3</x>
</a>
<b inherits="a">
<x id="2">I don't match resulting XPath</x>
</b>
<b inherits="a">
<x id="2">b_2</x>
</b>
</struct>