eXist-db / exist

eXist Native XML Database and Application Platform
https://exist-db.org
GNU Lesser General Public License v2.1
416 stars 179 forks source link

Node Comparison returns no data with nested predicate #5342

Open adamretter opened 2 weeks ago

adamretter commented 2 weeks ago

The data (example-1.xml) looks like:

<text>
  <lg>
      <w wid="_1_d2e15" id="d1e14" lemma="thalla">Thalla</w>
      <pc join="left">,</pc>
      <w wid="_1_d2e23" id="d1e20" lemma="voc">a</w>
      <w wid="_1_d2e26" id="d1e23" pos="nx" lemma="leabhar">leabhair</w>
      <w wid="_1_d2e30" id="d1e26" pos="a" lemma="beag">bhig</w>
      <w wid="_1_d2e33" id="d1e30" pos="px" lemma="neo">neo</w>
      <pc join="both">-</pc>
      <w wid="_1_d2e41" id="d1e36" pos="a" lemma="euchdach">euchdaich</w>
      <pc join="left">:</pc>
      <lb/>
      <w wid="_1_d2e50" id="d1e45" pos="V" lemma="amhairc">amhairc</w>
      <w wid="_1_d2e55" id="d1e54" pos="A" lemma="a-steach">a-steach</w>
      <w wid="_1_d2e58" id="d1e61" pos="p" lemma="an">’na</w>
      <w wid="_1_d2e61" id="d1e64" pos="ns" lemma="sùil">sùilean</w>
      <w wid="_1_d2e65" id="d1e67" pos="a" lemma="leugach">leugach</w>
      <pc join="left">:</pc>
      <lb/>
      <w wid="_1_d2e75" id="d1e76" pos="z" lemma="ge">ge</w>
      <w wid="_1_d2e78" id="d1e79" pos="a" lemma="bacach">bacach</w>
      <w wid="_1_d2e84" id="d1e82" pos="D" lemma="thu">thu</w>
      <pc join="left">,</pc>
      <w wid="_1_d2e90" id="d1e88" pos="z" lemma="cha">chan</w>
      <w wid="_1_d2e93" id="d1e92" pos="v" lemma="bi">eil</w>
  </lg>
</text>

The initial query setup looks like:

let $n := 7
let $word := doc("/db/meanma/example-1.xml")//w[@wid eq "_1_d2e50"]
let $following-n-words := $word/following-sibling::w[fn:position() le $n]

This expression returns no data:

$word/following-sibling::node()[. << $following-n-words[last()]]

Refactoring it to this (to remove the inner predicate), does return data:

let $last-following-n-word := $following-n-words[last()]
return
  $word/following-sibling::node()[. << $last-following-n-word]

Tested with eXist-db 7.0.0-SNAPSHOT (built from develop branch commit 097087bb020637b2c9d293d82522a2a5689aedc0)