Discussion:
table vertical spans and page breaks
(too old to reply)
Marcel Tromp
2008-11-06 09:17:16 UTC
Permalink
Hi,

I have a long table in which certain columns contain a large vertical
span (using morerows attribute).

When printing to pdf with fop, fop page breaks this large vertical cell
at an arbitrary place.

I have been trying to control this using the 'keep-together' directive,
but I see no effect.

What is the best way to make sure fop will only break a table at the end
of cell that spans multiple rows?

Thanks,

Marcel
--
Vincent Hennebert
2008-11-06 12:46:21 UTC
Permalink
Hi Marcel,
Post by Marcel Tromp
Hi,
I have a long table in which certain columns contain a large vertical
span (using morerows attribute).
When printing to pdf with fop, fop page breaks this large vertical cell
at an arbitrary place.
I have been trying to control this using the 'keep-together' directive,
but I see no effect.
What is the best way to make sure fop will only break a table at the end
of cell that spans multiple rows?
keep-together set on the spanning cell should work. Which version of FOP
are you using?
Post by Marcel Tromp
Thanks,
Marcel
Vincent
Marcel Tromp
2008-11-07 08:44:42 UTC
Permalink
Hi,

I am using fop 0.95. I am using code similar to this example:

I've tried using this dbfo at different location as well (row, start of
table) and I don't see any difference: fop breaks the table in the
middle of a cell that straddles multiple rows.

<tbody>
<row>
<entry>
<para>foo</para>
</entry>
<entry>
<para>foo</para>
</entry>
<entry morerows="19">
<?dbfo keep-together="always"?>
<para></para>
</entry>

What I am trying to do is to have a long (500 row) narrow, sorted table
be printed three columns per page. I want to use the straddled cell to
control page breaks:

page 1:
1 6 11
2 7 12
3 8 13
4 9 14
5 10 15

page 2:
16 21 26
17 22 27
18 23 28
19 24 29
20 25 30

page 3:
etc.

Marcel
--
Post by Vincent Hennebert
Hi Marcel,
Post by Marcel Tromp
Hi,
I have a long table in which certain columns contain a large vertical
span (using morerows attribute).
When printing to pdf with fop, fop page breaks this large vertical
cell at an arbitrary place.
I have been trying to control this using the 'keep-together'
directive, but I see no effect.
What is the best way to make sure fop will only break a table at the
end of cell that spans multiple rows?
keep-together set on the spanning cell should work. Which version of FOP
are you using?
Post by Marcel Tromp
Thanks,
Marcel
Vincent
---------------------------------------------------------------------
Vincent Hennebert
2008-11-07 11:28:37 UTC
Permalink
Hi,
Post by Marcel Tromp
Hi,
I've tried using this dbfo at different location as well (row, start of
table) and I don't see any difference: fop breaks the table in the
middle of a cell that straddles multiple rows.
<tbody>
<row>
<entry>
<para>foo</para>
</entry>
<entry>
<para>foo</para>
</entry>
<entry morerows="19">
<?dbfo keep-together="always"?>
<para></para>
</entry>
This processing instruction only applies to formal object (table,
example, figure, equation), not to other elements [1].
[1] http://docbook.sourceforge.net/release/xsl/current/doc/pi/dbfo_keep-together.html

You will have to customize the template matching <entry> and add
a keep-together.within-column="always" to the produced fo:table-cell
element. As to how to do that...
Post by Marcel Tromp
What I am trying to do is to have a long (500 row) narrow, sorted table
be printed three columns per page. I want to use the straddled cell to
1 6 11
2 7 12
3 8 13
4 9 14
5 10 15
16 21 26
17 22 27
18 23 28
19 24 29
20 25 30
etc.
I’m not sure this is the best way to achieve that. The source DocBook
file should remain output-agnostic; by adding a row-spanning entry
element you’re somehow abusing its semantics.
A more proper way would be to customize the XSLT stylesheets so as to
put a keep-together.within-column plus keep-with-next.within-column on
every row, except every n-th row. Of course that requires some XSLT
knowledge.


HTH,
Vincent
Bob Stayton
2008-11-07 16:59:00 UTC
Permalink
Hi,
It isn't necessary to customize the template with match="entry" to add the
keep-together properties, as there is a utility template named
"table.cell.properties" that can accomplish that. This is a template, not
an attribute-set, and is described in this section of my book:

http://www.sagehill.net/docbookxsl/PrintTableStyles.html#table.cell.properties

Just add this to the customized template:

<xsl:attribute name="keep-together.within-column">always</xsl:attribute>

Bob Stayton
Sagehill Enterprises
***@sagehill.net


