我想删除所有显示 的文本后面的换行符 请参阅附件“
不需要的换行符,如 notepadd++ 所示:
alt text http://img13.imageshack.us/img13/9803/clcflinebreak.png
这是我到目前为止:
<xsl:template match="p">
<!-- output everything but the See the exhibit text should have the line break removed -->
</xsl:template>
有任何想法吗?谢谢!
最佳答案
如果您使用转换生成 HTML 输出,最简单的方法通常是:
<xsl:value-of select="normalize-space($text)"/>
normalize-space
去除前导和尾随空格,并用单个空格替换字符串中的多个空格字符。要准确删除尾随 CR/LF 对:
<xsl:choose>
<xsl:when test="substring(., string-length(.)-1, 2) = '
'">
<xsl:value-of select="substring(., 1, string-length(.)-2)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
关于xml - XSL 从文本中删除换行符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1922882/