Question regarding the accept operator

Hi,

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?

Thanks.

Hi,

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
XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition) for details.

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

Regards,
Juliane.

Juliane,

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

Don