[xsl] xsl:sort clarification

Subject: [xsl] xsl:sort clarification
From: Jack Matheson <jack@xxxxxxxxxxxxxx>
Date: Mon, 22 Aug 2005 16:47:11 -0500
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'"/>
    Descending order....
    <xsl:for-each select="t">
      <xsl:sort data-type="number" order="{$ord}"/>
      <xsl:value-of select="."/><xsl:text>|</xsl:text>


with input:

<?xml version="1.0"?>

Using Saxon 6.5.4, I get:

<?xml version="1.0" encoding="utf-8"?><out>
    Descending order....

What I expected was:

<?xml version="1.0" encoding="UTF-8"?><out>
    Descending order....

Can anyone help clarify this?

Thanks again,

Current Thread