RE: [xsl] Filtering out duplicates in current-group()

Subject: RE: [xsl] Filtering out duplicates in current-group()
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 29 Mar 2006 22:48:05 +0100
> I tried this:
> 
> <xsl:for-each-group select="Song"
> group-by="substring(Year, 1, 3)">
>   <p>Decade: <xsl:value-of
> select="current-grouping-key()"/>0's</p>
>   <xsl:for-each-group select="current-group()"
> group-by="Title">
>     <p style="margin-left: 1pc;">
>      <xsl:apply-templates
> select="current-group()/Title"/>
>     </p>
>   </xsl:for-each-group>
> </xsl:for-each-group>
> 
> but still get two "Strangers in the Night".

Well, your inner current-group() holds two copies of "Strangers in the
Night" and if you apply-templates to both of them, you're going to get both
of them output. The whole point of grouping them is that you process them as
a group, not individually. For example you might do

<p><xsl:apply-templates select="current-group()[1]/Title"/></p>
<p><xsl:apply-templates select="current-group()/*[not(self::Title)]"/></p>

Michael Kay
http://www.saxonica.com/

Current Thread