Subject: RE: [xsl] Grouping problem From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Fri, 15 Feb 2008 13:17:36 -0000 |
Unfortunately your desired output is very badly formatted. I'm having trouble interpreting it. It seems to have Cs and Ds in it and I can't see where these are supposed to come from. The basic problem of creating one column for each distinct value of "due" is best handled using logic like this: <xsl:value-of select="due-values" select="distinct-values(item/due)"/> <tr> <td/> <xsl:for-each select="$due-values"> <td><xsl:value-of select="."/></td> </xsl:for-each> </tr> <xsl:for-each-group select="item" group-by="ccode"> <tr> <td><xsl:value-of select="current-grouping-key()"/></td> <xsl:for-each select="$due-values"> <td><xsl:value-of select="current-group()[@due = current()]"/></td> </xsl:for-each> </tr> Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Eugene Bernard [mailto:eugene.bernard@xxxxxxxxx] > Sent: 15 February 2008 04:01 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Fwd: > > Hi all > > Using the below XML data (Partial listing) and XSL, I am > getting the HTML output as below. > > How to make it to compact horizontally tabulated HTML output > like this (to limit the size of my mail i have removed html tags) > > HTML Output : > > Code Due Press ID Qty > --------------------------------------------- > A001 > ---------------------------------------------- > Beyond Mar > Press A 100 > Press B 219 > Feb Due > Press A 47 > Press B 365 > Mar Due > Press A 84 > Press B 256 > Over Due > Press B 2 > -------------------------------- > > HTML Output (Desired): > > CODE BEYOND MAR FEB DUE MAR DUE OVER DUE > A B C D A B C D A B C > D A B C D > A001 100 219 47 365 84 256 > 2 > > XML: > > <?xml version="1.0" ?> > - <mpour> > - <item> > <ccode>A004</ccode> > <due>Beyond Mar</due> > <line>Press A</line> > <pour>409</pour> > <weight>3476.50</weight> > </item> > - <item> > <ccode>A004</ccode> > <due>Beyond Mar</due> > <line>Press A</line> > <pour>300</pour> > <weight>2550.00</weight> > </item> > - <item> > <ccode>A004</ccode> > <due>Beyond Mar</due> > <line>Press A</line> > <pour>500</pour> > <weight>4250.00</weight> > </item> > - <item> > > XSL : > > <xsl:stylesheet version="2.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:template match="mpour"> > <table border="1" cellspacing="0" > cellpadding="4"><tr><td>Code</td><td>Due</td><td>Press > ID</td><td>Qty</td></tr> > <xsl:for-each-group select="item" group-by="ccode"> > <xsl:sort select="current-grouping-key()"/> > <tr> > <td><xsl:value-of select="ccode"/></td> > <td/> > <td/> > <td/> > </tr> > <xsl:for-each-group select="current-group()" > group-by="due"> > <xsl:sort select="current-grouping-key()"/> > <tr> > <td/> > <td><xsl:value-of select="due"/></td> > <td/> > <td/> > </tr> > <xsl:for-each-group select="current-group()" group-by="line"> > <xsl:sort select="current-grouping-key()"/> > <tr> > <td/> > <td/> > <td><xsl:value-of select="line"/></td> > <td align="right"><xsl:value-of > select="format-number(sum(current-group()/pour),'######.##')" /></td> > </tr> > </xsl:for-each-group> > </xsl:for-each-group> > </xsl:for-each-group> > </table> > </xsl:template> > </xsl:stylesheet> > > > > Regards > Eugene
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Fwd:, Eugene Bernard | Thread | [xsl] Accessing input document from, Michael Ludwig |
[xsl] Grouping Problem, Eugene Bernard | Date | RE: [xsl] Temporary tree elements a, Marroc |
Month |