我想在Xslt中检查当前节点的父节点是否为根节点。我该如何做?
请指导我解决这个问题...
谢谢和问候, P.SARAVANAN
谢谢和问候, P.SARAVANAN
在XPath 1.0(XSLT 1.0)中:
not(parent::*)
或者您可以使用:
generate-id(..) = generate-id(/)
.. is root()
not(ancestor::*)
。 <xsl:template match="node()|@*">
<xsl:if test="not(ancestor::*)">
<xsl:message>The root element is "<xsl:value-of select="name()"/>".</xsl:message>
</xsl:if>
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>