Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an alternative to "keep-together='always'" on table-row?

Upon finding the "keep-together" attribute, and needing to not page break inside a row I added keep-together="always" on every table-row element in my xslt. Is there a nicer way of achieving the same effect? It seems a bit hacky. (ps. I will accept "no" as an answer if no one provides a better one, provided some kind of explanation is proffered.)

like image 801
Sean Avatar asked Dec 18 '12 11:12

Sean


4 Answers

I have used the following three methods to keep table rows together with some success:

Keep whole block together

<tr keep-together.within-page="always">
...
</tr>

Keep adjacent blocks together

<tr keep-with-next.within-page="always">
    <td keep-together.within-page="always">...</td>
    ...
</tr>
<tr>...</tr>

<tr>...</tr>
<tr keep-with-previous.within-page="always">
    <td keep-together.within-page="always">...</td>
    ...
</tr>

Though you have to be careful - if the row or cell would span more than one page of a generated document, you will loose the bottom of that page off the bottom!

like image 85
Ruskin Avatar answered Oct 27 '22 01:10

Ruskin


keep-together="always" is dangerous because that's a compound property that also indirectly sets keep-together.within-line="always" (prohibiting line breaks inside a table-cell). You should use keep-together.within-column="always" instead. But specifying that on a table-row is actually the way to go. Nothing hacky about it.

See also: http://www.w3.org/TR/xsl11/#datatype

like image 34
Jeremias Märki Avatar answered Oct 26 '22 23:10

Jeremias Märki


This answer solved my problem of a table row that was flowing over a page break when i needed to lock the table together. i used the <fo:table keep-together="always"></fo:table> Thanks.

like image 33
Alistair Lindsay-Macfadyen Avatar answered Oct 27 '22 01:10

Alistair Lindsay-Macfadyen


With an XSL formatter that handles integer keeps, you can use an integer value so that the formatter will try to keep the row together but will break the row rather than run off the end of the page. However, this question is tagged for FOP, and FOP's compliance page currently states that it has limited support for integer keeps (http://xmlgraphics.apache.org/fop/compliance.html#fo-property-keep-together), so YMMV.

like image 44
Tony Graham Avatar answered Oct 27 '22 00:10

Tony Graham