----- Original Message -----
From: "Vincent Hennebert" <***@gmail.com>
To: <docbook-***@lists.oasis-open.org>
Sent: Friday, November 07, 2008 3:28 AM
Subject: Re: [docbook-apps] table vertical spans and page breaks
Post by Vincent Hennebert
Hi,
Post by Marcel Tromp
Hi,
I've tried using this dbfo at different location as well (row, start of
table) and I don't see any difference: fop breaks the table in the middle
of a cell that straddles multiple rows.
<tbody>
<row>
<entry>
<para>foo</para>
</entry>
<entry>
<para>foo</para>
</entry>
<entry morerows="19">
<?dbfo keep-together="always"?>
<para></para>
</entry>
This processing instruction only applies to formal object (table,
example, figure, equation), not to other elements [1].
[1]
http://docbook.sourceforge.net/release/xsl/current/doc/pi/dbfo_keep-together.html
You will have to customize the template matching <entry> and add
a keep-together.within-column="always" to the produced fo:table-cell
element. As to how to do that...
Post by Marcel Tromp
What I am trying to do is to have a long (500 row) narrow, sorted table
be printed three columns per page. I want to use the straddled cell to
1 6 11
2 7 12
3 8 13
4 9 14
5 10 15
16 21 26
17 22 27
18 23 28
19 24 29
20 25 30
etc.
I’m not sure this is the best way to achieve that. The source DocBook
file should remain output-agnostic; by adding a row-spanning entry
element you’re somehow abusing its semantics.
A more proper way would be to customize the XSLT stylesheets so as to
put a keep-together.within-column plus keep-with-next.within-column on
every row, except every n-th row. Of course that requires some XSLT
knowledge.
HTH,
Vincent
---------------------------------------------------------------------
Marcel Tromp
2008-11-08 07:18:48 UTC
Permalink
I tried adding this, but it doesn't seem to work with fop 0.95: it still
breaks in the middle of a straddled cell.

I also tried to do the same thing on table.row.properties and this
didn't work either.

Marcel
--
Post by Bob Stayton
Hi,
It isn't necessary to customize the template with match="entry" to add
the keep-together properties, as there is a utility template named
"table.cell.properties" that can accomplish that. This is a template,
http://www.sagehill.net/docbookxsl/PrintTableStyles.html#table.cell.properties
<xsl:attribute name="keep-together.within-column">always</xsl:attribute>
Bob Stayton
Sagehill Enterprises
Marcel Tromp
2008-11-08 09:20:07 UTC
Permalink
I ended up fixing this by embedding tables in a table.

Marcel
--
Post by Marcel Tromp
I tried adding this, but it doesn't seem to work with fop 0.95: it still
breaks in the middle of a straddled cell.
I also tried to do the same thing on table.row.properties and this
didn't work either.
Marcel
--
Post by Bob Stayton
Hi,
It isn't necessary to customize the template with match="entry" to add
the keep-together properties, as there is a utility template named
"table.cell.properties" that can accomplish that. This is a template,
http://www.sagehill.net/docbookxsl/PrintTableStyles.html#table.cell.properties
<xsl:attribute name="keep-together.within-column">always</xsl:attribute>
Bob Stayton
Sagehill Enterprises
---------------------------------------------------------------------
Bob Stayton
2008-11-11 18:29:53 UTC
Permalink
OK, I checked this out, and it seems that FOP 0.95 knows how to keep an
ordinary table cell together, but it does not know how to keep a cell
together if it spans down to additional rows. That should probably be
reported as a bug on FOP, because it should work for spanned cells too.

Bob Stayton
Sagehill Enterprises
***@sagehill.net


----- Original Message -----
From: "Marcel Tromp" <***@tromp.org>
Cc: <docbook-***@lists.oasis-open.org>
Sent: Saturday, November 08, 2008 1:20 AM
Subject: Re: [docbook-apps] table vertical spans and page breaks
Post by Marcel Tromp
I ended up fixing this by embedding tables in a table.
Marcel
--
Post by Marcel Tromp
I tried adding this, but it doesn't seem to work with fop 0.95: it still
breaks in the middle of a straddled cell.
I also tried to do the same thing on table.row.properties and this didn't
work either.
Marcel
--
Post by Bob Stayton
Hi,
It isn't necessary to customize the template with match="entry" to add
the keep-together properties, as there is a utility template named
"table.cell.properties" that can accomplish that. This is a template,
http://www.sagehill.net/docbookxsl/PrintTableStyles.html#table.cell.properties
<xsl:attribute name="keep-together.within-column">always</xsl:attribute>
Bob Stayton
Sagehill Enterprises
---------------------------------------------------------------------
---------------------------------------------------------------------
Vincent Hennebert
2008-11-12 11:23:54 UTC
Permalink
Hi,
Post by Bob Stayton
OK, I checked this out, and it seems that FOP 0.95 knows how to keep an
ordinary table cell together, but it does not know how to keep a cell
together if it spans down to additional rows. That should probably be
reported as a bug on FOP, because it should work for spanned cells too.
I think FOP is correct with respect to the XSL-FO specification. This is
a corner case here, that’s not well described by the spec and does
certainly not match common sense.

Actually the keep-together property does not apply to the fo:table-cell
element. It does apply to the block children of a table cell, though,
and that should work properly in FOP even with row-spanning cells.
However, if the cell is not filled with its content (if there is some
empty space left at the bottom of the cell), then it’s perfectly
acceptable to break there:
_______________________
| | |
| cell 1.1 | content of | \
|__________| a row- | |_ This will remain
| | spanning | | together on a page
| cell 2.1 | cell | /
|__________| |

