[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Grouping elements in table using xsl:fo

Subject: RE: Grouping elements in table using xsl:fo
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 16 Jun 2004 17:46:37 +0100
table td grouping
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.

eg.

                                A   C   D   E
                   gg1
                                ff  hh  ii  jj
                                pp  qq  rr  ss
                        gg2
                                kk  ll  mm  nn
                                ff  hh  ii  jj
                        gg3
                        tt  uu  vv  ww

I hope this helps.


............................. Ken


T:\ftemp>type james.xml <x> <y> <z> <A>ff</A> <B>gg1</B> <C>hh</C> <D>ii</D> <E>jj</E> </z> </y> <y> <z> <A>kk</A> <B>gg2</B> <C>ll</C> <D>mm</D> <E>nn</E> </z> </y> <y> <z> <A>tt</A> <B>gg3</B> <C>uu</C> <D>vv</D> <E>ww</E> </z> </y> <y> <z> <A>pp</A> <B>gg1</B> <C>qq</C> <D>rr</D> <E>ss</E> </z> </y> <y> <z> <A>ff</A> <B>gg2</B> <C>hh</C> <D>ii</D> <E>jj</E> </z> </y> </x>

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.