【发布时间】:2011-04-09 08:32:51
【问题描述】:
我正在使用 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/> 替换为 <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
当我使用的Description字符串是使用<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/> 在<xsl:value-of select=""/> 语句的值内时,这似乎不会发生。我试过在 SO 和 Google 等上搜索这个,但无济于事。任何建议或帮助将不胜感激。谢谢!
【问题讨论】: