[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xsl:sort clarification

Subject: xsl:sort clarification
From: Jack Matheson <jack@xxxxxxxxxxxxxx>
Date: Mon, 22 Aug 2005 16:47:11 -0500
xsl sort compare
In the XSLT 1.0 spec, the following is stated:

"The sort must be stable: in the sorted list of nodes, any sub list that has sort keys that all compare equal must be in document order."

Does this mean that if all sort keys compare equal, a node-set will appear in ascending document order regardless of the 'order' attribute? Or does this mean that if the 'order' is 'descending', nodes with identical sort key values will appear in reverse-document order? If I've learned anything from this list, it's that I should always take the spec as literally as possible, which would lead me to believe that ascending document order is expected for any sort involving equal sort key values...but this doesn't seem useful at all. =)

Here is a quick example:

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


<xsl:template match="doc">
  <xsl:variable name="ord" select="'descending'"/>
  <out>
    Descending order....
    <xsl:for-each select="t">
      <xsl:sort data-type="number" order="{$ord}"/>
      <xsl:value-of select="."/><xsl:text>|</xsl:text>
    </xsl:for-each>
  </out>
</xsl:template>

</xsl:stylesheet>

with input:

<?xml version="1.0"?>
<doc>
  <t>1</t>
  <t>007</t>
  <t>1.0</t>
  <t>7</t>
  <t>bogus</t>
  <t>0.5</t>
  <t>1.1</t>
  <t>11</t>
</doc>

Using Saxon 6.5.4, I get:

<?xml version="1.0" encoding="utf-8"?><out>
    Descending order....
    11|007|7|1.1|1|1.0|0.5|bogus|</out>

What I expected was:

<?xml version="1.0" encoding="UTF-8"?><out>
    Descending order....
    11|7|007|1.1|1.0|1|0.5|bogus|</out>

Can anyone help clarify this?

Thanks again,
-Jack

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.