You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2002/08/22 19:49:05 UTC

DO NOT REPLY [Bug 11941] New: - ancestor and ancestor-or-self axis sometimes return wrong element

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11941>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11941

ancestor and ancestor-or-self axis sometimes return wrong element

           Summary: ancestor and ancestor-or-self axis sometimes return
                    wrong element
           Product: XalanJ2
           Version: 2.4Dx
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Major
          Priority: Other
         Component: org.apache.xpath
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: benoit@synclude.com


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?