i'am使用apache fop使用XSL 1.0将XML转换为PDF。
我XML节点
<ABC>This is one line
This is second line
This is third line</ABC>
我想要与节点相似的输出,即
This is one line
This is second line
This is third line
,但它只有一行。那么,XSL中是否有任何解决方案可以逃脱"&amp; #xd"?以下代码用于获取节点的值。
<xsl:value-of select="ABC" disable-output-escaping="yes" />
您要寻找的属性是linefeed-treatment
。
将其设置为"preserve"
将具有处理线馈示的文本为单独段落的效果,因此像这样的块
<fo:block linefeed-treatment="preserve">A
B
C</fo:block>
将在输出中产生三条线
A
B
C
解决问题的方法是
的分析字符串<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="/">
<xsl:analyze-string select="ABC" regex="
">
<xsl:matching-substring></xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
</xsl:stylesheet>
利用然后我们在匹配项上拆分并仅使用非匹配字符串的事实。