Xslt 将XSL-FO表放在同一页上,而不是跨下一页移动
我使用XSL-FO模板从XSL生成PDF。在我的PDF中,有一些表将由动态数据填充(对生成的行没有控制)。我在PDF中有一些静态内容,之后会出现表格。当前的行为类似于,在PDF中,如果静态内容一直占据页面中间,而具有动态内容的表格有许多行,则表格会移动到下一页,将静态内容后的空格留空。我希望其行为类似于,在PDF中,表格应在同一页面中的静态内容之后立即开始,并允许该页面中允许的行数,如果表格不适合上一页面,则在下一页面中继续表格 为了更清晰,我在此添加代码Xslt 将XSL-FO表放在同一页上,而不是跨下一页移动,xslt,xsl-fo,xmltable,Xslt,Xsl Fo,Xmltable,我使用XSL-FO模板从XSL生成PDF。在我的PDF中,有一些表将由动态数据填充(对生成的行没有控制)。我在PDF中有一些静态内容,之后会出现表格。当前的行为类似于,在PDF中,如果静态内容一直占据页面中间,而具有动态内容的表格有许多行,则表格会移动到下一页,将静态内容后的空格留空。我希望其行为类似于,在PDF中,表格应在同一页面中的静态内容之后立即开始,并允许该页面中允许的行数,如果表格不适合上一页面,则在下一页面中继续表格 为了更清晰,我在此添加代码 <fo:block>
<fo:block>
<fo:block>
<fo:table xsl:use-attribute-sets="tablestyle1">
<fo:table-column xsl:use-attribute-sets="tablecoll" />
<fo:table-column xsl:use-attribute-sets="tablecoll"/>
<fo:table-column xsl:use-attribute-sets="tablecoll" />
<fo:table-column xsl:use-attribute-sets="tablecoll" />
<fo:table-column xsl:use-attribute-sets="tablecoll" />
<fo:table-body>
<fo:table-row xsl:use-attribute-sets="tabletr">
<fo:table-cell font-weight="bold" xsl:use-attribute-sets="tabletd">
<fo:block>
<xsl:text disable-output-escaping="yes">
</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell font-weight="bold" xsl:use-attribute-sets="tabletd">
<fo:block>Name</fo:block>
</fo:table-cell>
( 3 more cells here..)
</fo:table-row>
<xsl:for-each
select="(value is being fetched from function)">
<fo:table-row xsl:use-attribute-sets="tabletr">
<fo:table-cell font-weight="bold" xsl:use-attribute-sets="tabletd">
<fo:block>
<xsl:value-of select="position()" />
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="tabletd">
<fo:block>
<xsl:choose>
<xsl:when
test="./Name/Title!='' or ./Name/ForeName !='' or ./Name/SecondInitial!='' or ./Name/Surname!=''">
<xsl:call-template name="format-name1">
<xsl:with-param name="name" select="./Name/Title" />
</xsl:call-template>
<xsl:text> </xsl:text>
<xsl:call-template name="format-name1">
<xsl:with-param name="name" select="./Name/ForeName" />
</xsl:call-template>
<xsl:text> </xsl:text>
<xsl:call-template name="format-name1">
<xsl:with-param name="name" select="./Name/Surname" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text disable-output-escaping="yes">
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="tabletd">
(few more table cells are populated here using for - each iteration)
.
.
</fo:table-cell>
</fo:table-body>
</fo:table>
</fo:block>
</fo:block>
;
名称
(这里还有3个单元格…)
;
(这里使用for-each迭代填充的表格单元格很少)
.
.
宾果游戏:
<xsl:attribute-set name="tabletr" foa:class="table">
<xsl:attribute name="keep-with-next">always</xsl:attribute>
总是
“始终”设置是你的罪魁祸首。这使得表中的所有行都希望保持在一起。格式化程序将尝试将整个表放在一个页面上
您可以完全删除该属性,也可以将“始终”更改为数字。保持设置使用优先级,因此从低优先级数字(1)开始 显示您在编写此代码方面的尝试。提供一个示例,代码已经添加到您调用的tabletd属性集中,可能有一些属性处理分页。(与下一个保持一致,与上一个保持一致等)。将这些设置为错误的值将给出您描述的行为。正如@Hobbes所说,我们至少需要查看
tablestyle1
和tabletr
属性集的定义,才能真正了解发生了什么。另外,当你说“静态内容”时,你是指由fo:static content
或样板文本生成的区域还是什么?(我不认为您指的是fo:static content
,因为它不应该像您描述的那样运行,但我还是想检查一下。)在td/tr调用中,任何Keep属性都不是私有的。