[xml] libxslt ancestor-or-self::* results ordering.



I'm not sure if this is a bug or not but it feels weird. The "ancestor-or-self" axis seems to be returning nodes in document order when I thought it should be returning them in reverse document order. From my reading the XPath spec is vague on the subject. However other points of documentation point to reverse document order. For instance xpathInternals of libxml2 http://xmlsoft.org/html/libxml-xpathInternals.html#xmlXPathNextAncestorOrSelf specifies reverse document order. And the Wrox book "XSLT Programmer's Reference" by Micheal Kay also seems to say reverse document order.

However when I run xsltproc on the attached files I get these results.

jadams fuzball:~/tmp$ xsltproc foo.xsl foo.xml
xml :
foo : A
foo : B
foo : C
foo : D
bar : E

Is that right ?


Jason Adams
<xml>
        <foo tag="A">
                <foo tag="B">
                        <foo tag="C">
                                <foo tag="D">
                                        <bar tag="E"/>
                                </foo>
                        </foo>
                </foo>
        </foo>
</xml>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; >

        <xsl:output method="text" encoding="iso-8859-1" />

        <xsl:template match="/">
                <xsl:apply-templates select="//bar"/>
        </xsl:template>

        <xsl:template match="bar">
                <xsl:for-each select="ancestor-or-self::*">
                        <xsl:value-of select="local-name()"/>
                        <xsl:text> : </xsl:text>
                        <xsl:value-of select="@tag"/>
<xsl:text>
</xsl:text>
                </xsl:for-each>
        </xsl:template>


</xsl:stylesheet>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]