微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

xml – 如何获取当前节点变量的父节点元素?

以下是我的xslt:

<xsl:template match="/">
            <xsl:call-template name="generateLinks">
        <xsl:with-param name="currentPageBranchVariable" select="//Item[@CurrentPageBranch='true']"></xsl:with-param>
      </xsl:call-template>

  </xsl:template>

和:

<xsl:template name="generateLinks">
    <xsl:param name="currentPageBranchVariable"></xsl:param>

    <xsl:value-of select="$currentPageBranchVariable/@FullName"/>

    // how to get the parent node of $currentPageBranchVariable?

  </xsl:template>

可以看出,$currentPageBranchVariable是包含Item节点的第二个模板的变量.

怎么可能从那里得到它的父元素?

我尝试了以下但没有奏效:

<xsl:value-of select="../$currentPageBranchVariable/@FullName"/>
<xsl:value-of select="parent::node()/$currentPageBranchVariable/@FullName"/>
<xsl:value-of select="parent($currentPageBranchVariable)/@FullName"/>

希望问题很清楚.

也许我想要做的是不可能的?

谢谢,

解决方法

the $currentPageBranchVariable is a variable for the second template
which contains an Item node.

How would that be possible to get its parent element from there?

只需使用:

$currentPageBranchVariable/..

这将选择$currentPageBranchVariable中包含的所有节点(在这种情况下只有一个)的父节点(每个节点).

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。