W3C home > Mailing lists > Public > xsl-editors@w3.org > January to March 2002

RE: XSL sort

From: Kay, Michael <Michael.Kay@softwareag.com>
Date: Wed, 9 Jan 2002 16:43:06 +0100
Message-ID: <DFF2AC9E3583D511A21F0008C7E6210622B8D7@daemsg02.software-ag.de>
To: "'Kevin O'Riordan'" <koriordan99@hotmail.com>, xsl-editors@w3.org
Thanks for the comment. I agree that it's a little inelegant. Unfortunately
it isn't really feasible to use an attribute because there can be multiple
sort keys. Nor is it really feasible to change the current syntax, which is
now well-established, even if we could come up with something that's
obviously better.
 
You do have the option with XSLT 2.0 to write a top-level sort key
specification, using <xsl:sort-key>, and then to reference it in the select
expression:
 
<xsl:for-each select="sort('sort-key-1', catalog/cd)">
   ...
</xsl:for-each>
 
Thanks for the comment.
 
Mike Kay

-----Original Message-----
From: Kevin O'Riordan [mailto:koriordan99@hotmail.com]
Sent: 09 January 2002 12:39
To: xsl-editors@w3.org
Subject: XSL sort


Hi
I haven't looked in any great detail at the new spec so my apologies of
these comments are irrelevant:
 
Consider the following snippet from an xsl file taken from the w3c schools
tutorial:
 
 
<xsl:for-each select="catalog/cd">
      <xsl:sort select="artist"/>
      <tr>
        <td><xsl:value-of select="title"/></td>
        <td><xsl:value-of select="artist"/></td>
      </tr>
</xsl:for-each>
 
 
 
 
Apart from the nested sort, the xsl nexted within the 'for each' block acts
on each specific  'cd' element found in the xml file to be transformed.
In my view, it is unintuitive and confusing to have the 'sort'  instruction
at this level when it really pertains to the whole iteration. I think a
syntax
like this makes more intuitive sense.
 
 
<xsl:for-each select="catalog/cd"   sort="artist">
        <tr>
        <td><xsl:value-of select="title"/></td>
        <td><xsl:value-of select="artist"/></td>
      </tr>
</xsl:for-each>
 
 
Regards
Kevin O'Riordan
 
 
 
 

 
 
 
 
 
Received on Wednesday, 9 January 2002 10:43:22 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:59:52 GMT