Hi,

  I am trying to order a list of attributes by name.  So I use a
for-each with a sort on node-name(.), to compare the attribute
names as QNames:

    <xsl:for-each select="$attrs">
       <xsl:sort select="node-name(.)"/>
       <xsl:sequence select="."/>
    </xsl:for-each>

  But this gives me the following error, even though QName are
comparable (unless I am mistaken):

    XTDE1030: Non-comparable types found while sorting: Values
    are not comparable (xs:QName, xs:QName)

  The following variant works:

    <xsl:for-each select="$attrs">
       <xsl:sort select="namespace-uri(.)"/>
       <xsl:sort select="local-name(.)"/>
       <xsl:sequence select="."/>
    </xsl:for-each>

  Complete repro:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:xs="http://www.w3.org/2001/XMLSchema"
                    xmlns:my="..."
                    version="2.0">

       <!--
          Sort a list of attributes, by name.
       -->
       <xsl:function name="my:sort-attrs" as="attribute()*">
          <xsl:param name="attrs" as="attribute()*"/>
          <xsl:for-each select="$attrs">
             <xsl:sort select="node-name(.)"/>
             <xsl:sequence select="."/>
          </xsl:for-each>
       </xsl:function>

       <!--
          Output attribute values, with attributes sorted by name.
       -->
       <xsl:template name="main">
          <xsl:variable name="elem" as="element()">
             <dummy one="1" two="2" three="3" four="4"/>
          </xsl:variable>
          <xsl:value-of select="my:sort-attrs($elem/@*)" separator=", "/>
       </xsl:template>

    </xsl:stylesheet>

  Regards,

--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/