I am trying to use a Xquery FLOWR where statement in C#:
for $x in //div[@class="class1"] where $x//span="data1" return $x
to get some data from an xml file. (The reason for using FLOWR is to easily read the queries runtime from an external file)
for this I use the Saxon API: http://www.saxonica.com/html/documentation/dotnet/dotnetapi.html
The xml code looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<div class="class1">
<div class="class2">
<span class="class3">
data1
</span>
<span class="class4">
data2
</span>
</div>
<div class="class5">
data3
</div>
<div class="class6">
data4
</div>
</div>
<div class="class1">
<div class="class2">
<span class="class3">
data5
</span>
</div>
<div class="class5">
data6
</div>
</div>
</doc>
If I test this code using X-base it works like I expect and returns one of the two class1 classes; however both Saxon and xpathtester.com compile the Xquery without errors but return empty. If I remove the optional where statement it behaves as expected. Am I missing something?