The*_*ght 4 xml xslt xpath parent
以下是我的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>
Run Code Online (Sandbox Code Playgroud)
和:
<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>
Run Code Online (Sandbox Code Playgroud)
可以看出,$ currentPageBranchVariable是包含Item节点的第二个模板的变量.
怎么可能从那里得到它的父元素?
我尝试了以下但没有奏效:
<xsl:value-of select="../$currentPageBranchVariable/@FullName"/>
<xsl:value-of select="parent::node()/$currentPageBranchVariable/@FullName"/>
<xsl:value-of select="parent($currentPageBranchVariable)/@FullName"/>
Run Code Online (Sandbox Code Playgroud)
希望问题很清楚.
也许我想要做的是不可能的?
谢谢,
这
$currentPageBranchVariable是包含Item节点的第二个模板的变量.怎么可能从那里得到它的父元素?
只需使用:
$currentPageBranchVariable/..
Run Code Online (Sandbox Code Playgroud)
这将选择包含在中的所有节点(在这种情况下只有一个)的父节点(每个节点)$currentPageBranchVariable.
| 归档时间: |
|
| 查看次数: |
7338 次 |
| 最近记录: |