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.

 View Only
  • 1.  recursive join??

    Posted Fri March 16, 2007 10:29 PM

    I’ve got a collection of documents like the following:


    etc. The chain of connections via the has-part elements can be arbitrarily long (20 - 30 in reality). I’d like to get back all the has-part documents related to my root document, something like




    ,
    which I can do easily enough with a script, but am having no luck formulating an xquery to do so. Even a flat result (e.g. ) would be okay as long as it contains all the linked documents. Any suggestions?

    Thanks in advance for anyone’s help.


    #Tamino
    #API-Management
    #webMethods


  • 2.  RE: recursive join??

    Posted Fri March 16, 2007 10:51 PM

    I would try something like this (just off the top of my head; I haven’t tested it or anything):

    declare function local:get-parts($id as xs:string) as node()
    {
    let $doc := input()/doc[@id = $id]
    for $has-part in $doc/has-part
    let $next-id := $has-part/@id
    return <has-part id="{$next-id}">
    {local:get-parts($next-id)}
    </has-part>
    }
    
    let $doc := input()/doc[@id = 'x']
    return <doc id="x">
    {for $part in $doc/has-parts
    return local:get-parts($part/@id)}
    </doc>

    (I should note that this requires Tamino 4.4; Tamino didn’t support user defined functions like this in earlier versions.)


    #Tamino
    #API-Management
    #webMethods


  • 3.  RE: recursive join??

    Posted Thu March 22, 2007 08:58 PM

    Thankfully, we are running 4.4. And your query works beautifully. Thanks for the help.


    #webMethods
    #API-Management
    #Tamino