<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:variable name="nl" select="'&#xA;'"/>

<xsl:key name="State" match="Store" use="StoreState"/>
<xsl:key name="City" match="Store" use="concat(StoreState, '-', StoreCity)"/>

<xsl:template match="/">
	<xsl:for-each select="//Store[generate-id() = generate-id( key('State', StoreState)[1] ) ]">
		<xsl:sort select="StoreState"/>
		<xsl:variable name="state" select="StoreState"/>
		<xsl:call-template name="decode_state">
			<xsl:with-param name="id" select="$state"/>
		</xsl:call-template>
		<xsl:value-of select="$nl"/>
		<xsl:for-each select="//Store[generate-id() = generate-id( key('City', concat($state, '-', StoreCity))[1] ) ]">
			<xsl:sort select="StoreCity"/>
			<xsl:variable name="city" select="StoreCity"/>
			<xsl:value-of select="StoreCity"/>
			<xsl:value-of select="$nl"/>
			<xsl:for-each select="key('City', concat($state, '-', $city))">
				<xsl:value-of select="StoreName"/>
				<xsl:value-of select="$nl"/>
			</xsl:for-each>
			<xsl:value-of select="$nl"/>
		</xsl:for-each>
		<xsl:value-of select="$nl"/>
		<xsl:value-of select="$nl"/>
	</xsl:for-each>
</xsl:template>

<xsl:template name="decode_state">
	<xsl:param name="id"/>

	<xsl:choose>
		<xsl:when test="$id='WA'">Washington</xsl:when>
		<xsl:when test="$id='ID'">Idaho</xsl:when>
	</xsl:choose>
</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2007. Progress Software Corporation. All rights reserved.

<metaInformation>
	<scenarios>
		<scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="store.xml" htmlbaseurl="" outputurl="" processortype="saxon8" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml=""
		          commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator="">
			<advancedProp name="sInitialMode" value=""/>
			<advancedProp name="bXsltOneIsOkay" value="true"/>
			<advancedProp name="bSchemaAware" value="true"/>
			<advancedProp name="bXml11" value="false"/>
			<advancedProp name="iValidation" value="0"/>
			<advancedProp name="bExtensions" value="true"/>
			<advancedProp name="iWhitespace" value="0"/>
			<advancedProp name="sInitialTemplate" value=""/>
			<advancedProp name="bTinyTree" value="true"/>
			<advancedProp name="bWarnings" value="true"/>
			<advancedProp name="bUseDTD" value="false"/>
			<advancedProp name="iErrorHandling" value="fatal"/>
		</scenario>
	</scenarios>
	<MapperMetaTag>
		<MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
		<MapperBlockPosition></MapperBlockPosition>
		<TemplateContext></TemplateContext>
		<MapperFilter side="source"></MapperFilter>
	</MapperMetaTag>
</metaInformation>
-->