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.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
  • 1.  Q:XQuery and 'outerjoin'

    Posted 11/14/03 07:24 AM

    Could someone come up with a solution for the following problem (challenge :wink:

    I do have the following document (instance of a specific schema)



    mo
    tu














    Element Allocation is optional!

    Now I would like to get all documents with and without allocations using XQuery4

    The following XQuery only returns documents WITH allocation, but I do also want documents WITHOUT allocations!

    How do I proceed. A union would be a solution but I have no idea how to accomplish this with XQuery4.

    Here is the xquery that produces all documents with an allocation

    --------------------------------
    for $chkplan in input()/Chkplan

    sort by ($chkplan/@fltnr)
    return
    for $alloc in $chkplan/Allocation {
    { $alloc/@rlendtime } { $alloc/@rlstarttime } { $chkplan/@fltnr }
    { $chkplan/Operationaldays }
    { for $row in $alloc/Checkin return
    { $row/@chkinrow }

    }

    }
    --------------------------------

    Regards,
    Rudolf de Grijs


    #API-Management
    #webMethods
    #Tamino


  • 2.  RE: Q:XQuery and 'outerjoin'

    Posted 11/17/03 05:55 PM

    Hi Rudolf,

    The above xml is not valid and xquery is not valid so could you zip up and post the following:
    1) actual example document with allocations
    2) actual example document without allocations
    3) actual xquery you have working so far (that does just produces a result of documents with allocations)
    4) and what you really expect to see in the result: i.e. for those documents without allocations what would you expect to see in the result set.

    Bye for now,

    Stuart Fyffe-Collins
    Software AG (UK) Ltd.


    #API-Management
    #webMethods
    #Tamino


  • 3.  RE: Q:XQuery and 'outerjoin'

    Posted 11/18/03 12:27 PM

    Hi Stuart,

    Ok, I may have made a typo. Here is the real thing:

    I have two (valid) XML documents



    mo
    tu
    th
    su





















    we





    One document contains Chkalloc elements and teh last one does not.

    Now I would like to ‘browse’ over the allocations (and it works, but the latter is left out in the final result)

    The XQuery(4)

    for $chkplan in input()/Chkplan

    sort by ($chkplan/@fltnr)
    return
    for $alloc in $chkplan/Chkalloc
    return
    { $alloc/@rlendtime } { $alloc/@rlstarttime } { $chkplan/@fltnr } { $chkplan/@protect }
    { $chkplan/Opdays }
    { for $row in $alloc/Checkin return
    { $row/@chkinrow }

    }


    What I also want, besides all documents with Chkalloc elements, are documents without Chkalloc elements, so
    in that case the attributes { $alloc/@rlendtime } { $alloc/@rlstarttime } and the Row elements are missing in the final result.


    I’m not able to accomplish this, but you would make me happy if you can :wink:

    Kind regards,
    Rudolf de Grijs


    #API-Management
    #webMethods
    #Tamino


  • 4.  RE: Q:XQuery and 'outerjoin'

    Posted 11/18/03 03:56 PM

    Hello Rudolf,

    How about the following xquery. Seems to work for me.

      
    for $chkplan in input()/Chkplan
    sort by ($chkplan/@fltnr)
    return (
    (let $e := for $alloc in $chkplan/Chkalloc
    return
    <Allocation> { $alloc/@rlendtime } 
    { $alloc/@rlstarttime } 
    { $chkplan/@fltnr } 
    { $chkplan/@protect } 
    { $chkplan/Opdays } 
    { for $row in $alloc/Checkin return 
    <Row> { $row/@chkinrow } </Row> 
    } 
    </Allocation> 
    where count($chkplan/Chkalloc) > 0 return $e),
    
    (let $e := <Allocation>
    { $chkplan/@fltnr } 
    { $chkplan/@protect } 
    { $chkplan/Opdays } 
    </Allocation>
    where count($chkplan/Chkalloc) = 0 return $e)
    )



    Really hope this helps.

    Stuart Fyffe-Collins
    Software AG (UK) Ltd.


    #Tamino
    #webMethods
    #API-Management


  • 5.  RE: Q:XQuery and 'outerjoin'

    Posted 11/18/03 04:15 PM

    Thanks Stuart … it works ;-).


    Kind regards,
    Rudolf


    #webMethods
    #API-Management
    #Tamino


  • 6.  RE: Q:XQuery and 'outerjoin'

    Posted 07/24/07 02:01 PM

    Hi,
    I am very new to both XML and XQuery, but I think I have a problem that could be solved using parts of the code given in the previous messages of this thread. I want to retrieve all XML documents that do not have a particular element. As I said, I am extremely new to this, so my apologies if my question is strangely worded or exceedingly simple.

    An example of my schema is this:

    2005 04001 55 Imaging of keratin dynamics during the cell cycle and in response to phosphatase inhibition. Windoffer R Leube RE Meth. Cell Biol. 23 321-352 A

    What I am trying to do, is write a query that will give me all documents that do not contain a ‘Bewertung’ element.

    I hope it’s a simple matter. In the meantime, I will continue trying. Thanks! :slight_smile:

    Kathy


    #Tamino
    #API-Management
    #webMethods


  • 7.  RE: Q:XQuery and 'outerjoin'

    Posted 07/24/07 03:05 PM

    Hi Kathy,
    A simple query like below should be able to do the job.

    Finn
    PS The query is only optimized if there is an standard index on “Bewertung” !!!

    for $a in input()/Publikation
    where not ($a/Bewertung)
    return $a


    #Tamino
    #API-Management
    #webMethods


  • 8.  RE: Q:XQuery and 'outerjoin'

    Posted 07/24/07 03:30 PM

    Quick response!

    Thanks a lot. :slight_smile: We got it working.

    KT


    #webMethods
    #API-Management
    #Tamino