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

RE: Grouping & summing

Subject: RE: Grouping & summing
From: cknell@xxxxxxxxxx
Date: Fri, 18 Jun 2004 09:35:28 -0400
summing and grouping xsl
Search the archives of this list (http://www.biglist.com/lists/xsl-list/archives/) or Google for "Muenchian method".

-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Martin K. Borgars <martin.borgars@xxxxxxxxxxxxxxx>
Sent:     Fri, 18 Jun 2004 12:27:52 +0100
To:       <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:   Grouping & summing

I have a piece of XML which looks like this: -

<application>
       <personal_client id="pc1">
             <full_name>Mr Test9</full_name>
       </personal_client>
       <personal_client id="pc2">
             <full_name>Mrs Test9</full_name>
       </personal_client>
       <product>
             <risk_benefit id="rb1" type="Permanent Health Insurance">
                    <risk_cover>
                           <life_assured personal_client_id="pc1"/>
                    </risk_cover>
                    <tpsdata>
                           <provider_component>
                                 <calculated_sa>600</calculated_sa>
                           </provider_component>
                    </tpsdata>
             </risk_benefit>
             <risk_benefit id="rb2" type="Permanent Health Insurance">
                    <risk_cover>
                           <life_assured personal_client_id="pc1"/>
                           <life_assured personal_client_id="pc2"/>
                    </risk_cover>
                    <tpsdata>
                           <provider_component>
                                 <calculated_sa>800</calculated_sa>
                           </provider_component>
                    </tpsdata>
             </risk_benefit>
             <risk_benefit id="rb3" type="Permanent Health Insurance">
                    <risk_cover>
                           <life_assured personal_client_id="pc1"/>
                    </risk_cover>
                    <tpsdata>
                           <provider_component>
                                 <calculated_sa>1000</calculated_sa>
                           </provider_component>
                    </tpsdata>
             </risk_benefit>
             <risk_benefit id="rb4" type="Life And Health">
                    <risk_cover>
                           <life_assured personal_client_id="pc2"/>
                    </risk_cover>
                    <tpsdata>
                           <provider_component>
                                 <calculated_sa>900</calculated_sa>
                           </provider_component>
                    </tpsdata>
             </risk_benefit>
       </product>
</application>
 

In my XSL, I want to sum the 'calculated_sa' for each
'life_assured[personal_client_id]' grouped by 'risk_benefit[type]'. If there
is more than 1 'life_assured[personal_client_id]' associated with a
'risk_benefit' then the 'calculated_sa' should be included for each
'life_assured[personal_client_id]'.

 
So, in this example I want to end up with something like this

life_assured[personal_client_id="pc1"] risk_benefit[type="Permanent Health
Insurance"]               Total Sum Assured = 2400 (i.e. 600 + 800 + 1000)

life_assured[personal_client_id="pc2"] risk_benefit[type="Permanent Health
Insurance"]               Total Sum Assured = 800

life_assured[personal_client_id="pc2"] risk_benefit[type=" Life And Health
"]                                  Total Sum Assured = 900

Any suggestions with suitable XPATH or XSL would be greatly appreciated.
 
Many thanks

Martin K. Borgars



--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
--+--




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.