I am using BaseX latest version 11.0 beta.
I am trying to remove Texas cities in the /root/base/r sequence by using /root/remove/r sequence.
The goal is to use XQuery except expression.
Here is my XML and XQuery
declare context item := document {
<root>
<base>
<r>Miami</r>
<r>Orlando</r>
<r>Dallas</r>
<r>Austin</r>
</base>
<remove>
<r>Dallas</r>
<r>Austin</r>
</remove>
</root>
};
let $remove := /root/remove/r
return /root/base/r except $remove
Desired output
<r>Miami</r>
<r>Orlando</r>
Unfortunately, I am getting the same initial XML
<r>Miami</r>
<r>Orlando</r>
<r>Dallas</r>
<r>Austin</r>
It is not clear what I am doing wrong.
With
except, the node references are compared, not their contents. For example, the following query will exclude nodes with the same node identity from the result:If you want to exclude all nodes of the
basebranch that have the string values of the nodes of the$removebranch, you can do this: