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.  XQuery

    Posted 01/19/05 09:07 PM

    Hi:
    I’m new to XQuery. I have a document like the following

    John Doe
    7031234567
    8041234567
    9051234567

    Mary Ann
    2021234567
    9011234567
    8051234567


    I want to get the home phone, the query I used like the following :

    for $a in input()/person
    let $b :=$a/phone
    where $b/@type=“home”
    return $b

    Obviously this doesn’t work as it gives back all phone no matter which type. Please help.


    #API-Management
    #Tamino
    #webMethods


  • 2.  RE: XQuery

    Posted 01/20/05 08:40 AM

    Hi,

    The reason for the unexpected result is that by using a ?let? clause you bind all phones of a person to variable $b. In the ?where? clause you just check if there is a ?home? phone bound to $b. If this is the case you return all phones of a person by returning $b.
    To get the only the ?home? phones you have to replace the ?let? by a ?for? clause in the following way:

    for $a in input()/person
    for $b in $a/phone
    where $b/@type=“home”
    return $b

    A shorter variant of this query is the following:

    for $b in input()/person/phone
    where $b/@type=“home”
    return $b

    The shortest variant just consists of a single path expression:

    input()/person/phone[@type=“home”]

    Best regards,

    Thorsten Fiebig


    #API-Management
    #webMethods
    #Tamino