Thread: Ordering lists
View Single Post
 
Old June 9th, 2003, 02:06 AM
armmarti armmarti is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: Nor Hachin, Kotayk, Armenia.
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti
Default

I put all the stuff in the "root template", though it will be better to break it down to several templates:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:variable name="set-of-states" select="/cities/city/stateName[not(. = preceding::stateName)]"/>
        <xsl:for-each select="$set-of-states">
            <xsl:sort select="."/>
            <br/>
            [<xsl:value-of select="."/>]<br/>
            <xsl:for-each select="/cities/city/cityName[../stateName = current()]">
                <xsl:sort select="."/>
                <xsl:value-of select="."/><br/>
            </xsl:for-each>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>