I need to fetch a node set containing elements that refer to exactly two other elements. I can't figure out how to do it in a single XPath expression.
My (simplified) source XML looks like this:
<group>
<id>1337</id>
</group>
<group>
<id>1338</id>
</group>
<member>
<id>31415</id>
<groupId>1337</groupId>
</member>
<member>
<id>31416</id>
<groupId>1337</groupId>
</member>
<member>
<id>31417</id
<groupId>1338</groupId>
</member>
Now, I want to select all <group>
nodes that refer to exactly two <member>
s, which should result in returning the group with id=1337 only. I tried the following...
<xsl:variable name="groupsWithTwoMembers" select="group[count(../member[id=??]) = 2]"/>
...and obviously at the '??' I need to insert the groupId of the group I selected at the start of the XPath expression, but I can't think of a way to get to this groupId. Can anyone out there think of one? Thanks!