xsl-list
[Top] [All Lists]

RE: generic sort based on attribute names

2005-01-23 16:28:47

Here's a solution using the latter approach:

<xsl:for-each select="e">
 <xsl:sort>
   <xsl:for-each select="@*">
     <xsl:sort select="name()"/>
     <xsl:value-of select='name(), "=""", ., """ "' separator=""/>
   </xsl:for-each>
 </xsl:sort>
 <xsl:copy-of select="."/>
</xsl:for-each>

Saxon 8.2 produces an error message that:

"A sequence of more than one item is not allowed as the @sort-key
attribute of xsl:sort".

OK: you need to wrap it like this:

<xsl:for-each select="e">
 <xsl:sort>
      <xsl:value-of>
   <xsl:for-each select="@*">
     <xsl:sort select="name()"/>
     <xsl:value-of select='name(), "=""", ., """ "' separator=""/>
   </xsl:for-each>
      </xsl:value-of>
 </xsl:sort>
 <xsl:copy-of select="."/>
</xsl:for-each>

Besides this problem, does xsl:sort have a "sort-key" attribute? I
don't see it specified either in the latest WG draft or in the book.

Looks like the error message needs improving... 

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--