首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过XSLT从XML中删除特定的空标记

通过XSLT从XML中删除特定的空标记
EN

Stack Overflow用户
提问于 2014-05-29 08:18:58
回答 2查看 212关注 0票数 0

我有以下过程的XML

代码语言:javascript
复制
<p>In technical jargon<sup></sup>, the expect<span class="insert"></span><span class="insert"></span><span class="insert">ed</span> excess return on a factor is proportional to the negative of the factor covariance with the pricing kernel, <br/>given by marginal utility of consumption for a representative agent.</p>

我使用下面的xsl来删除span空标记。

代码语言:javascript
复制
<xsl:template match=
    "*[not(span) 
     and normalize-space()=''
      ]"/>

通过XSL输出。它移除所有空标签。

代码语言:javascript
复制
<p>In technical jargon, the expect<span class="insert">ed</span> excess return on a factor is proportional to the negative of the factor covariance with the pricing kernel, given by marginal utility of consumption for a representative agent.</p>

但只删除span空标签。所以我需要下面的XML

代码语言:javascript
复制
<p>In technical jargon<sup></sup>, the expect<span class="insert">ed</span> excess return on a factor is proportional to the negative of the factor covariance with the pricing kernel, <br/>given by marginal utility of consumption for a representative agent.</p>

谢谢你提前。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-05-29 08:24:27

使用

代码语言:javascript
复制
<xsl:template match=
        "*[self::span 
        and normalize-space()=''
        ]"/>
票数 1
EN

Stack Overflow用户

发布于 2014-05-29 08:36:40

如果只想删除span,则使模板仅匹配跨范围。

代码语言:javascript
复制
<xsl:template match="span[not(span) 
     and normalize-space()='']"/>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23928818

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档