[xsl] Another grouping question

Subject: [xsl] Another grouping question
From: "William Jordan" <williamhjordan@xxxxxxxxxxx>
Date: Sat, 21 Aug 2004 00:53:56 +0000
Sorry about this question. I know there have been many questions regarding grouping, but I for one am still not getting it.

Here is my problem.

I am using XSLT1.0

My data is in this format.

<type name="UNIT1">
  <kind name="DMI">
     <age name="2">
        <division name="SEC">9</division>
        <division name="HGT">4</division>
        <division name="KIU">12<division>
     </age>
     <age name="3">
        <division name="SEC">4</division>
        <division name="HGT">56</division>
        <division name="KIU">125<division>
     </age>
     <age name="5">
        <division name="SEC">61</division>
        <division name="HGT">316</division>
        <division name="KIU">83<division>
     </age>
  </kind>
  <kind name="TYD">
     <age name="3">
        <division name="SEC">8</division>
        <division name="HGT">71</division>
        <division name="KIU">948</division>
     </age>
     <age name="10">
        <division name="SEC">794</division>
        <division name="HGT">51</division>
        <division name="KIU">6</division>
     </age>
  </kind>
</type>
<type name="UNIT2">
  <kind name="POR">
     <age name="10">
        <division name="SEC">7</division>
        <division name="HGT">94</division>
        <division name="KIU">5</division>
     </age>
  </kind>
</type>


My xsl file should first sum all divisions, grouped by the number of days aged <age>. So, for the first table, the first row (0 - 3), records where age is between 0 and 3 should be included. For the second row, records where the age is between 4 and 5 should be included. All types are included in this first table.


The second table should include only those records where type = UNIT1. The rows will work the same (row 1 where age is between 0 and 3, etc...).

Same for the third table.

The output should be thus

ALL TYPES
AGE   DIV_TOTAL   SEC   HGT   KIU
0  3   1237           21      131     1085
4  5   460             61      316      83
6  10  957            801    145      11

TYPE UNIT1
AGE   DIV_TOTAL   SEC   HGT   KIU
0  3   210             13       60       137
4  5   460             61      316      83
6  10  957            794    51        6


TYPE UNIT2 AGE DIV_TOTAL SEC HGT KIU 0  3 0 0 0 0 4  5 0 0 0 0 6  10 106 7 94 5

I know everyone must be getting tired of grouping questions. I have read up on them and still don't get how to do them in XSLT.

Thanks in advance

Bill

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


Current Thread