W3C home > Mailing lists > Public > www-xsl-fo@w3.org > November 2002

Re: Variable number of table columns

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Thu, 14 Nov 2002 09:00:11 -0500
Message-Id: <>
To: <www-xsl-fo@w3.org>

At 2002-11-14 04:51 -0500, Eklund Anders wrote:
>I have an .xml-file with tables. The problem is that I don't know the 
>number of columns in each table.
>Then I don't know how many <fo:table-column> I need to have a proportional 
>table where all tables have the same width.

You will have to go to the effort of anticipating your column needs, 
usually by practically duplicating the algorithm for creating your columns 
but only in order to obtain a count.

Your example data was easy, in that each row of each table has the same 
number of columns, so my answer to your question looks almost too easy 
below.  But, you win if that is truly the shape of your data.  The problem 
comes when you have an arbitrary number of columns in an arbitrary number 
of rows and you want to find the largest number of columns of all the 
rows.  This is left as an exercise to the reader!

I hope this helps.

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


      <xsl:for-each select="row[1]/column">
        <fo:table-column column-width="50pt"/>

          <xsl:for-each select="row">
              <xsl:for-each select="column">
                  <fo:block><xsl:value-of select="."/></fo:block>

Upcoming hands-on in-depth XSLT/XPath and/or XSL-FO:
-                             North America:  Feb 3 - Feb 7,2003

G. Ken Holman               mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.        http://www.CraneSoftwrights.com/f/
Box 266, Kars, Ontario CANADA K0A-2E0  +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                     Definitive XSLT and XPath
ISBN 0-13-140374-5                             Definitive XSL-FO
ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
ISBN 1-894049-10-1             Practical Formatting Using XSL-FO
Next conference training:                    2002-12-08,03-03,06
Received on Thursday, 14 November 2002 09:00:23 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:58:26 UTC