【问题标题】:How to remove part of attached xml with xslt?如何使用 xslt 删除部分附加的 xml?
【发布时间】:2009-12-08 15:06:55
【问题描述】:

假设我们有 xml:

文本 { name1 :value1; name2 :value2; }

如何使用 xslt 删除带有 name1 和 value1 的整行(从 到 )?

删除 tag3 和 tag4 没有问题,但是这个冒号 (':') 字符对我来说有问题。

【问题讨论】:

标签: xslt


【解决方案1】:

这是一个非常丑陋但有效的解决方案。 这很难看,因为条件必须重复 3 次。必须有更简单的方法来做到这一点。

<xsl:template match="tag3[text()=' name1 ' and following-sibling::tag4[val/text()='value1']]"/>
<xsl:template match="text()[preceding-sibling::tag3[text()=' name1 '] and following-sibling::tag4/val[text()='value1']]" />
<xsl:template match="tag4[val/text()='value1' and preceding-sibling::tag3[text()=' name1 ']]" />
<xsl:template match="@* | node()">
    <xsl:copy>
        <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
</xsl:template>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-31
    • 1970-01-01
    • 1970-01-01
    • 2010-09-26
    • 2021-09-17
    • 2012-07-28
    相关资源
    最近更新 更多