我正在使用 XSL FO 生成一个包含信息表的 PDF 文件。其中一列是“描述”列。我填充这些描述字段之一的字符串示例如下:
This is an example Description.<br/>List item 1<br/>List item 2<br/>List item 3<br/>List item 4
在与此描述相对应的表格单元格内,我希望输出显示如下:
This is an example Description.
List item 1
List item 2
List item 3
List item 4
我从其他地方搜索得知,您可以使用 XSL FO 中的换行符<fo:block></fo:block>
在另一个内<fo:block>
元素。因此,即使在使用 XSL 样式表解析 XML 之前,我也会替换所有出现的<br/>
with <fo:block/>
,这样字符串的字面值现在看起来像:
This is an example Description.<fo:block/>List item 1<fo:block/>List item 2<fo:block/>List item 3<fo:block/>List item 4
当我使用的描述字符串是通过以下方式获取时,就会出现问题<xsl:value-of>
,示例如下:
<fo:block>
<xsl:value-of select="descriptionStr"/>
</fo:block>
在这种情况下,输出到 PDF 文档的值是文字值,因此它看起来与前面的示例完全相同,其中包含所有<fo:block/>
文字。我尝试过手动硬编码<fo:block/>
在另一个字符串的中间,并且它显示正确。例如。如果我在样式表中写入:
<fo:block>Te<fo:block/>st</fo:block>
它将正确显示为:
Te
st
但这似乎不会发生,当<fo:block/>
位于 a 的值内<xsl:value-of select=""/>
陈述。我尝试在 SO 以及 Google 等上搜索此内容,但无济于事。任何建议或帮助将不胜感激。谢谢你!