加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – XSL从文本中删除换行符

发布时间:2020-12-16 22:38:46 所属栏目:百科 来源:网络整理
导读:我想删除所有文字后面的换行符,参见附件“ 不需要的换行符,如notepadd所示: alt text http://img13.imageshack.us/img13/9803/clcflinebreak.png 这是我到目前为止: xsl:template match="p"!-- output everything but the See the exhibit text should hav
我想删除所有文字后面的换行符,参见附件“

不需要的换行符,如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 strip前导和尾随空格,并用单个空格替换字符串中多个空白字符的运行.

要准确删除尾随的CR / LF对:

<xsl:choose>
   <xsl:when test="substring(.,string-length(.)-1,2) = '&#xD;&#xA;'">
      <xsl:value-of select="substring(.,1,string-length(.)-2)"/>
   </xsl:when>
   <xsl:otherwise>
      <xsl:value-of select="."/>
   </xsl:otherwise>
</xsl:choose>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读