Details
-
Bug
-
Status: Resolved
-
Resolution: Fixed
-
2.4Dx
-
None
-
None
-
Operating System: Windows NT/2K
Platform: PC
-
11941
Description
This might be related to bug 7886.
When "count(ancestor::) > 1", "ancestor::[last()]" should be different than
"ancestor::*[1]", right? Well, it doesn't seem so.
To have it right, it seems we have to write an xpath of "./ancestor::*[last()]".
Same issue with ancestor-or-self.
My actual (working) code is:
<xsl:template match"someelement">
<xsl:message>
count ancestors: <xsl:value-of select="count(ancestor::*)"/>
last ancestor: <xsl:value-of select="local-name(./ancestor::*[last()])"/>
1st ancestor: <xsl:value-of select="local-name(./ancestor::*[1])"/>
</xsl:message>
<xsl:template>
Without the ./, last and 1st ancestors are the same element. I have other code
like "id(@foo)/ancestor-or-self::*[last() - 2]", which is working fine, so I'd
say / is our friend here.
Or did I miss anything in XPath?