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

Re: how do I find the sum for nested elements???

Subject: Re: how do I find the sum for nested elements???
From: "Garrick Besterwitch" <garrickb@xxxxxxxxxxx>
Date: Thu, 6 Dec 2001 13:00:07 +0530
find the sum
Thanks for solution Joshua ...............

Garrick

----- Original Message -----
From: <Joshua.Kuswadi@xxxxxxxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, December 06, 2001 12:05 PM
Subject: RE:  how do I find the sum for nested elements???


> Hi Garrick,
>
> For the below structure: (Note I've added a document element)
> <AgentList>
> > <AgentInfo>
> >     <MerchantList>
> >          <MerchantInfo>
> >              <Bal>10</Bal>
> >          </MerchantInfo>
> >          <MerchantInfo>
> >              <Bal>10</Bal>
> >          </MerchantInfo>
> >     </MerchantList>
> >   </AgentInfo>
> >    <AgentInfo>
> >       <MerchantList>
> >            <MerchantInfo>
> >                 <Bal>10</Bal>
> >            </MerchantInfo>
> >            <MerchantInfo>
> >                 <Bal>10</Bal>
> >            </MerchantInfo>
> >       </MerchantList>
> >   </AgentInfo>
> <AgentList>
> >
> >
> > I need the Total Balance i.e Grand Total for all Merchants
> > ....and also the
> > Total Balance Agent wise using XSL
>
> something like this should return the desired result. (I'm assuming you
want it in an HTML table format)
> <xsl:stylesheet>
> <xsl:template match="/AgentList">
>  <table>
>   <xsl:apply-templates select="AgentInfo" />
>   <tr>
>    <td>Grand total</td>
>    <td><xsl:value-of select="sum(AgentInfo/MerchantList/MerchantInfo/Bal)"
/></td>
>   </tr>
>  </table>
> </xsl:template>
>
> <xsl:template match="AgentInfo">
>  <tr>
>   <td>Agent: <xsl:value-of select="position()" /></td>
>   <td><xsl:value-of select="sum(MerchantList/MerchantInfo/Bal)" /></td>
>  </tr>
> </xsl:template>
> </xsl:stylesheet>
>
> >
> > eg Grand Total =40
> > (Agent wise)Total=20
>
> HTH,
> Joshua
>
> --------------------------------------------------------------------------
----
> This message and any attachment is confidential and may be privileged or
otherwise protected from disclosure.  If you have received it by mistake
please let us know by reply and then delete it from your system; you should
not copy the message or disclose its contents to anyone.
>
>
>
>
>
>  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.