Question regarding the accept operator


I have two xml files (books1.xml and books2.xml) that represent book collections. The files have a format like this:

TCP/IP Illustrated StevensW. Addison-Wesley 65.95 Advanced Programming in the UNIX Environment StevensW. Addison-Wesley 65.95

The files have some overlap so that the same book may appear in books1.xml and books2.xml. In addition, the files contain books which are not overlapped, so that those books appear in only one of the source files.

I would like to create a query that shows the books contained in books1.xml which are not in books2.xml. I tried the following query:

let $a := doc(“container1\books1.xml”)\book
let $b := doc(“container1\books2.xml”)\book
return $a expect $b

This query returns all the entries in books1.xml. Can anyone tell me what I’m doing wrong?



except works on the basis of node identity, i.e. a node is removed from the first
set only if a node having the same identity is contained in the second set. Since
the nodes in the second set are from a different collection, they are not identic
to any of the nodes in the first set.

The concept you are looking for, i.e. the idea of two different nodes having the
same content, is called deep-equality in XQuery speak. Check for details.

$a[not(. = $b)] should do it.



Thank you so much for your reply. The solution you suggested works perfectly. Thanks again for solving my problem!