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
Expand all | Collapse all

XQuery - select only appropriate parts of a document

  • 1.  XQuery - select only appropriate parts of a document

    Posted Fri May 07, 2004 12:09 AM

    Hi!

    My problem is to select parts of a XML document in Tamino with XQuery.

    My xml document is:



















    Now i want to get all rows with child elements where the number of available seats is bigger than a defined value.

    My XQuery should look similar to that:
    let $freeseats := 5
    for $b in input()/performance
    where $b/seats/@freeseats > $freeseats
    and count($b/seats/row/@freeseats > $freeseats)
    return $b/row

    There are two problems with the query:
    1. Function count() is not recognized by Tamino:
    Result:
    <ino:messagetext ino:code=“INOXQE6351”>XQuery feature not implemented</ino:messagetext>

    Tried to use
    declare namespace xf = “W3C XQuery 1.0 and XPath 2.0 Functions and Operators
    and xf:count, but without success.

    2. The where clause i only true for parts of the document. (row id=“1”) For row id=“2” the where clause is false. Tried to use nested counts: count(count(…) > $freeseats) > 0 .
    Got same problem as in (1.). Another problem is to return only the rows, where the clause is true.

    Has anyone an idea, which XQuery could satisfy my needs?

    Thanks in advance!
    Regards,
    Christian


    #webMethods
    #Tamino
    #API-Management


  • 2.  RE: XQuery - select only appropriate parts of a document

    Posted Fri May 07, 2004 10:28 AM

    Hi,

    From your document fragment you can extract “row” elements that have a “freeSeat” attribute with a value greater than 5 by the following query:

    for $b in input()/theater/seats/row
    where $b/@freeseats > 5
    return $b

    The error 6351 is caused by the fact that you have tried to call the count() on a boolean expression. This is not supported by the early versions of the Tamino XQuery processor.

    Regards,

    Thorsten


    #Tamino
    #webMethods
    #API-Management


  • 3.  RE: XQuery - select only appropriate parts of a document

    Posted Fri May 07, 2004 12:50 PM

    Hi Thorsten!

    Thanks for your solution! Works fine. Quite simple! :slight_smile:

    Regards,
    Christian


    #API-Management
    #Tamino
    #webMethods