10

在找到“keep-together”属性并且不需要在行内分页后keep-together="always",我在 xslt 中的每个 table-row 元素上添加。有没有更好的方法来达到同样的效果?这似乎有点hacky。(ps。如果没有人提供更好的答案,我会接受“不”作为答案,前提是提供某种解释。)

4

4 回答 4

16

keep-together="always"很危险,因为这是一个也间接设置的复合属性keep-together.within-line="always"(禁止在表格单元格内换行)。你应该keep-together.within-column="always"改用。但是在表格行上指定它实际上是要走的路。没什么可笑的。

另见:http ://www.w3.org/TR/xsl11/#datatype

于 2012-12-18T13:18:33.597 回答
4

我使用以下三种方法将表行保持在一起并取得了一些成功:

将整个街区保持在一起

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

将相邻的块保持在一起

<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>

尽管您必须小心 - 如果行或单元格跨越生成文档的多页,您会将该页面的底部从底部松开!

于 2016-05-16T11:33:56.913 回答
1

当我需要将表格锁定在一起时,这个答案解决了我的表格行在分页符上流动的问题。我用了<fo:table keep-together="always"></fo:table> 谢谢。

于 2015-06-18T07:08:19.443 回答
1

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.

于 2016-05-19T08:54:22.253 回答