[xsl] Select a node only if its previous siblings have specific attributes

Subject: [xsl] Select a node only if its previous siblings have specific attributes
From: Philipp Kursawe <phil.kursawe@xxxxxxxxx>
Date: Fri, 15 Apr 2011 19:40:14 +0200
Hello,

a node with @result='9' should be select if one of its previous
siblings has @result=10 or @result=11. Only the most recent node with
@result=9 should be selected.

given the following examples:

<root>
<data result="11"/>
<data result="10"/>
<data result="9"/>
</root>
Should select data[3]

<root>
<data result="11"/>
<data result="5"/>
<data result="9"/>
</root>
Should not select any node, because one of data[3] prev siblings has
@result != 10|11

<root>
<data result="11"/>
<data result="9"/>
<data result="5"/>
<data result="9"/>
</root>
Should select data[2] not data[4] because data[4] has previous
siblings with @result != 10|11

How would the XPath selector look like? Basically i need to find the
first() (or last()?) node whose previous siblings do not have
@result=10|11

Thanks for your help!
Phil

Current Thread