xsl-list
[Top] [All Lists]

Re: Identity Transform Grouping Question

2004-11-06 04:34:20
ethan(_dot_)kalfus(_at_)ubs(_dot_)com wrote:

        <xsl:key name="offices" match="office" 
use="concat(cities/city[(_at_)lang='en'],'-',names/name[(_at_)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[(_at_)lang='en'])[1])=1]">
                                        <xsl:sort 
select="city[(_at_)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


<Prev in Thread] Current Thread [Next in Thread>