gpt4 book ai didi

xslt - 向上一个节点,查看父节点是否等同于 XSLT 中的特定节点

转载 作者:行者123 更新时间:2023-12-03 16:00:41 25 4
gpt4 key购买 nike

我想看看我所指的当前节点的父节点是否等于某个特定值。我做了如下但没有用。

例如。

<v:name>
<v:age>

在“年龄”时,我尝试了 <xsl:if test='.. = v:name'> .但这是不正确的。什么是正确的方法?有人可以帮忙吗?

我在一个对 v:name 和 v:age 都适用的模板中。有 v:age 不是 v:name 的 child 。我想确保我所指的 v:age 是 v:name 的子代。这就是我想要的测试属性。

最佳答案

来自 OP 的评论:

I am inside a template which is true for both v:name and v:age. There are v:age's which are not children of v:name. I want to ensure that v:age I am referring to is a child of a v:name. That is what I want inside the test attribute

使用:

parent::v:name

这在 xsl:if 中变为:

<xsl:if test="parent::v:name">
<!-- Whatever processing is necessary. -->
</xsl:if>

关于xslt - 向上一个节点,查看父节点是否等同于 XSLT 中的特定节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11381352/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com