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.


#TechXchangePresenter
 View Only
  • 1.  [XQuery] how find the max value in an attribut

    Posted Tue June 21, 2005 05:41 PM

    Hello,

    Does Someone know how I find the maximal value of attribut in an element. I show you this xquery exemple:

    declare namespace xs=‘XML Schema
    for $c in max(input()/Case[@year=xs:gYear(‘2000’) and @crit=‘BL’]/@number)
    return $c

    If I write this exemple, I have no answer, it take too long tim.
    However, I have an index on year et crit attribut.

    If I write this xquery without max() function, I hava an answer, but it is a list number and I want to have the maximum value of the number attribut.

    Thank you very much for your help.

    C


    #Tamino
    #webMethods
    #API-Management


  • 2.  RE: [XQuery] how find the max value in an attribut

    Posted Tue June 21, 2005 10:54 PM

    I’d try

    declare namespace xs='http://www.w3.org/2001/XMLSchema'
    
    max(
    for $c in input()/Case
    where $c/@year=xs:gYear('2000') and $c/@crit='BL'
    return $c/@number
    )

    #Tamino
    #webMethods
    #API-Management


  • 3.  RE: [XQuery] how find the max value in an attribut

    Posted Wed June 22, 2005 08:53 AM

    Thank you Curtis for your help, now It works very well ! :lol:

    C


    #webMethods
    #API-Management
    #Tamino


  • 4.  RE: [XQuery] how find the max value in an attribut

    Posted Thu July 07, 2005 04:22 PM

    Try this:

    declare namespace xf = “W3C XQuery 1.0 and XPath 2.0 Functions and Operators
    declare namespace xs = “XML Schema
    let $max:= (
    input()/Case[@year=xs:gYear(‘2000’) and @crit=‘BL’]
    sort by (@number descending)
    )[1]
    return $max

    Regards,

    Joachim


    #API-Management
    #webMethods
    #Tamino