xsl-list
[Top] [All Lists]

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

2006-03-29 14:48:28
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/



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--