试图解决一个谜语。我想只在元素包含属性(任何属性)时才显示元素的祖父。提前致谢!我有以下代码:
<xsl:when test="content/track">
<xsl:for-each select="content/track">
<div class="container_orange">
<xsl:value-of select="./text()" disable-output-escaping="yes"/>
is <b>current</b> and grandchild of
<b><xsl:value-of select="name(../..)"/></b>
<!-- displays only the name of the node that is a grandparent, but how to add an attribute condition?-->
</div>
</xsl:for-each>
</xsl:when>
答案 0 :(得分:1)
条件称为谓词并进入方括号,因此../..[@*]
选择具有任何属性的祖父母。