Discussion:
XSL Table Code (repost)
David Hedley
2005-04-25 15:04:16 UTC
Permalink
(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
David Hedley
2005-04-25 14:16:23 UTC
Permalink
(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




Scanned for viruses by MailDefender
nico
2005-04-27 22:29:53 UTC
Permalink
Post by David Hedley
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.
Wow, what a terrific piece of code! I've used it without any problem. The
only limitation I found is when an <entry> contains blank lines like this:

<entry>

This is a buggy entry, isn't it?

</entry>

Latex then complains about the multicolumn:
"{
! Paragraph ended before \multicolumn was complete.
<to be read again>
\par
l.60
\par
l.60

I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?"

I guess that it's a normal behaviour but do know if something can be done
to have this command less fragile?
Post by David Hedley
[...]
* The 'node-set' extension is used extensively. Your XSLT processor
must be able to support this extension (most do).
I was really not possible to use only pure XSL language?

Anyway, great work. Would you mind if I put your file in a future dblatex
release (not db2latex since I have no rights for this :-)? Of course I
keep your file untouched with your header. I must do some other tests, but
I think that with this implementation I can remove the table perl
dependency I have in my implementation.

Thanks,

BG


-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix
David Hedley
2005-04-28 10:33:15 UTC
Permalink
Hi Nico & others,
Post by nico
The
only limitation I found is when an <entry> contains blank
<entry>
This is a buggy entry, isn't it?
</entry>
"{
! Paragraph ended before \multicolumn was complete.
<to be read again>
\par
l.60
\par
l.60
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?"
I can't reproduce this with my setup - it handles this case fine. What could
cause this is if you're using the 'morerows' attribute and haven't tweaked
multirow.sty as advised in my original email. If you are still having
problems then please let me have your test case and let me know which
version etc of pdflatex you're using.
Post by nico
Anyway, great work. Would you mind if I put your file in a
future dblatex
release (not db2latex since I have no rights for this :-)? Of
course I
keep your file untouched with your header. I must do some
other tests, but
I think that with this implementation I can remove the table perl
dependency I have in my implementation.
No of course not. Help yourself to it.

Best wishes,

David



-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start! http://www.idcswdc.com/cgi-bin/survey?id5hix
nico
2005-04-28 20:59:09 UTC
Permalink
Post by David Hedley
Hi Nico & others,
Post by nico
The
only limitation I found is when an <entry> contains blank
<entry>
This is a buggy entry, isn't it?
</entry>
Latex then complains about the multicolumn: [...]
I can't reproduce this with my setup - it handles this case fine. What could
cause this is if you're using the 'morerows' attribute and haven't tweaked
multirow.sty as advised in my original email. If you are still having
problems then please let me have your test case and let me know which
version etc of pdflatex you're using.
I don't use the attribute 'morerows', and it really seems to come from
multicolumn. Please find attached the simple test case that shows the
behaviour I have. It contains the XSL used (main.xsl), the XML test file
(doc.xml), the LaTeX result (doc.tex), and the pdflatex compilation log
(doc.log) whose first line gives the pdflatex version.
Post by David Hedley
Post by nico
Anyway, great work. Would you mind if I put your file in a
future dblatex
release (not db2latex since I have no rights for this :-)? [...]
No of course not. Help yourself to it.
Thanks!

BG


-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix
nico
2005-04-28 21:18:53 UTC
Permalink
Sorry, I forgot the piece.

------- Forwarded message -------
From: nico <***@libertysurf.fr>
To: "db2latex-***@lists.sourceforge.net"
<db2latex-***@lists.sourceforge.net>
Subject: Re: [DB2LaTeX-devel] XSL Table Code (repost)
Date: Thu, 28 Apr 2005 22:59:09 +0200
Post by David Hedley
Hi Nico & others,
Post by nico
The
only limitation I found is when an <entry> contains blank
<entry>
This is a buggy entry, isn't it?
</entry>
Latex then complains about the multicolumn: [...]
I can't reproduce this with my setup - it handles this case fine. What could
cause this is if you're using the 'morerows' attribute and haven't tweaked
multirow.sty as advised in my original email. If you are still having
problems then please let me have your test case and let me know which
version etc of pdflatex you're using.
I don't use the attribute 'morerows', and it really seems to come from
multicolumn. Please find attached the simple test case that shows the
behaviour I have. It contains the XSL used (main.xsl), the XML test file
(doc.xml), the LaTeX result (doc.tex), and the pdflatex compilation log
(doc.log) whose first line gives the pdflatex version.
Post by David Hedley
Post by nico
Anyway, great work. Would you mind if I put your file in a
future dblatex
release (not db2latex since I have no rights for this :-)? [...]
No of course not. Help yourself to it.
Thanks!

BG


-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix
_______________________________________________
DB2LaTeX-devel mailing list
DB2LaTeX-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/db2latex-devel
--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Loading...