RE: [xsl] Grouping by attribute values

Subject: RE: [xsl] Grouping by attribute values
From: cknell@xxxxxxxxxx
Date: Tue, 01 Mar 2005 08:49:40 -0500
Go to this URL (http://techrepublic.com.com/5046-22-0.html?SearchThis=Muenchian+grouping&nodeIds=all&go=GO) and get this document: - Overcoming decades old legacy systems with XSLT and Muenchian grouping .
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Josh Taylor <jktylr@xxxxxxxxxxx>
Sent:     Tue, 01 Mar 2005 09:38:16 -0400
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  [xsl] Grouping by attribute values

I have the following problem. My XML is structured in the following way:

<?xml version="1.0" encoding="UTF-8"?>
<ratePremiums rateDate="20041001" territory="100" type="1">
<coverage id="Liability">
  <premium class="1" drivingRecord="0" 
limit="200">820.7014415999998</premium>
  <premium class="1" drivingRecord="0" 
limit="300">853.5294992639998</premium>
  <premium class="1" drivingRecord="1" 
limit="200">805.7559679999999</premium>
  <premium class="1" drivingRecord="1" 
limit="300">837.9862067199999</premium>
....
  <premium class="12" drivingRecord="2" limit="200">0.0</premium>
  <premium class="12" drivingRecord="2" limit="300">0.0</premium>
<coverage>
</ratePremiums>

I need to display premiums grouped first by class, then by driving record 
and then by limit in
HTML tables.

So a table for each class, a row for each driving record and a column for 
each limit (much like an engineering table).

To elaborate: Desired output for the snipet above is:
Class 1:
<table>
  <tr><th></th><th>200 K</th><th>300 K</th></tr>
  <tr><td>DR = 
0</td><td>820.7014415999998</td><td>853.5294992639998</td></tr>
  <tr><td>DR = 
0</td><td>805.7559679999999</td><td>837.9862067199999</td></tr>
  ....
</table>
... etc.

I have no idea how to loop through the premiums, isolated a unique class to 
create a table. Then for that class loop through unique driving record 
values and display the premiums according to limit.

I do not want to structure my XML with this table view in mind.

Thank you for your time!

- Josh Taylor

Current Thread