[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: max of sum

Subject: Re: max of sum
From: "Charly" <cohana@xxxxxxxxxxxxxxx>
Date: Fri, 1 Feb 2002 09:33:18 -0800
max of sum
Thanks Oliver,
That's awesome .

----- Original Message -----
From: "Oliver Becker" <obecker@xxxxxxxxxxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Friday, February 01, 2002 12:10 AM
Subject: Re:  max of sum


> > Is there a way to get the max for a bunch of sum on an attribute.
>
> Yes, of course.
>
> > I have the following XML and would like to find what's the highest
expenses
> > (sum of all expense/@value). Which would be 303 .
> > any idea ?
> >
> > <company>
> >    <department id="IT">
> >       <expense value="10"/>
> >       <expense value="12"/>
> >       <expense value="13"/>
> >       <expense value="18"/>
> >       <expense value="28"/>
> >    </department>
> >
> >    <department id="Research">
> >       <expense value="40"/>
> >       <expense value="150"/>
> >       <expense value="75"/>
> >       <expense value="17"/>
> >       <expense value="21"/>
> >    </department>
> >
> >    <department id="Finance">
> >       <expense value="34"/>
> >       <expense value="77"/>
> >    </department>
> >
> >    <department id="HR">
> >       <expense value="22"/>
> >    </department>
> > </company>
>
>
> <xsl:template match="department">
>   <xsl:variable name="sum" select="sum(expense/@value)" />
>   <xsl:if test="not(../department[sum(expense/@value) > $sum])">
>     <xsl:text />max: <xsl:value-of select="$sum" /> for <xsl:text />
>     <xsl:value-of select="@id" />
>   </xsl:if>
> </xsl:template>
>
> Cheers,
> Oliver
>
>
> /-------------------------------------------------------------------\
> |  ob|do        Dipl.Inf. Oliver Becker                             |
> |  --+--        E-Mail: obecker@xxxxxxxxxxxxxxxxxxxxxxx             |
> |  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
> \-------------------------------------------------------------------/
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.