RE: [xsl] Grouping by Node & Node Attributr

Subject: RE: [xsl] Grouping by Node & Node Attributr
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 30 Oct 2006 08:24:34 -0000
It's a standard grouping problem, read up on grouping at

http://www.jenitennison.com/xslt/grouping

It's much easier if you can switch to XSLT 2.0.

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: jeb501@xxxxxxxxxxxxxxx [mailto:jeb501@xxxxxxxxxxxxxxx]
> Sent: 30 October 2006 06:32
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Grouping by Node & Node Attributr
>
>
>
>
>
> Hi all,
>
> WIth following XML & XSL files, after transformation i get an html
>
> file as below.
>
> XML :
>
>   <?xml version="1.0" ?>
>     + <sum>
>       - <record>
>           <mon cat="OT">Sep2005</mon>
>           <qty>3.00</qty>
>           <weight>15.66000</weight>
>       </record>
>       - <record>
>           <mon cat="1X">Sep2005</mon>
>           <qty>12.00</qty>
>           <weight>36.12000</weight>
>       </record>
>       - <record>
>           <mon cat="OT">Sep2005</mon>
>           <qty>2.00</qty>
>           <weight>39.90000</weight>
>       </record>
>       - <record>
>           <mon cat="1X">Sep2005</mon>
>           <qty>16.00</qty>
>           <weight>7.05600</weight>
>       </record>
>       - <record>
>           <mon cat="1X">Sep2005</mon>
>           <qty>32.00</qty>
>           <weight>12.48000</weight>
>       </record>
>     </sum>
>
>
>   XSL :
>
>   <?xml version="1.0" encoding="ISO-8859-1" ?>
>     - <xsl:stylesheet version="1.0" xmlns:xsl="
>     http://www.w3.org/1999/XSL/Transform";>
>       - <xsl:template match="/">
>         - <html>
>           - <body>
>             - <table border="1" cellpadding="4" cellspacing="0">
>               - <tr bgcolor="#9acd32">
>                   <th rowspan="2">Month</th>
>                   <th rowspan="2">Cat</th>
>                   <th colspan="2">P Qty</th>
>               </tr>
>               - <tr bgcolor="#9acd32">
>                   <th>Qty</th>
>                   <th>Value</th>
>               </tr>
>               - <xsl:for-each select="sum/record">
>                 - <tr>
>                   - <td>
>                       <xsl:value-of select="mon" />
>                   </td>
>                   - <td>
>                       <xsl:value-of select="mon/@cat" />
>                   </td>
>                   - <td align="right">
>                       <xsl:value-of select="qty" />
>                   </td>
>                   - <td align="right">
>                       <xsl:value-of select="weight" />
>                   </td>
>                 </tr>
>               </xsl:for-each>
>             </table>
>           </body>
>         </html>
>       </xsl:template>
>     </xsl:stylesheet>
>
>   HTML actual Output :

Current Thread