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.  Java api query nested elements help

    Posted Tue January 30, 2007 06:26 PM

    Hello we have an xml structure like this :

    <A
















    /A>

    Where elements, can be repeated in this structure. Where a , b, or c can take values from 1 to n.

    In this way we are wondering if it’s posible to make a query where asking only for L, M, I or F to have a value X and return only the related parents and that complish with the searched value/s descarting the other ones ( ) that are not acomplishing the search condition.

    Thanks in advance.


    #API-Management
    #webMethods
    #webMethods-Tamino-XML-Server-APIs


  • 2.  RE: Java api query nested elements help

    Posted Thu February 01, 2007 10:39 AM

    Hi,

    you are somewhat vague on the expected result, so I can only guess that the following query produces what you want to see

    
    for $d in collection("ino:etc")/A
    return ($d/*[starts-with(local-name(.),"D") and F="X"],
    $d/*/*[starts-with(local-name(.),"G") and I="X"],
    $d/*/*/*[starts-with(local-name(.),"J") and (L="X" or M="X")])

    If applied to the input

    
    <A><B/><C/><D1><E/><F>X</F><G1><H/><I>X</I><J1><K/><L/><M>X</M><N/></J1></G1></D1><D2><E/><F/><G1><H/><I>X</I><J1><K/><L/><M/><N/></J1></G1>
    
    <G2><H/><I>Y</I><J1><K/><L/><M/><N/></J1></G2></D2><D3><E/><F/><G1><H/><I/><J1><K/><L/><M/><N/></J1><J2><K/><L/><M/><N>X</N></J2></G1></D3></A>
    

    it produces the output

    
    <D1>
    <E/>
    <F>X</F>
    <G1>
    <H/>
    <I>X</I>
    <J1>
    <K/>
    <L/>
    <M>X</M>
    <N/>
    </J1>
    </G1>
    </D1>
    <G1>
    <H/>
    <I>X</I>
    <J1>
    <K/>
    <L/>
    <M>X</M>
    <N/>
    </J1>
    </G1>
    <G1>
    <H/>
    <I>X</I>
    <J1>
    <K/>
    <L/>
    <M/>
    <N/>
    </J1>
    </G1>
    <J1>
    <K/>
    <L/>
    <M>X</M>
    <N/>
    </J1>

    Regards

    Harald


    #webMethods-Tamino-XML-Server-APIs
    #webMethods
    #API-Management


  • 3.  RE: Java api query nested elements help

    Posted Thu February 01, 2007 02:04 PM

    Thanks for your answer, I did not meant to be vague in this way I’ll try to be more precise
    Input xml:

    123 29 I>30</I 32 33 34 35 37 38 39 40 6 I>48</I 50 51 52 53 55 56 57 17 555 60 I>61</I 62 63 64 65 67 68 69 70 71 I>72</I 73 74 75 76 77 78 79 80 223 6 I>7</I 9 10 11 12 14 15 16 17 19 20 21 17

    If I ask for F=123 and H=6 and N=17 the espected output should be :

    123 6 I>48</I 55 56 57 17

    Notice that the following elements or nodes have been removed : D2 and G1 and J1 from xml structure D1 of the element or node A1
    Is this possible?

    Thanks in advance,
    Enric


    #webMethods
    #API-Management
    #webMethods-Tamino-XML-Server-APIs


  • 4.  RE: Java api query nested elements help

    Posted Thu February 01, 2007 03:53 PM

    Hi

    try

    
    declare function local:filter ($in as node()) as node() {
    if (starts-with(local-name($in),"D") and not ($in[F=123 and */H=6 and */*/N=17])
    or starts-with(local-name($in),"G") and not ($in[H=6 and */N=17])
    or starts-with(local-name($in),"J") and not ($in[N=17])
    ) then ()
    else
    element {local-name($in)} {$in/@*, 
    for $node in $in/* return if ($node/*) then local:filter($node) else $node}
    }
    for $doc in collection("ino:etc")/*
    let $d:=$doc/*[starts-with(local-name(.),"D") and F=123 and */H=6 and */*/N=17]
    where $d
    return local:filter($doc)

    Regards

    Harald


    #webMethods-Tamino-XML-Server-APIs
    #webMethods
    #API-Management


  • 5.  RE: Java api query nested elements help

    Posted Fri February 02, 2007 01:23 PM

    Hi, Harald thanks for your help and for being so patient. I am just a beginner with XQuery.

    I’ve tried the following query:

    declare function local:filter ($in as node()) as node() {
    if (starts-with(local-name($in),“D”) and not ($in[F=123 and /H=6 and //N=17])
    or starts-with(local-name($in),“G”) and not ($in[H=6 and /N=17])
    or starts-with(local-name($in),“J”) and not ($in[N=17])
    ) then ()
    else
    element {local-name($in)} {$in/@
    ,
    for $node in $in/
    return if ($node/) then local:filter($node) else $node}
    }
    for $doc in input()/A
    let $d:=$doc/
    [starts-with(local-name(.),“D”) and F=123 and */H=6 and //N=17]
    where $d
    return local:filter($doc)

    Returned error :

    <ino:messagetext ino:code=“INOXQE6352”>XQuery parsing error</ino:messagetext>
    ino:messageline
    Syntax Error at line 1, column 9: found “function” when expecting any of: “or”, “and”, “div”, “mod”, " *", “intersect”, “union”, “except”, “/”, “//”, “=”, “!=”, “<=”, “>=”, “eq”, “ne”, “gt”, “ge”, “lt”, “le”, "< ", “>”, “-”, “+”, “=>”, “|”, “(”, “[”, “,”, “sort”, “stable”
    </ino:messageline>
    </ino:message>

    Seems to fail on method starts-with used in function local:filter.
    I’ve executed the following xquery:

    for $doc in input()/A
    let $d:=$doc/*[starts-with(local-name(.),“D”) and F=123 and */H=6 and //N=17]
    where $d
    return $doc

    And this worked fine. Any idea about this?

    Thanks in advance


    #webMethods
    #API-Management
    #webMethods-Tamino-XML-Server-APIs


  • 6.  RE: Java api query nested elements help

    Posted Sun February 04, 2007 10:20 AM

    Hi,

    this looks like you do not have Tamino v4.4 installed (but maybe V4.2). Please check the version of your system

    regards

    harald


    #webMethods-Tamino-XML-Server-APIs
    #API-Management
    #webMethods


  • 7.  RE: Java api query nested elements help

    Posted Mon February 05, 2007 09:43 AM

    Hi Harald, we are working with tamino version 4.2.1.7 . Is it posible to execute this kind of queries with this versi


    #API-Management
    #webMethods
    #webMethods-Tamino-XML-Server-APIs


  • 8.  RE: Java api query nested elements help

    Posted Mon February 05, 2007 03:51 PM

    Hi,

    this kind of query does not work with 4.2. I suggest you to upgrade to v4.4

    Regards

    harald


    #webMethods
    #API-Management
    #webMethods-Tamino-XML-Server-APIs