This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 8398 - [XSLT 2.0] order in result of grouping example is wrong
Summary: [XSLT 2.0] order in result of grouping example is wrong
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 2.0 (show other bugs)
Version: Recommendation
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL: http://www.w3.org/TR/xslt20/#grouping...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-29 14:10 UTC by Martin Honnen
Modified: 2010-07-15 09:35 UTC (History)
0 users

See Also:


Attachments

Description Martin Honnen 2009-11-29 14:10:29 UTC
The example "Grouping Nodes based on Common Values" in http://www.w3.org/TR/xslt20/#grouping-examples shows the following result:

<table>
  <tr>
    <th>Position</th>
    <th>Country</th>
    <th>List of Cities</th>
    <th>Population</th>
  </tr>
  <tr>
    <td>1</td>
    <td>Italia</td>
    <td>Milano, Venezia</td>
    <td>6</td>
  </tr>
  <tr>
    <td>2</td>
    <td>France</td>
    <td>Lyon, Paris</td>
    <td>9</td>
  </tr>  
  <tr>
    <td>3</td>
    <td>Deutschland</td>
    <td>München</td>
    <td>4</td>
  </tr>  
</table>

I think the order in the third cell (List of Cities) in the third row (key France) is wrong, it should be "Paris, Lyon", not "Lyon, Paris", as in the input

  <city name="Milano"  country="Italia"      pop="5"/>
  <city name="Paris"   country="France"      pop="7"/>
  <city name="München" country="Deutschland" pop="4"/>
  <city name="Lyon"    country="France"      pop="2"/>
  <city name="Venezia" country="Italia"      pop="1"/>

city name="Paris" precedes city name="Lyon".
Comment 1 Michael Kay 2009-11-30 11:14:07 UTC
I think one could defend the example on the grounds that the stated requirement is for the output to be "unsorted", i.e. the user does not care what the result order is, and the provided code meets this requirement. However I agree it would be clearer if the published code delivered the published output as shown.
Comment 2 Martin Honnen 2009-11-30 17:57:34 UTC
(In reply to comment #1)
> I think one could defend the example on the grounds that the stated requirement
> is for the output to be "unsorted", i.e. the user does not care what the result
> order is, and the provided code meets this requirement. However I agree it
> would be clearer if the published code delivered the published output as shown.

When I filed this "bug" I had focused on the sample input, output, and XSLT code in the specification. Based on your comment I reread the text accompanying the example again and see that it says "The four columns are to contain [...] third, a comma-separated alphabetical list of the city names within that country". That means the order "Lyon, Paris" is what the textual description specifies, an alphabetical list. Only in that case the XSLT sample does not achieve what the textual description requires, as it outputs "Paris, Lyon".

So somehow the textual description, the sample output and the sample XSLT code need to be aligned.
Comment 3 Michael Kay 2010-05-27 16:39:36 UTC
Decided to fix this by adding the required xsl:sort element to the XSLT
solution of the example.
Comment 4 Michael Kay 2010-07-15 09:35:38 UTC
This will be erratum E47. I am closing the bug anticipating that this resolution is acceptable.