This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: 2 unique lists
- To: "'xsl-list at mulberrytech dot com'" <xsl-list at mulberrytech dot com>
- Subject: RE: 2 unique lists
- From: Kay Michael <Michael dot Kay at icl dot com>
- Date: Mon, 7 Aug 2000 18:12:10 +0100
- Reply-To: xsl-list at mulberrytech dot com
>
> and from this I want two unique lists of dates, thus
>
> person1: Feb2000, Mar2000, Apr2000.
> person2: Feb2000, Mar2000, Apr2000.
>
> Here is the first stylesheet, using preceding:
>
> <xsl:template match="person">
> <xsl:value-of select="@name"/><xsl:text>: </xsl:text>
> <xsl:for-each select="date[ not( . = preceding::date )]">
> <xsl:value-of select="."/>
> <xsl:if test="not(position()=last())">, </xsl:if>
> </xsl:for-each>
> </xsl:template>
>
> which produces:
> person1: feb2000, mar2000, Apr2000
> person2:
you want preceding-sibling::date
>
>
> I also tried the key method:
> <xsl:key name="thedate" match="date" use="."/>
>
> <xsl:template match="person">
> <xsl:value-of select="@name"/><xsl:text>: </xsl:text>
> <xsl:for-each select="date[generate-id(.) =
> generate-id(key('thedate',.)[1])]">
> <xsl:value-of select="."/>
> <xsl:if test="not(position()=last())">, </xsl:if>
> </xsl:for-each>
> </xsl:template>
>
> which produced the same result.
You need the key value to idendify not only the date, but also the parent
element. So try <xsl:key name="thedate" match="date"
use="concat(generate-id(..), .)"/>
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list