XSL Table Code (repost)
David Hedley <[email protected]> Mon, 25 Apr 2005 16:04:16 +0100
| Newsgroups | gmane.text.docbook.db2latex.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------080509080601090700090909
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
(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
--------------080509080601090700090909
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<div class="moz-text-html" lang="x-western"> <br>
(Note: this is a repost. There appears to be a 40k limit on mail to
this list. Please visit <a class="moz-txt-link-freetext"
href="http://www.vistair.com/newtbl">http://www.vistair.com/newtbl</a>
for message
attachments)<br>
<br>
Fellow db2latex'ers,<br>
<div class="moz-text-html" lang="x-unicode"><br>
Please find attached my table code for db2latex which I'm releasing
under the GPL.<br>
<br>
This is a complete rewrite of the table code in XSL.<br>
<br>
Notes:<br>
<ul>
<li>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.<br>
</li>
<li>Handles row and column spanning, named column starts, missing
'entry' elements<br>
</li>
<li>Handles rowsep and colsep with inheritance</li>
<li>Handles rotated cells</li>
<li>Handles horizontal and vertical alignment (within the
capabilities of Latex tables)</li>
<li>Doesn't handle 'char' and 'charoff' attributes.</li>
<li>Doesn't support 'entrytbl' (although nested tables will work)<br>
</li>
<li>Requires 'calc' and 'multirow' packages. Note I strongly
recommend editing multirow.sty and changing \def\@xmultirow... to
\long\def\@xmultirow<br>
</li>
<li>Handles absolute and relative column widths (i.e. starred
columns, including widths of the format '5*+3in')</li>
<li>Uses the 'tabular' environment but can use other packages (e.g.
supertabular) by passing the 'tabletype' parameter.</li>
<li>The 'node-set' extension is used extensively. Your XSLT processor
must be able to support this extension (most do).</li>
<li>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.<br>
</li>
</ul>
Problems and differences from the original table code:<br>
<ul>
<li>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.</li>
<li>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:<br>
</li>
</ul>
<tt><xsl:template match="processing-instruction('strut')"><br>
<xsl:text>\rule{0pt}{</xsl:text><br>
<xsl:value-of select="."/><br>
<xsl:text>}</xsl:text><br>
</xsl:template></tt><br>
<blockquote>You can then put <tt><? strut 1.5em ?></tt> or
similar to open up problem rows.<br>
</blockquote>
Testing:<br>
<ul>
<li>Tested with xsltproc only (libxml 20619, libxslt 10114 and
libexslt 812)<br>
</li>
<li>The code passes the 18 'table' and 'informal' table tests with
docbook 4.4 with the following caveats:</li>
<ul>
<li>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.<br>
</li>
<li>informaltable test 015 fails as one of the column widths is
given as '4in*' which seems pretty meaningless to me.</li>
<li>table tests 009 and 013 don't work properly as they use
'entrytbl'</li>
<li>table test 016 fails as it uses HTML table tags.</li>
</ul>
<li>The code works fine with all 1100+ tables listed in the Airbus
Flight Crew Operating Manuals (for which they were originally developed)</li>
</ul>
<br>
Best wishes,<br>
<br>
David Hedley<br>
<br>
</div>
<br>
</div>
</body>
</html>
--------------080509080601090700090909--
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click