我有几个段落,我只想在一个页面上显示其中的 5 个。为此,我使用了 keep-together="always" 属性。
对于以下输入:
<paragraphs>
<paragraph/>
<paragraph/>
<paragraph/>
<paragraph/>
<paragraph/>
<paragraph/>
<paragraph/>
<paragraph/>
<paragraph/>
<paragraph/>
</paragraphs>
我想得到类似的东西:
<fo:block keep-together="always">
<paragraph/>
<paragraph/>
<paragraph/>
<paragraph/>
<paragraph/>
</fo:block>
<fo:block keep-together="always">
<paragraph/>
<paragraph/>
<paragraph/>
<paragraph/>
<paragraph/>
</fo:block>
我首先尝试了以下内容:
<xsl:template match="paragraphs">
<fo:block keep-together="always">
<xsl:for-each select="paragraph">
<xsl:if test="position() mod(5) = 1 and not(position() = 1)">
</fo:block>
<fo:block keep-together="always">
</xsl:if>
<xsl:apply-templates select="."/>
</xsl:for-each>
</fo:block>
</xsl:template>
但问题是它无法编译,因为 fo:block 的关闭位于 xsl:if 内部(编译时的 sax 解析器异常)。
有谁知道我如何解决这个问题?