<xsl:template name="makeDiv">
<xsl:when test="descendant::*[Parent][Name]">
</xsl:when>
</xsl:template>
在某处...
<xsl:if test="descendant::ParentCheck">
<xsl:call-template name="makeDiv"/>
</xsl:if>
有人可以向我解释定义了什么template-name = makeDiv以及测试正在做什么吗?它是否在寻找
Parent
的后代的任何节点的属性'Name
'和'ParentCheck
'?另外,
<xsl:when test="not(descendant::*[SomeAttribute])">
是什么意思?它是指不是SomeAttribute
的其他子元素吗?
最佳答案
descendant:*[Parent][Name]
表示“具有子“父代”元素和“名称”元素的任何后代。
i.e. <SomeElement>
<Parent/>
<Name/>
<SomeElement>
descendant::ParentCheck
表示“任何名为ParentCheck的后代”i.e. <ParentCheck />
关于xml - xpath高级语法困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12303998/