IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

Question regarding the accept operator

  • 1.  Question regarding the accept operator

    Posted Tue January 03, 2006 04:46 PM

    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.


    #API-Management
    #webMethods
    #Tamino


  • 2.  RE: Question regarding the accept operator

    Posted Wed January 04, 2006 10:23 AM

    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.


    #API-Management
    #webMethods
    #Tamino


  • 3.  RE: Question regarding the accept operator

    Posted Wed January 04, 2006 07:44 PM

    Juliane,

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

    Don


    #Tamino
    #webMethods
    #API-Management