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 2001/04/19 22:59:32 UTC
[Bug 1410] New - sort descending w/ nodes along ancestor axis backward
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1410
*** shadow/1410 Thu Apr 19 13:59:32 2001
--- shadow/1410.tmp.3102 Thu Apr 19 13:59:32 2001
***************
*** 0 ****
--- 1,115 ----
+ +============================================================================+
+ | sort descending w/ nodes along ancestor axis backward |
+ +----------------------------------------------------------------------------+
+ | Bug #: 1410 Product: XalanJ2 |
+ | Status: NEW Version: 2.0.0 |
+ | Resolution: Platform: Sun |
+ | Severity: Normal OS/Version: Solaris |
+ | Priority: Medium Component: org.apache.xalan.xsltc |
+ +----------------------------------------------------------------------------+
+ | Assigned To: xalan-dev@xml.apache.org |
+ | Reported By: tamiro@east.sun.com |
+ | CC list: Cc: |
+ +----------------------------------------------------------------------------+
+ | URL: |
+ +============================================================================+
+ | DESCRIPTION |
+ [taken from SunMicrosystem's bug 4419612]
+ The following test is taken from the example in Mike Kay's XSLT Reference manual
+ on page 203. The intention is to write a style sheet that output comments
+ that document the position of the elements with respect to one another
+ in reverse document order.
+
+ It's counter intuitive, but the sort order within a for-each is relative
+ to forward document order regardless of the axis order used to select
+ the nodes being processed by the for-each. Thus even though the ancestor::*
+ axis selects node is reverse document order from the current node,
+ you still have to sort the nodes in descending (reverse) order to
+ to process them in reverse document order.
+
+ In this test, the correct output should say, "line within stanza within poem"
+ which is reverse document order given the xml doc structue of
+ <poem>
+ <stanza>
+ <line>blah blah<line>
+ </stanza>
+ </poem>
+
+ xslt says, "line within poem within stanza" which is not true of course:
+ Stanza are within poems; poems are not within stanzas. We have company
+ though. Xt agrees with xsltc, whereas Saxon and Xalan seem to get it right.
+
+ Expected Output (Saxon and Xalan)
+ ============================================================================
+ <?xml version="1.0" encoding="utf-8"?><!--poem-->
+ <!--author within poem-->Rupert Brooke
+ <!--date within poem-->1912
+ <!--title within poem-->Song
+ <!--stanza within poem-->
+ <!--line within stanza within poem-->And suddenly the wind comes soft,
+ <!--line within stanza within poem-->And Spring is here again;
+ <!--line within stanza within poem-->And the hawthorn quickens with buds of
+ green
+ <!--line within stanza within poem-->And my heart with buds of pain.
+
+ <!--stanza within poem-->
+ <!--line within stanza within poem-->My heart all Winter lay so numb,
+ <!--line within stanza within poem-->The earth so dead and frore,
+ <!--line within stanza within poem-->That I never thought the Spring would come
+ again
+ <!--line within stanza within poem-->Or my heart wake any more.
+
+ <!--stanza within poem-->
+ <!--line within stanza within poem-->But Winter's broken and earth has woken,
+ <!--line within stanza within poem-->And the small birds cry again;
+ <!--line within stanza within poem-->And the hawthorn hedge puts forth its buds,
+ <!--line within stanza within poem-->And my heart puts forth its pain.
+
+ XSL File
+ ============================================================================
+ <xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0"
+ >
+ <xsl:template match="*">
+ <xsl:comment>
+ <xsl:value-of select="name()"/>
+ <xsl:for-each select="ancestor::*">
+ <xsl:sort select="position()" order="descending"/>
+ <xsl:text> within </xsl:text>
+ <xsl:value-of select="name()"/>
+ </xsl:for-each>
+ </xsl:comment>
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+
+ XML File
+ =============================================================================
+ <?xml version="1.0" encoding="iso-8859-1"?>
+ <?xml-stylesheet type="text/xsl" href="poem.xsl"?>
+ <poem>
+ <author>Rupert Brooke</author>
+ <date>1912</date>
+ <title>Song</title>
+ <stanza>
+ <line>And suddenly the wind comes soft,</line>
+ <line>And Spring is here again;</line>
+ <line>And the hawthorn quickens with buds of green</line>
+ <line>And my heart with buds of pain.</line>
+ </stanza>
+ <stanza>
+ <line>My heart all Winter lay so numb,</line>
+ <line>The earth so dead and frore,</line>
+ <line>That I never thought the Spring would come again</line>
+ <line>Or my heart wake any more.</line>
+ </stanza>
+ <stanza>
+ <line>But Winter's broken and earth has woken,</line>
+ <line>And the small birds cry again;</line>
+ <line>And the hawthorn hedge puts forth its buds,</line>
+ <line>And my heart puts forth its pain.</line>
+ </stanza>
+ </poem>