GNOME Bugzilla – Bug 107804
select by ancestor-or-self::*/@name gives wrong order
Last modified: 2009-08-15 18:40:50 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>
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>
 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>
</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
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
This should be closed by the release of libxml2-2.5.5 and libxslt-1.0.28, thanks, Daniel