Subject: [xsl] patial sums From: "Vrajitoru" <vrajitoru@xxxxxxxx> Date: Fri, 12 Apr 2002 09:00:06 +0200 |
I have an XML like this: <?xml version='1.0' ?> <?xml-stylesheet type='text/xsl' href='raport.xsl'?><data> <row Cod='212' Denumire='VINZARI CATRE ALTE UNITATI' Document='FACTURA' Numar='12358' Data='2000-10-19' Furnizor='32802' Comanda='X' Valoare='757900.0'/> <row Cod='212' Denumire='VINZARI CATRE ALTE UNITATI' Document='FACTURA' Numar='12710' Data='2000-10-24' Furnizor='4560' Comanda='X' Valoare='76191050.0'/> <row Cod='212' Denumire='VINZARI CATRE ALTE UNITATI' Document='FACTURA' Numar='12881' Data='2000-10-25' Furnizor='43049' Comanda='X' Valoare='1277790.0'/> .... </data> and in the following XSL I want to display partial sums on the attribute "Valoare" after each grouping. I am new in XML and I tried everything I knew but it doesn't work. It is possible? and if yes, how? Thaks. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:key name="kgrp1" match="@Document" use="."/> <xsl:key name="kgrp2" match="@Cod" use="../@Document"/> <xsl:key name="skgrp2" match="@Cod" use="concat(.,'::',../@Document)"/> <xsl:key name="kgrp3" match="@Data" use="concat(../@Document,'::',../@Cod)"/> <xsl:key name="skgrp3" match="@Data" use="concat(.,'::',../@Document,'::',../@Cod)"/> <xsl:key name="kgrp4" match="@Furnizor" use="concat(../@Document,'::',../@Cod,'::',../@Data)"/> <xsl:key name="skgrp4" match="@Furnizor" use="concat(.,'::',../@Document,'::',../@Cod,'::',../@Data)"/> <xsl:key name="kcomb" match="row" use="concat(@Document,'::',@Cod,'::',@Data,'::',@Furnizor)"/> <xsl:template match="/"> <table border="0" width="100%"> <xsl:for-each select="/data/row/@Document[generate-id(.)=generate-id(key('kgrp1',.)[1])]"> <xsl:sort select="@Document" order="ascending"/> <xsl:variable name="valgrp1" select="string(.)"/> <tr><td> <h2><xsl:value-of select="$valgrp1"/></h2> <table border="0" width="100%"> <xsl:for-each select="key('kgrp2',$valgrp1)[generate-id(.)= generate-id(key('skgrp2',concat(.,'::',$valgrp1))[1])]"> <xsl:sort select="@Cod"/> <tr><td> <xsl:variable name="valgrp2" select="string(.)"/> <h3><br></br><xsl:value-of select="$valgrp2"/> - <xsl:value-of select="@Denumire"/></h3> <table border="0" width="100%" cellpadding='0' cellspacing='0'> <xsl:for-each select="key('kgrp3',concat($valgrp1,'::',$valgrp2))[generate-id(.)= generate-id(key('skgrp3',concat(.,'::',$valgrp1,'::',$valgrp2))[1])]"> <tr><td> <xsl:variable name="valgrp3" select="string(.)"/> <h4><br></br>Data: <xsl:value-of select="$valgrp3"/></h4> <table border="0" width="100%" cellpadding='0' cellspacing='0'> <xsl:for-each select="key('kgrp4',concat($valgrp1,'::',$valgrp2,'::',$valgrp3))[generate-i d(.)= generate-id(key('skgrp4',concat(.,'::',$valgrp1,'::',$valgrp2,'::',$valgrp3) )[1])]"> <tr><td> <xsl:variable name="valgrp4" select="string(.)"/> <h5><br></br>Furnizor: <xsl:value-of select="$valgrp4"/></h5> <table border="1" width="100%" cellpadding='0' cellspacing='0'> <xsl:for-each select="key('kcomb',concat($valgrp1,'::',$valgrp2,'::',$valgrp3,'::',$valgrp 4))"> <xsl:sort select="@Numar" data-type="number"/> <tr> <td valign='Top' align='Left'><xsl:value-of select='@Numar'/></td> <td valign='Top' align='Left'><xsl:value-of select='@Data'/></td> <td valign='Top' align='Left'><xsl:value-of select='@Furnizor'/></td> <td valign='Top' align='Left'><xsl:value-of select='@Comanda'/></td> <td valign='Top' align='Right'><xsl:value-of select='@Valoare'/></td> </tr> </xsl:for-each> </table> </td></tr> </xsl:for-each> </table> </td></tr> </xsl:for-each> </table> </td></tr> </xsl:for-each> </table> </td></tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Query regarding XSL varia, Matt Gushee | Thread | Re: [xsl] patial sums, Matt Gushee |
Re: [xsl] patial sums, Matt Gushee | Date | [xsl] Re: Re: patial sums, Dimitre Novatchev |
Month |