I have this piece of XML-code:
<player name="John" points="50">
<game points="5">Beans</game>
<game points="40">Cucumbers</game>
<game points="50">Tomatos</game>
</player>
What I want to do is to get this piece, but only with those games where number of points (attribute of "game") is equal to points which is attribute of "player". Thus, considering above example, I should get next XML-piece:
<player name="John" points="50">
<game points="50">Tomatos</game>
</player>
I write following XQuery:
for $a in doc("ex.xml")
where $a/xs:int(@points)=$a/game/xs:int(@points)
return $a
But I don't get any result. Could you please help me?