Is there an alternative to "keep-together='always'" on table-row?
Solution 1
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
Solution 2
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!
Solution 3
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.
Solution 4
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.
Sean
Working in C# - Answering and asking questions to improve my knowledge on c#. Currently trying f#. Expect stupid questions.
Updated on May 19, 2020Comments
-
Sean about 4 years
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.) -
bvb1909 about 9 yearshow can i use these over more rows to shows it always on one site? I try to use a block over more rows but it's not working :(
-
Jeremias Märki about 9 yearsThat's a case for keep-with-next.within-column="always" on fo:table-row (assuming you're talking about a table). You'll probably need to combine keep-together and keep-with-next (or -previous) here.
-
flu over 8 yearsI had exactly the problem with using
keep-together="always"
prohibiting line breaks inside table-cells. Thank you very much for that explanation.keep-together.within-column="always"
helped me, making the whole table break on overflow but keeping line breaks inside the table's cells intact.