webMethods

webMethods

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.  problem with SUM function in XQuery

    Posted Tue September 02, 2003 03:13 PM

    Hello

    I have a big problem with formating a result of a SUM function. The result shouldn’t contain ‘E’ character.

    let $z:=sum(input()/docs/floatvalue)
    return $z

    It gives for example: 123.45E4

    how can I avoid such a situation and obtain a result like XXX.XX.

    thanks in advance


    #API-Management
    #webMethods
    #Tamino


  • 2.  RE: problem with SUM function in XQuery

    Posted Tue September 02, 2003 04:41 PM

    please… any suggestions?


    #Tamino
    #webMethods
    #API-Management


  • 3.  RE: problem with SUM function in XQuery

    Posted Wed September 03, 2003 07:17 AM

    This is the way that Tamino prints large numbers (or doubles?), so I don’t think this problem has anything in particular to do with the sum() function. I don’t see any functions in tamino for formatting numbers, but you could probably use a stylesheet (XSL-FO) to process Tamino’s output into the form you want.

    Bill


    #webMethods
    #API-Management
    #Tamino


  • 4.  RE: problem with SUM function in XQuery

    Posted Wed September 03, 2003 12:47 PM

    Hi,

    try

    declare namespace xs=“XML Schema
    let $z:=sum(input()/docs/floatvalue)
    return xs:integer($z)

    regards

    Harald


    #Tamino
    #API-Management
    #webMethods


  • 5.  RE: problem with SUM function in XQuery

    Posted Wed September 03, 2003 02:30 PM

    This is a known gap in the current XQuery specs (which may or may not get filled - we’re having great trouble getting agreement in this area).

    There’s no format-number capability in XQuery, but you can convert to an integer or decimal which will give you a more acceptable display. Or, of course, you can render the output through XSLT.

    Michael Kay


    #webMethods
    #API-Management
    #Tamino


  • 6.  RE: problem with SUM function in XQuery

    Posted Wed September 03, 2003 06:18 PM

    Thanks you for all your answers :slight_smile:

    The information that it’s “a gap in current xquery specification” satisfies my expectations :slight_smile: The worst situation is when I don’t know the solution that really exists.

    I couldn’t use a stylesheet because I prepared a mechanism for different reports managed by one algoritm and XQuery is built “on fly”… so I don’t know a document structure… But it’s a more complex problem…

    By the way do anybody explain me which function in XSLT can change this number format to normal double. Unfortunatelly format-number interprets this as a NaN (Not a Number).

    Once again THANKS

    Martka


    #webMethods
    #API-Management
    #Tamino


  • 7.  RE: problem with SUM function in XQuery

    Posted Wed August 18, 2004 12:25 PM

    I have another way of doing this.

    Try inside the sum, doing the next:

    1. Multiply * 100
    2. Convert to integer
    3. Divide / 100.


    #Tamino
    #API-Management
    #webMethods