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.  Help! Beginner in Xquery : basic questions.

    Posted 04/25/07 01:46 PM

    II’m a very naive user of Xquery, who is just at the beginning of learning. :slight_smile:

    I have plein of problems fwith syntax. I try two explain two of them here.

    I’m using the Exist sample database “mondial.xml” :

    http://demo.exist-db.org/rest//db/mondial/mondial.xml

    When I write the query :

    doc/mondial/country/border[@country=“F”]

    to know the code of countries bordering France, I get too muvh information
    (the entire country elements), while I want juste the country codes.
    Of course, I tried to use a FLWOR construction, but, there, I get a message of syntax error that
    I cannot even understant.

    More generally : how to “point” to values of XML attributes, so as to reriebve just them ?

    By the way of the syntax of FLOWR : I managed to get the countrie having more than 60000000 habitants simply by writing :

    for $p in doc(“mondial.xml”)/mondial/country let $b:=$p/population where
    $b >6000000 return $b.

    but it’s a mystery to me why my construction works there and that does not work, for, istance, in my trial to improve the first query.
    :evil:

    Thanks a lot, and sorry for the naivety of my questions. I’m try to learn by myself.


    #API-Management
    #Tamino
    #webMethods


  • 2.  RE: Help! Beginner in Xquery : basic questions.

    Posted 04/26/07 08:06 AM

    If you want to just return the attrbutes you could use:

    
    for $c in input()/mondial/country/border[@country="F"]
    return $c/@country

    To recast the attribute as an element you can use:

    
    for $c in input()/mondial/country/border[@country="F"]
    return <C>{string($c/@country)}</C>

    To return elements showing the countries that border France, you might use:

    for $p in input()/mondial/country
    let $b := $p/border/@country
    where $b = "F"
    return <bordering>{$p/@car_code}</bordering>

    and to get the country name with the code:

    for $p in input()/mondial/country/border
    where $p/@country = "F"
    return <bordering country="{$p/../@car_code}">{$p/../name}</bordering>

    Your second construct returns the node “population” - that is all that is contained in the variable $b.


    #API-Management
    #webMethods
    #Tamino