Dear BaseX,
according to github instructions I’m sending a bug report via email:
Using BaseX 9.5.1, cmd-line “basex.bat -i datafile.xml queryfile.xq” leads to no result at all. I’m convinced there should be result equivalent to the one of the online xquery tester (https://www.videlibri.de/cgi-bin/xidelcgi)
For a modified query using string comparison based on fn:path(), BaseX gives the expected result.
%%% query begin %%%
let $rootElement := /child::*
for $x in //Section[parent::* != $rootElement]
return fn:path($x)
%%% query end %%%
%%% data begin %%%
<root>
<Section id="should not be reported 1" />
<Section id="should not be reported 2">
<Section id="should be reported 1"/>
<a>
<Section id="should be reported 2"/>
</a>
</Section>
<a>
<Section id="should be reported 3"/>
</a>
</root>
%%% data end %%%
%%% modified query begin %%%
let $rootElementPath := fn:path(/child::*)
for $x in //Section[fn:path(parent::*) != $rootElementPath]
return fn:path($x)
%%% query end %%%
Kind regards
Jan Červák