我正在使用XSL FO生成包含信息表的PDF文件.其中一列是"描述"列.我填充其中一个Description字段的字符串示例如下:
This is an example Description.<br/>List item 1<br/>List item 2<br/>List item 3<br/>List item 4
Run Code Online (Sandbox Code Playgroud)
在与此描述对应的表格单元格内,我希望输出显示如下:
This is an example Description.
List item 1
List item 2
List item 3
List item 4
Run Code Online (Sandbox Code Playgroud)
我从其他地方搜索过,你可以使用<fo:block></fo:block>另一个<fo:block>元素在XSL FO中进行换行.因此,甚至在我用我的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
Run Code Online (Sandbox Code Playgroud)
当我使用的描述字符串使用时获得问题<xsl:value-of>,例如如下:
<fo:block>
<xsl:value-of select="descriptionStr"/>
</fo:block>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,输出到我的PDF文档的值是文字值,因此它看起来与上一个包含所有<fo:block/>文字的示例完全相同.我已经尝试<fo:block/>在另一个字符串的中间手动硬编码,并且它正确显示.例如,如果我在样式表中写入:
<fo:block>Te<fo:block/>st</fo:block>
Run Code Online (Sandbox Code Playgroud)
它将正确显示为:
Te
st
Run Code Online (Sandbox Code Playgroud)
但是当<fo:block/>它在<xsl:value-of select=""/>语句的值内时似乎不会发生.我试过在SO以及Google等上搜索这个都无济于事.任何建议或帮助将不胜感激.谢谢!