After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 107804 - select by ancestor-or-self::*/@name gives wrong order
select by ancestor-or-self::*/@name gives wrong order
Status: VERIFIED FIXED
Product: libxslt
Classification: Platform
Component: general
1.0.23
Other HP-UX
: Normal normal
: ---
Assigned To: Daniel Veillard
Daniel Veillard
Depends on:
Blocks:
 
 
Reported: 2003-03-07 09:38 UTC by jre
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description jre 2003-03-07 09:38:07 UTC
<xsl:for-each select="ancestor-or-self::*/@name"> selects items in an
apparently random order if more than 3 are selected.  At any rate, they
don't seem to be selected in document order.
<xsl:for-each select="ancestor-or-self::*"> behaves as expected and selects
the elements in document order.

Example xml:
<?xml version="1.0"?>
<a name="a"><b name="b"><c name="c"><d name="d"><e name="e"><f name="f"><g
name="g"><h name="h">
</h></g></f></e></d></c></b></a>

Example xsl:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" >

   <xsl:output method="text"/>
   <xsl:template match="*">
     <xsl:text>&#x0A;selecting by element:    </xsl:text>
     <xsl:for-each select="ancestor-or-self::*">
       <xsl:text>/</xsl:text>
       <xsl:value-of select="@name"/>
     </xsl:for-each>
     <xsl:text>&#x0A;          by attribute:  </xsl:text>
     <xsl:for-each select="ancestor-or-self::*/@name">
       <xsl:text>/</xsl:text>
       <xsl:value-of select="."/>
     </xsl:for-each>
     <xsl:text>&#x0A;</xsl:text>
     <xsl:apply-templates/>
   </xsl:template>

</xsl:stylesheet>

Output:

selecting by element:    /a
          by attribute:  /a

selecting by element:    /a/b
          by attribute:  /a/b

selecting by element:    /a/b/c
          by attribute:  /a/b/c

selecting by element:    /a/b/c/d
          by attribute:  /c/d/a/b

selecting by element:    /a/b/c/d/e
          by attribute:  /e/d/c/b/a

selecting by element:    /a/b/c/d/e/f
          by attribute:  /d/e/f/a/b/c

selecting by element:    /a/b/c/d/e/f/g
          by attribute:  /g/e/f/d/b/c/a

selecting by element:    /a/b/c/d/e/f/g/h
          by attribute:  /c/d/a/b/g/h/e/f
Comment 1 Daniel Veillard 2003-03-07 15:02:27 UTC
Okay, fixed in CVS:

http://cvs.gnome.org/bonsai/cvsquery.cgi?branch=&dir=gnome-xml&who=veillard&date=explicit&mindate=2003-03-07%2009:19&maxdate=2003-03-07%2009:21&cvsroot=/cvs/gnome

once recompiled agaist the fixed version xsltproc now does
the Right Thing:

paphio:~/XSLT/tests/general -> xsltproc bug-108.xsl ../docs/bug-108.xml

selecting by element:    /a
          by attribute:  /a

selecting by element:    /a/b
          by attribute:  /a/b

selecting by element:    /a/b/c
          by attribute:  /a/b/c

selecting by element:    /a/b/c/d
          by attribute:  /c/d/a/b

selecting by element:    /a/b/c/d/e
          by attribute:  /e/d/c/b/a

selecting by element:    /a/b/c/d/e/f
          by attribute:  /d/e/f/a/b/c

selecting by element:    /a/b/c/d/e/f/g
          by attribute:  /g/e/f/d/b/c/a

selecting by element:    /a/b/c/d/e/f/g/h
          by attribute:  /c/d/a/b/g/h/e/f

paphio:~/XSLT/tests/general ->

  thanks a lot for the smaller test and the pre-analysis !

Daniel
Comment 2 Daniel Veillard 2003-03-25 12:35:35 UTC
 This should be closed by the release of libxml2-2.5.5 and
libxslt-1.0.28,

    thanks,

Daniel