This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Remove duplicates from a list
- From: "Joerg Heinicke" <joerg dot heinicke at gmx dot de>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 29 Jan 2002 17:01:49 +0100
- Subject: Re: [xsl] Remove duplicates from a list
- References: <7ED06C84BBC8094087344246675783EB2B7176@osapp.optimal-systems.de>
- Reply-to: xsl-list at lists dot mulberrytech dot com
This is always a grouping problem. For this the best way is using the
Muenchian Method: http://www.jenitennison.com/xslt/grouping/muenchian.html.
You have to group your <OBX> by the Observation_ID:
<xsl:key name="obx" match="OBX" use="@Observation_ID"/>
<xsl:template match="tdObsResults">
<xsl:apply-templates select="OBX[count( . | key( 'obx',
@Observation-ID)[1] ) = 1]"/>
</xsl:template>
<xsl:template match="OBX">
<xsl:value-of select="@Observation_ID"/>
</xsl:templaet>
Regards,
Joerg
----- Original Message -----
From: "Asim Tozlu" <Tozlu@optimal-systems.de>
To: <XSL-List@lists.mulberrytech.com>
Sent: Tuesday, January 29, 2002 4:31 PM
Subject: [xsl] Remove duplicates from a list
> Hi,
>
> i'm XSL-newbi. I have this XML:
>
> <tdObsResults>
> <OBX ObservationDT="2001-11-05T08:00:00"
> Observation_ID="1742-6"/>
> <OBX ObservationDT="2001-11-05T08:00:00"
> Observation_ID="1232-6"/>
> <OBX ObservationDT="2001-11-03T08:00:00"
> Observation_ID="1685-6"/>
> <OBX ObservationDT="2001-11-02T08:00:00"
> Observation_ID="1742-6"/>
> <OBX ObservationDT="2001-11-08T08:00:00"
> Observation_ID="1742-6"/>
> <OBX ObservationDT="2001-11-03T08:00:00"
> Observation_ID="1685-6"/>
> </tdObsResults>
>
> and i need this Result
> 1742-6
> 1232-6
> 1685-6
>
> Thanks for a Tip
>
> Asim
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list