<----- Page break ------>
__________
| | |
| cell 3.1 | |
|__________|____________|


The only solution, to my knowledge, to properly handle this is to set
keep-together on every row spanned by the cell, plus keep-with-next on
every row but the last one.

It might also be possible to put a block with keep-together inside the
spanning cell, and as its children as many blocks containing
non-breaking spaces as necessary to fill the cell:
<fo:block keep-together.within-column="always">
<fo:block>&#160;</fo:block>
<fo:block>&#160;</fo:block>
<fo:block>&#160;</fo:block>
...
</fo:block>
But obviously the number of blocks will depend on the content of the
other cells, which will make the thing tricky to implement.

<snip/>

Vincent
Bob Stayton
2008-11-12 20:00:11 UTC
Permalink
Hi,
This is very interesting. I did not know that keep-together is not a
property that acts on fo:table-cell, but that is indeed what the spec says.
My experience has been that in both XEP and Antenna House, putting that
property on fo:table-cell will keep the cell together regardless of its
spans or content (or lack thereof).

The spec does say that the keep-together property is inherited, so the
fo:block that DocBook XSL wraps the cell content in will inherit the
keep-together. So regardless of how many rows that cell spans, its actual
content in the fo:block will be kept together. As you say, if that block
doesn't fill the cell, there is nothing in the spec that prevents the cell
itself from being broken below the block.

Do you know if the following solution works in FOP 0.95?
Post by Vincent Hennebert
The only solution, to my knowledge, to properly handle this is to set
keep-together on every row spanned by the cell, plus keep-with-next on
every row but the last one.
This might be feasible in the DocBook XSL stylesheet because of the way it
keeps track of vertical spans when processing rows.

Bob Stayton
Sagehill Enterprises
***@sagehill.net


----- Original Message -----
From: "Vincent Hennebert" <***@gmail.com>
To: <docbook-***@lists.oasis-open.org>
Sent: Wednesday, November 12, 2008 3:23 AM
Subject: Re: [docbook-apps] table vertical spans and page breaks
Post by Vincent Hennebert
Hi,
Post by Bob Stayton
OK, I checked this out, and it seems that FOP 0.95 knows how to keep an
ordinary table cell together, but it does not know how to keep a cell
together if it spans down to additional rows. That should probably be
reported as a bug on FOP, because it should work for spanned cells too.
I think FOP is correct with respect to the XSL-FO specification. This is
a corner case here, that’s not well described by the spec and does
certainly not match common sense.
Actually the keep-together property does not apply to the fo:table-cell
element. It does apply to the block children of a table cell, though,
and that should work properly in FOP even with row-spanning cells.
However, if the cell is not filled with its content (if there is some
empty space left at the bottom of the cell), then it’s perfectly
_______________________
| | |
| cell 1.1 | content of | \
|__________| a row- | |_ This will remain
| | spanning | | together on a page
| cell 2.1 | cell | /
|__________| |
<----- Page break ------>
__________
| | |
| cell 3.1 | |
|__________|____________|
The only solution, to my knowledge, to properly handle this is to set
keep-together on every row spanned by the cell, plus keep-with-next on
every row but the last one.
It might also be possible to put a block with keep-together inside the
spanning cell, and as its children as many blocks containing
<fo:block keep-together.within-column="always">
<fo:block>&#160;</fo:block>
<fo:block>&#160;</fo:block>
<fo:block>&#160;</fo:block>
...
</fo:block>
But obviously the number of blocks will depend on the content of the
other cells, which will make the thing tricky to implement.
<snip/>
Vincent
---------------------------------------------------------------------
Vincent Hennebert
2008-11-13 10:11:40 UTC
Permalink
Hi Bob,
Post by Bob Stayton
Hi,
This is very interesting. I did not know that keep-together is not a
property that acts on fo:table-cell, but that is indeed what the spec
says. My experience has been that in both XEP and Antenna House, putting
that property on fo:table-cell will keep the cell together regardless of
its spans or content (or lack thereof).
I guess a similar extension could be implemented in FOP. If anyone wants
to file a RFE:
https://issues.apache.org/bugzilla/enter_bug.cgi?product=Fop
;-)
Post by Bob Stayton
The spec does say that the keep-together property is inherited, so the
fo:block that DocBook XSL wraps the cell content in will inherit the
keep-together. So regardless of how many rows that cell spans, its
actual content in the fo:block will be kept together. As you say, if
that block doesn't fill the cell, there is nothing in the spec that
prevents the cell itself from being broken below the block.
Do you know if the following solution works in FOP 0.95?
Yes it does. Keeps and breaks should now be fully supported on every
table element to which they apply (except the general limitation that
only the "always" value is supported for keeps).
Post by Bob Stayton
Post by Vincent Hennebert
The only solution, to my knowledge, to properly handle this is to set
keep-together on every row spanned by the cell, plus keep-with-next on
every row but the last one.
This might be feasible in the DocBook XSL stylesheet because of the way
it keeps track of vertical spans when processing rows.
That would be great!


Thanks,
Vincent

Continue reading on narkive:
Loading...