Re: [xsl] Identity Transform Grouping Question

Subject: Re: [xsl] Identity Transform Grouping Question
From: Geert Josten <Geert.Josten@xxxxxxxxxxx>
Date: Sat, 06 Nov 2004 12:34:20 +0100
ethan.kalfus@xxxxxxx wrote:

<xsl:key name="offices" match="office" use="concat(cities/city[@lang='en'],'-',names/name[@lang='en'])"/>

...


	<!-- reorganize 'country' elements -->
	<xsl:template match="country">
		<country>
			<xsl:copy-of select="@*"/>
			<cities>
				<!-- group 'city' elements within this country -->
				<xsl:variable name="offices-in-this-country">
					<xsl:copy-of select="offices"/>
					<!-- this is a trick, to restrict all subsequent key usage to this country only -->
				</xsl:variable>
				<xsl:apply-templates select="msxsl:node-set($offices-in-this-country)/offices/office/cities[count(.|key('cities',city[@lang='en'])[1])=1]">
					<xsl:sort select="city[@lang='en']"/>
				</xsl:apply-templates>
			</cities>
		</country>
	</xsl:template>

Hi Ethan,


Why use the node-set function here if you could use a key as well?

<xsl:key name="offices-by-country" match="office" use="ancestor::country/@name"/>

Or am I missing something?

Grtz,
Geert

Current Thread