[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Grouping elements in table using xsl:fo
At 2004-06-15 14:55 +0100, James Steven wrote:
The main aspect I am having trouble with is getting each unique <B> on a separate row in the table with each <z> grouped under the relevant <B>. I can only get each <B> on the same row and so cannot group under these. Below is a working version using the Muenchian Method, just change the HTML table constructs to XSL-FO. You'll see the structure as you requested: At 2004-06-15 12:15 +0100, James Steven wrote: I would like to create a row for each <z> in a table grouped by the value of <B>. For each different value of <B> there would be a heading and on the rows below each heading each <z> which has the same <B> value. I hope this helps. ............................. Ken
T:\ftemp>type james.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output indent="yes"/> <xsl:key name="entries" match="z" use="B"/> <xsl:template match="/"> <table border="1"> <tr> <td></td><td>A</td><td>C</td><td>D</td><td>E</td> </tr> <xsl:for-each select="/x/y/z[generate-id(.)= generate-id(key('entries',B))]"> <tr><td><xsl:value-of select="B"/></td></tr> <xsl:for-each select="key('entries',B)"> <tr> <td></td> <td><xsl:value-of select="A"/></td> <td><xsl:value-of select="C"/></td> <td><xsl:value-of select="D"/></td> <td><xsl:value-of select="E"/></td> </tr> </xsl:for-each> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> T:\ftemp>saxon -o james.htm james.xml james.xsl T:\ftemp>type james.htm <?xml version="1.0" encoding="utf-8"?> <table border="1"> <tr> <td/> <td>A</td> <td>C</td> <td>D</td> <td>E</td> </tr> <tr> <td>gg1</td> </tr> <tr> <td/> <td>ff</td> <td>hh</td> <td>ii</td> <td>jj</td> </tr> <tr> <td/> <td>pp</td> <td>qq</td> <td>rr</td> <td>ss</td> </tr> <tr> <td>gg2</td> </tr> <tr> <td/> <td>kk</td> <td>ll</td> <td>mm</td> <td>nn</td> </tr> <tr> <td/> <td>ff</td> <td>hh</td> <td>ii</td> <td>jj</td> </tr> <tr> <td>gg3</td> </tr> <tr> <td/> <td>tt</td> <td>uu</td> <td>vv</td> <td>ww</td> </tr> </table> -- Public training 3 days XSLT & 2 days XSL-FO: Phoenix,AZ 2004-08-23 World-wide on-site corporate, govt. & user group XML/XSL training. G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|