[xsl] Customised sorting

Subject: [xsl] Customised sorting
From: Mille Eriksson <mille.eriksson@xxxxxxxxxxxxxxxxx>
Date: Thu, 05 Apr 2001 09:30:57 +0200
In Michael Kay's book XSLT - Programmer's reference, the following
example is given on getting data into groups (pages 560-561):

	<city name="Paris" country="France"/>
	<city name="Roma" country="Italy"/>
	<city name="Nice" country="France"/>
	<city name="Madrid" country="Espana"/>
	<city name="Milano" country="Italia"/>
	<city name="Firenze" country="Italia"/>
	<city name="Napoli" country="Italia"/>
	<city name="Lyon" country="France"/>
	<city name="Barcelona" country="Espana"/>

The grouping of the data is done with the following stylesheet:

<xsl:template match="/">
	<xsl:variable name="unique-countries"
		<xsl:for-each select="$unique-countries">
			<country name="{.}">
				<xsl:for-each select="//city[@country=current()]">
						<xsl:value-of select="@name"/>

Resulting in:

	<country name="France">
	and so on

Now, my problem is very similar to this example but with the addition
that I need to sort the groups in a specific order. In the example this
would correspond to order the groups for example by the size of captial
of each country. This ordering information needs to bes supplied with
the style-sheet and not with the XML-document.

Are there any ideas of how this can be accomplished?

Thanks in advance
Mille Eriksson

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread