webMethods

webMethods

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.

 View Only
Expand all | Collapse all

Get XQuery Result with joined elements

  • 1.  Get XQuery Result with joined elements

    Posted Tue March 19, 2002 11:19 AM

    Hello.

    Can anybody give me a hint how i can query joined elemts including in a result document?


    doctype order_id:
    <order_id ino:id=“1” c_ob_id=“1” p_ob_id=“2”>
    <order_id ino:id=“2” c_ob_id=“1” p_ob_id=“3”>
    <order_id ino:id=“2” c_ob_id=“2” p_ob_id=“1”>

    doctype customer:
    c1
    c2

    doctype product:
    p1
    p2

    The result should be something like that:

    c1
    p1
    p2


    c2
    p1


    I do not know how to solve it! :o(

    Regards
    Michael


    #webMethods
    #Tamino
    #API-Management


  • 2.  RE: Get XQuery Result with joined elements

    Posted Mon March 25, 2002 03:37 PM

    Sorry that nobody answered your question earlier
    (I was on vacation…)

    I hope the following solution will help you.
    Yo can test it with the latest version of quip (I
    did not check earlier versions).

    From this solution you can learn several things:

    * a nice example of qualified expressions
    * nested flower expressions
    * computed element construction
    * definition of utility function

    Sven Eric

    –snip------


    define function removeAttr($el){
    element {name($el)} {$el/node()}
    }

    let $orders :=
    (<order_id ino:id=“1” c_ob_id=“1” p_ob_id=“2”/>
    ,<order_id ino:id=“2” c_ob_id=“1” p_ob_id=“1”/>
    ,<order_id ino:id=“2” c_ob_id=“2” p_ob_id=“1”/>
    )

    let $customers :=
    (c1
    ,c2
    )

    let $products :=
    (p1
    ,p2
    )

    for $c in $customers
    return
    {
    removeAttr($c),
    for $p in $products
    where some $o in $orders
    satisfies ($p/@ino:id = $o/@p_ob_id
    and $c/@ino:id = $o/@c_ob_id)
    return
    removeAttr($p)
    }


    #Tamino
    #API-Management
    #webMethods