Article View: fr.comp.text.xml
Article #10199Re: Supprimer un doublon
From: Rapha�l THERY
Date: Tue, 28 Nov 2000 00:00
Date: Tue, 28 Nov 2000 00:00
70 lines
2786 bytes
2786 bytes
J'ai enfin trouv� .... si cela interesse !
Gr�ce au tri j'ai pu utiliser une variable !
<xsl:template match="root">
<xsl:element name="Resultat" >
<xsl:variable name="maVariable" select="" />
<xsl:for-each select="*" >
<xsl:sort select="@nom" order="ascending" />
<xsl:if test="$maVariable = @nom">
<xsl:apply-templates select="." />
</xsl:if>
<xsl:variable name="maVariable" select="@nom" />
</xsl:for-each>
</xsl:element></xsl:template>
Rapha�l THERY <raphael.thery@nordnet.fr> a �crit dans le message :
72MU5.66$Fc.280770@nnrp1.proxad.net...
> Certes la question a d�j� �t� pos�e mais sans r�ponses ....
>
> j'ai un flux xml
> <root>
> <champ nom="toto" .... />
> <champ nom="titi" .... />
> <champ nom="tutu" .... />
> <champ nom="tutu" .... />
> <champ nom="tata" .... />
> <champ nom="toto" .... />
> <champ nom="tata" .... />
> <champ nom="titi" .... />
> <champ nom="titi" .... />
> </root>
>
> je voudrais supprimer les doublons pour n'avoir plus que ;
> <root>
> <champ nom="toto" .... />
> <champ nom="titi" .... />
> <champ nom="tutu" .... />
> <champ nom="tata" .... />
> </root>
>
> pour cela j'applique une feuille de styles :
> (l'objet : Parcourir la liste des �l�ments "champ" et cr�er un noeud s'il
> n'existe pas d�j� dans le noeud r�sultat !)
> <xsl:template match="root">
> <xsl:element name="Resultat" >
> <xsl:for-each select="*" >
> <xsl:sort select="@nom" order="ascending" />
> <xsl:variable name="monNom" select="@nom" />
> <xsl:if test="not($monNom=//Resultat/Champ[@nom])">
> <xsl:apply-templates select="." />
> </xsl:if>
> </xsl:for-each>
> </xsl:element>
> </xsl:template>
>
> <xsl:template match="Champ">
> <xsl:element name="Champ">
> <xsl:attribute name="nom">
> <xsl:value-of select="@nom" />
> </xsl:attribute>
> </xsl:element>
> </xsl:template>
>
> bien evidemment cela ne marche pas (je soup�onne le test if)
>
> merci pour vos conseils
> Rapha�l
>
>
Technical Details
Message-ID:
<0kMU5.25$P8.119926@nnrp2.proxad.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<72MU5.66$Fc.280770@nnrp1.proxad.net>Show Full Headers
Complete Article Headers
X-Google-Language: FRENCH,ASCII X-Google-Thread: 114f60,8a4f3d741be47a82 X-Google-Attributes: gid114f60,public From: "Rapha�l THERY" <raphael.thery@nordnet.fr> Subject: Re: Supprimer un doublon Date: 2000/11/28 Message-ID: <0kMU5.25$P8.119926@nnrp2.proxad.net> X-Deja-AN: 698623114 References: <72MU5.66$Fc.280770@nnrp1.proxad.net> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Complaints-To: abuse@proxad.net X-Trace: nnrp2.proxad.net 975409532 195.115.154.77 (Tue, 28 Nov 2000 12:05:32 CET) Organization: Guest of ProXad - France X-MSMail-Priority: Normal NNTP-Posting-Date: Tue, 28 Nov 2000 12:05:32 CET Newsgroups: fr.comp.text.xml