Hi Leo, I came across this question because I needed to know whether there are city > elements twice in the file. For that I wrote version 2 and the result was > wrong. Then I wrote version 1 with > … satisfies . => deep-equal($city) > that gave the correct answer. I noticed that I do not fully understand the > cast behavior of the = operator… >
Thanks. deep-equal() is probably what you want. If you use generalized comparisons (=, !=, etc.), or if you use “data(.)” or “string(.)”, the descendant text nodes of the referenced node will be concatenated and returned as single string. As a result, queries like the following one… <a><b>X</b></a> = <a><c>X</c></a> …will return “true” because the atomized value of both operands is“X”. Sibling node traversals are often slow, as the same nodes are repatedly processed. for $city-group in //city group by $string := serialize($city-group) where count($city-group) > 1 return head($city-group) With the latest BaseX 11 snapshot and the upcoming XQuery 4 features, it could be: for value $v in map:build(//city, serialize#1) where count($v) > 1 return head($v) Hope this helps, Christian