Xml XSL-FO分页符、寡妇和孤儿
我有一个大型语料库,它基于以下简化XML结构的XSL-FO 3.0转换生成PDF:Xml XSL-FO分页符、寡妇和孤儿,xml,xslt,xsl-fo,Xml,Xslt,Xsl Fo,我有一个大型语料库,它基于以下简化XML结构的XSL-FO 3.0转换生成PDF: <corpus> <deposition> <text> <deposition-title>foo title</deposition-title> <seg>foo paragraph 1</seg> <seg>foo paragraph 2</seg&
<corpus>
<deposition>
<text>
<deposition-title>foo title</deposition-title>
<seg>foo paragraph 1</seg>
<seg>foo paragraph 2</seg>
<seg>foo paragraph 3</seg>
<appnotes>
<appitem>foo apparatus item 1</appitem>
</appnotes>
<footnotes>
<footitem>foo note 1</footitem>
<footitem>foo note 1</footitem>
</footnotes>
</text>
</deposition>
<deposition>
<text>
<deposition-title>foo title</deposition-title>
<seg>foo paragraph 1</seg>
<seg>foo paragraph 2</seg>
<appnotes/>
<footnotes>
<footitem>foo note 1</footitem>
</footnotes>
</text>
</deposition>
[...]
</corpus>
富头衔
foo第1段
foo第2段
foo第3段
但是XSL-FO产生了一些分页符问题,我似乎无法通过使用keep-together、widows、Olivers等组合来解决这些问题
与
从
目标:对于任何
,我想应用以下两条规则进行分页:
粘贴到第一个
和
坚持最后的
提前感谢您提供的任何见解。如果您添加
<xsl:template match="deposition-title">
<fo:block keep-with-next="always">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
如果你加上
<xsl:template match="deposition-title">
<fo:block keep-with-next="always">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
在接受答案之后,我将针对评论中确定的一个问题,在这里发布修改后的代码。现在
和
是一个模板,在一个
中。这是用RenderX处理的
<xsl:template match="footnotes | appnotes">
<fo:block font-size="8pt" font-weight="normal" end-indent="120pt" keep-with-previous="always">
<xsl:choose>
<xsl:when test="./appitem">
<fo:leader leader-pattern="rule" leader-length="2cm" rule-style="solid" rule-thickness=".2pt" keep-with-previous="always"/>
<fo:block keep-with-previous="always">
<xsl:for-each select="./appitem">
<fo:inline><xsl:apply-templates/>   </fo:inline>
</xsl:for-each>
</fo:block>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="./footitem">
<fo:leader leader-pattern="rule" leader-length="2cm" rule-style="solid" rule-thickness=".2pt" keep-with-previous="always"/>
<xsl:for-each select="./footitem">
<fo:block keep-with-previous="always">
<xsl:apply-templates/>
</fo:block>
</xsl:for-each>
<fo:leader leader-pattern="rule" leader-length="2cm" rule-style="solid" rule-thickness=".2pt" keep-with-previous="always"/>
</xsl:when>
</xsl:choose>
</fo:block>
</xsl:template>
在接受答案之后,我将针对评论中确定的一个问题在这里发布修订后的代码。现在
和
是一个模板,在一个
中。这是用RenderX处理的
<xsl:template match="footnotes | appnotes">
<fo:block font-size="8pt" font-weight="normal" end-indent="120pt" keep-with-previous="always">
<xsl:choose>
<xsl:when test="./appitem">
<fo:leader leader-pattern="rule" leader-length="2cm" rule-style="solid" rule-thickness=".2pt" keep-with-previous="always"/>
<fo:block keep-with-previous="always">
<xsl:for-each select="./appitem">
<fo:inline><xsl:apply-templates/>   </fo:inline>
</xsl:for-each>
</fo:block>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="./footitem">
<fo:leader leader-pattern="rule" leader-length="2cm" rule-style="solid" rule-thickness=".2pt" keep-with-previous="always"/>
<xsl:for-each select="./footitem">
<fo:block keep-with-previous="always">
<xsl:apply-templates/>
</fo:block>
</xsl:for-each>
<fo:leader leader-pattern="rule" leader-length="2cm" rule-style="solid" rule-thickness=".2pt" keep-with-previous="always"/>
</xsl:when>
</xsl:choose>
</fo:block>
</xsl:template>
非常简单。非常感谢!当我仔细检查结果时,我意识到这个解决方案可以在第一个seg块中保留标题。但是,appnotes和脚注并没有这样做:我将现有模板中的所有内容都打包到
中。然而,例如,第一个
将从appnotes的其余部分分离。谢谢。你有一个appnotes和脚注的fo:block
包装器吗?它还可能有助于在问题中添加信息,并作为您使用的FO处理器的标记,我必须承认,我对这些XSL-FO属性在不同实现中的实际工作情况的了解相当有限,但我在这里看到的答案表明,如果您提到您的FO处理器,有各种产品的经验丰富的用户可以给您提供更具体的建议。我不确定为什么我不想把它放在这里但即使只使用一个块,也无法解决问题。但是,我将相同的属性添加到每个子块、引线等中,现在它们都保持在一起。这正在使用RenderX进行处理。谢谢(我在回答自己的问题时添加了修改后的代码,以防有人发现问题)。非常简单。非常感谢!当我仔细检查结果时,我意识到这个解决方案可以在第一个seg块中保留标题。但是,appnotes和脚注并没有这样做:我将现有模板中的所有内容都打包到
中。然而,例如,第一个
将从appnotes的其余部分分离。谢谢。你有一个appnotes和脚注的fo:block
包装器吗?它还可能有助于在问题中添加信息,并作为您使用的FO处理器的标记,我必须承认,我对这些XSL-FO属性在不同实现中的实际工作情况的了解相当有限,但我在这里看到的答案表明,如果您提到您的FO处理器,有各种产品的经验丰富的用户可以给您提供更具体的建议。我不确定为什么我不想把它放在这里但即使只使用一个块,也无法解决问题。但是,我将相同的属性添加到每个子块、引线等中,现在它们都保持在一起。这正在使用RenderX进行处理。谢谢(我在回答自己的问题时添加了修改后的代码,以防有人发现问题)。