You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Jens Posingies <je...@posingies.com> on 2002/05/16 16:40:35 UTC

Newbie: html-like table to fo-table

Hi folks,

again we need your help: We are using FOP and XSLT for creating pdf
documents which works fine - excepting tables! The dtd contains a table-tag
like similar to html:
[...]
<!ENTITY % alignes "
	align (left | center | right) #IMPLIED
	valign (top | middle | bottom | baseline) #IMPLIED
">
<!ENTITY % alignes_span "
	%alignes;
	rowspan NMTOKEN '1'
	colspan NMTOKEN '1'
">
[...]
<!ELEMENT table (title?, thead?, tbody+, tfoot?)>
<!ATTLIST table
	%id_req;
	width CDATA #IMPLIED
	summary CDATA #IMPLIED
	cellspacing CDATA #IMPLIED
	cellpadding CDATA #IMPLIED
>
<!ELEMENT thead (tr)+>
<!ATTLIST thead
	%id_imp;
	%alignes;
>
<!ELEMENT tfoot (tr)+>
<!ATTLIST tfoot
	%id_imp;
	%alignes;
>
<!ELEMENT tbody (tr)+>
<!ATTLIST tbody
	%id_imp;
	%alignes;
>
<!ELEMENT tr (th | td)+>
<!ATTLIST tr
	%id_imp;
	%alignes;
>
<!ELEMENT th (%outer;)*>
<!ATTLIST th
	%id_imp;
	%alignes_span;
>
<!ELEMENT td (%outer;)*>
<!ATTLIST td
	%id_imp;
	%alignes_span;
>
[...]
Transforming into html with xslt was no problem as expected, but how could a
template look like in fo (a bit heavy for newbies because of counting
columns etc.)? The fo:table-markups are a bit confusing, and some of them
don't seem to work as expected in the current FOP-version (like
table-and-caption). Who has experiences with fo:tables and xslt and could
give us a hint?

Jens Posingies

_______________________________________

    **** COMMODORE 64 BASIC V2 ****

64K RAM SYSTEM  38911 BASIC BYTES FREE

READY.
_
_______________________________________


Re: Newbie: html-like table to fo-table

Posted by Lee Goddard <ho...@LeeGoddard.com>.
At 09:00 16/05/2002 -0700, Chuck Paussa wrote:
>Jens
>
>Here's my partial 2 minute solution untested
>(a hint Take a look at the spec here 
>http://zvon.org/xxl/xslfoReference/Output/index.html )

Do make sure you put in good HTML, of course, with all
the optional size attributes included. I think you'll have to
have them absolute, atm, too.

lee






Re: Newbie: html-like table to fo-table

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Chuck Paussa wrote:
>        <xsl:variable name="numcolumns" select="count(./tbody/tr/*)"/>

This will count all cells in the whole table body. If all
rows have the same number of cells, and never use colspan
nor rowspan,
  select="count(tbody/tr[1]/*)
should work (the "./" is redundant).
If rowspans/colspans are present, a general solution appears to
be hard. Norman Walsh himself asked for this on the XSL list.
His docbook-xsl, available at
  http://sourceforge.net/projects/docbook/
contains a module for translating CALS tables to HTML and FO.
I haven't checked whether the span related issues has been
resolved.
One problem is that the docbook-xsl style sheets create
fo:table-and-caption FO, which are not implemented in FOP,
and usually create auto layout tables, without preset column
widths, which are needed by FOP. Unfortunately, even proportional
column widths, which can be implemented in FOP using the
proportional-column-width() function, are generated by docbook-xsl
as NN% mesurements. Too bad. Some people have said on this list
that trivial hacking of the style sheets got them around these
problems.

HTH
J.Pietschmann


Re: Newbie: html-like table to fo-table

Posted by Chuck Paussa <Ch...@systems.dhl.com>.
Jens

Here's my partial 2 minute solution untested
(a hint Take a look at the spec here 
http://zvon.org/xxl/xslfoReference/Output/index.html )

<xsl:template match="table">
    <fo:table>
        <xsl:attribute name="border-separation" 
select="./@cellspacing"/> <!-- Not so sure about this one -->
        <xsl:attribute name="padding" select="./cellpadding"/>
        <xsl:variable name="numcolumns" select="count(./tbody/tr/*)"/>
        <xsl:for-each select="./tbody/tr/*">
            <fo:table-column>
                <xsl:attribute name="column-width" select="./@width div 
$numcolumns"/>
            </fo:table-column
            <fo:table-header>
                etc. etc.
        <xsl:for-each
 </xsl:template>

Chuck Paussa

Jens Posingies wrote:

>Hi folks,
>
>again we need your help: We are using FOP and XSLT for creating pdf
>documents which works fine - excepting tables! The dtd contains a table-tag
>like similar to html:
>[...]
><!ENTITY % alignes "
>	align (left | center | right) #IMPLIED
>	valign (top | middle | bottom | baseline) #IMPLIED
>">
><!ENTITY % alignes_span "
>	%alignes;
>	rowspan NMTOKEN '1'
>	colspan NMTOKEN '1'
>">
>[...]
><!ELEMENT table (title?, thead?, tbody+, tfoot?)>
><!ATTLIST table
>	%id_req;
>	width CDATA #IMPLIED
>	summary CDATA #IMPLIED
>	cellspacing CDATA #IMPLIED
>	cellpadding CDATA #IMPLIED
>  
>
><!ELEMENT thead (tr)+>
><!ATTLIST thead
>	%id_imp;
>	%alignes;
>  
>
><!ELEMENT tfoot (tr)+>
><!ATTLIST tfoot
>	%id_imp;
>	%alignes;
>  
>
><!ELEMENT tbody (tr)+>
><!ATTLIST tbody
>	%id_imp;
>	%alignes;
>  
>
><!ELEMENT tr (th | td)+>
><!ATTLIST tr
>	%id_imp;
>	%alignes;
>  
>
><!ELEMENT th (%outer;)*>
><!ATTLIST th
>	%id_imp;
>	%alignes_span;
>  
>
><!ELEMENT td (%outer;)*>
><!ATTLIST td
>	%id_imp;
>	%alignes_span;
>  
>
>[...]
>Transforming into html with xslt was no problem as expected, but how could a
>template look like in fo (a bit heavy for newbies because of counting
>columns etc.)? The fo:table-markups are a bit confusing, and some of them
>don't seem to work as expected in the current FOP-version (like
>table-and-caption). Who has experiences with fo:tables and xslt and could
>give us a hint?
>
>Jens Posingies
>
>_______________________________________
>
>    **** COMMODORE 64 BASIC V2 ****
>
>64K RAM SYSTEM  38911 BASIC BYTES FREE
>
>READY.
>_
>_______________________________________
>
>  
>




Re: Newbie: html-like table to fo-table

Posted by Lee Goddard <ho...@LeeGoddard.com>.
>  Who has experiences with fo:tables and xslt and could
>give us a hint?

It took me a month to get something passable using Perl
and XSL:FO, and I can't really it to you as I sold the copyright.
But: there is a very good tutorial on the site of another FOP...
www.renderx.com

>     **** COMMODORE 64 BASIC V2 ****

Then you may recognise my sig from the VIC-20 manual!
Always wanted a C64...


Lee Goddard
perl -e "while(1){print rand>0.5?chr 47:chr 92}"