Search the archives of this list
(http://www.biglist.com/lists/xsl-list/archives/) or Google for "Muenchian
method".
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email
-----Original Message-----
From: Martin K. Borgars <martin(_dot_)borgars(_at_)btopenworld(_dot_)com>
Sent: Fri, 18 Jun 2004 12:27:52 +0100
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: [xsl] 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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--