I have the following document where I want to select all nodes with their associated IDs iff all their successor node elements are greater than 300.
<item>
<deposit id="1">
<amount>1200</amount>
<amount>5000</amount>
<amount>2300</amount>
</deposit>
<deposit id="2">
<amount>300</amount>
<amount>1500</amount>
<amount>700</amount>
</deposit>
<deposit id="3">
<amount>300</amount>
<amount>500</amount>
<amount>700</amount>
</deposit>
<deposit id="4">
<amount>300</amount>
</deposit>
<deposit id="5">
<amount>3500</amount>
</deposit>
<deposit id="6">
<amount>1000</amount>
</deposit>
</item>
I've tried to run the following XQuery chunk but it gave me same as the above document without any changes.
let $e := $depot/deposit
for $a in $e/amount
return if (data($a/preceding-sibling::amount)>"300") then $e else ()
I am expecting to have the following query result,
<item>
<deposit id="1">
<amount>1200</amount>
<amount>5000</amount>
<amount>2300</amount>
</deposit>
<deposit id="5">
<amount>3500</amount>
</deposit>
<deposit id="6">
<amount>1000</amount>
</deposit>
</item>