表的定义如下
<fo:block font-size="10pt">
<fo:table table-layout="fixed" width="100%" border-collapse="separate" border-separation="5pt"
space-after="1.0cm">
<fo:table-column column-width="3cm"/>
<fo:table-column column-width="3cm"/>
<fo:table-column column-width="3cm"/>
<fo:table-column column-width="3cm"/>
<fo:table-column column-width="3cm"/>
<fo:table-column column-width="3cm"/>
<fo:table-column column-width="3cm"/>
<fo:table-footer>
</fo:table>
</fo:block>我如何将每一列设置为最大长度,如果它溢出,它应该转到下一行?目前,如果一列中的文本非常长,它不会转到下一行,而是显示在同一行上,这会阻止看到其他列。
例如如何映射数据:
<xsl:template match="setInfo">
<fo:table-row>
<xsl:apply-templates select="." mode="font-weight"/>
<fo:table-cell>
<fo:block>
<xsl:value-of select="date"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="category"/>
</fo:block>
</fo:table-cell>
<xsl:value-of select="measure"/>
<fo:table-cell>
<fo:block>
<xsl:value-of select="999999999999999999999999999999999999999999999999999999999999999999999999999999999"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>发布于 2022-02-23 08:15:46
在没有空格的表格单元格中分割文本是一个常见的问题。通常的解决方案( FOP)是在字符之间插入一个零宽度的空间.然而,这些答案中的大多数使用XSLT2.0,而您的问题被标记为XSLT1.0:
发布于 2022-02-24 11:45:02
若要在每个文本字符(最后一个字符除外)后面插入零宽度空格字符,请替换您的引用:
<xsl:value-of select="some-node"/>通过以下方式:
<xsl:call-template name="allow-line-breaks">
<xsl:with-param name="text" select="some-node"/>
</xsl:call-template>并将此模板添加到样式表中:
<xsl:template name="allow-line-breaks">
<xsl:param name="text"/>
<xsl:value-of select="substring($text, 1, 1)"/>
<xsl:if test="string-length($text) > 1">
<xsl:text>​</xsl:text>
<!-- recursive call -->
<xsl:call-template name="allow-line-breaks">
<xsl:with-param name="text" select="substring($text, 2)"/>
</xsl:call-template>
</xsl:if>
</xsl:template>如我在对另一个答复的评论中所指出的,我对XSL-FO一无所知。我不禁想知道,是否真的没有一个内置指令强制行的宽度。
https://stackoverflow.com/questions/71228722
复制相似问题