now I know that what I was trying to do is wrong, but the error message is totally misleading. No line number is reported in eXide and in Test Suite a totally misleading line and column number is reported, which confuses the issue no end.
The code to cause the error is simply :-
xquery version "3.0";
declare namespace jr = "http://www.JonathanTest.fr/tests";
let $list := (<jr:element/>,<jr:another-element/>)
if ($list[node-name(.)='jr:element']) then
and the error message is "exerr:ERROR Type error: cannot compare QName to xs:string". It also fails if there is one element in the $list but not when it is empty.
I actually create a list of elements dynamically, one at a time, and want to check that if the next one is only allowed once the raise an error. In practice the elements have different content.