David Hedley
2005-04-25 15:04:16 UTC
(Note: this is a repost. There appears to be a 40k limit on mail to this
list. Please visit http://www.vistair.com/newtbl for message attachments)
Fellow db2latex'ers,
Please find attached my table code for db2latex which I'm releasing
under the GPL.
This is a complete rewrite of the table code in XSL.
Notes:
* All templates run in the 'newtbl' mode and new and old tables can
be freely interchanged. The example XSL file test.xsl uses the new
code for all informaltable elements.
* Handles row and column spanning, named column starts, missing
'entry' elements
* Handles rowsep and colsep with inheritance
* Handles rotated cells
* Handles horizontal and vertical alignment (within the capabilities
of Latex tables)
* Doesn't handle 'char' and 'charoff' attributes.
* Doesn't support 'entrytbl' (although nested tables will work)
* Requires 'calc' and 'multirow' packages. Note I strongly recommend
editing multirow.sty and changing \def\@xmultirow... to
\long\def\@xmultirow
* Handles absolute and relative column widths (i.e. starred columns,
including widths of the format '5*+3in')
* Uses the 'tabular' environment but can use other packages (e.g.
supertabular) by passing the 'tabletype' parameter.
* The 'node-set' extension is used extensively. Your XSLT processor
must be able to support this extension (most do).
* rowseps and colseps are off by default as that seems to be what
docbook's tests expect. However this isn't clear in the CALS spec.
If in doubt, always give a default rowsep and colsep attribute in
the 'tgroup' element.
Problems and differences from the original table code:
* Each table cell is effectively set inside a 'parbox'. This means
that pretty much anything can be put in a table cell without
problems, but it does mean that cell contents will line-wrap. You
should always try to set appropriate column widths.
* The 'multirow' latex package makes some assumptions about the
number of rows it's spanning. This can lead to strange spacing and
overlapping cells. There's no easy fix for this that I know of
except to use struts in the problem cells. I usually define a
processing instruction as follows:
<xsl:template match="processing-instruction('strut')">
<xsl:text>\rule{0pt}{</xsl:text>
<xsl:value-of select="."/>
<xsl:text>}</xsl:text>
</xsl:template>
You can then put <? strut 1.5em ?> or similar to open up problem rows.
Testing:
* Tested with xsltproc only (libxml 20619, libxslt 10114 and
libexslt 812)
* The code passes the 18 'table' and 'informal' table tests with
docbook 4.4 with the following caveats:
o You will need the use template for 'para' given in test.xsl
for informaltable test 017 as the standard db2latex
paragraph handling is a bit broken.
o informaltable test 015 fails as one of the column widths is
given as '4in*' which seems pretty meaningless to me.
o table tests 009 and 013 don't work properly as they use
'entrytbl'
o table test 016 fails as it uses HTML table tags.
* The code works fine with all 1100+ tables listed in the Airbus
Flight Crew Operating Manuals (for which they were originally
developed)
Best wishes,
David Hedley
list. Please visit http://www.vistair.com/newtbl for message attachments)
Fellow db2latex'ers,
Please find attached my table code for db2latex which I'm releasing
under the GPL.
This is a complete rewrite of the table code in XSL.
Notes:
* All templates run in the 'newtbl' mode and new and old tables can
be freely interchanged. The example XSL file test.xsl uses the new
code for all informaltable elements.
* Handles row and column spanning, named column starts, missing
'entry' elements
* Handles rowsep and colsep with inheritance
* Handles rotated cells
* Handles horizontal and vertical alignment (within the capabilities
of Latex tables)
* Doesn't handle 'char' and 'charoff' attributes.
* Doesn't support 'entrytbl' (although nested tables will work)
* Requires 'calc' and 'multirow' packages. Note I strongly recommend
editing multirow.sty and changing \def\@xmultirow... to
\long\def\@xmultirow
* Handles absolute and relative column widths (i.e. starred columns,
including widths of the format '5*+3in')
* Uses the 'tabular' environment but can use other packages (e.g.
supertabular) by passing the 'tabletype' parameter.
* The 'node-set' extension is used extensively. Your XSLT processor
must be able to support this extension (most do).
* rowseps and colseps are off by default as that seems to be what
docbook's tests expect. However this isn't clear in the CALS spec.
If in doubt, always give a default rowsep and colsep attribute in
the 'tgroup' element.
Problems and differences from the original table code:
* Each table cell is effectively set inside a 'parbox'. This means
that pretty much anything can be put in a table cell without
problems, but it does mean that cell contents will line-wrap. You
should always try to set appropriate column widths.
* The 'multirow' latex package makes some assumptions about the
number of rows it's spanning. This can lead to strange spacing and
overlapping cells. There's no easy fix for this that I know of
except to use struts in the problem cells. I usually define a
processing instruction as follows:
<xsl:template match="processing-instruction('strut')">
<xsl:text>\rule{0pt}{</xsl:text>
<xsl:value-of select="."/>
<xsl:text>}</xsl:text>
</xsl:template>
You can then put <? strut 1.5em ?> or similar to open up problem rows.
Testing:
* Tested with xsltproc only (libxml 20619, libxslt 10114 and
libexslt 812)
* The code passes the 18 'table' and 'informal' table tests with
docbook 4.4 with the following caveats:
o You will need the use template for 'para' given in test.xsl
for informaltable test 017 as the standard db2latex
paragraph handling is a bit broken.
o informaltable test 015 fails as one of the column widths is
given as '4in*' which seems pretty meaningless to me.
o table tests 009 and 013 don't work properly as they use
'entrytbl'
o table test 016 fails as it uses HTML table tags.
* The code works fine with all 1100+ tables listed in the Airbus
Flight Crew Operating Manuals (for which they were originally
developed)
Best wishes,
David Hedley