🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.text.xml
Article #10198

Supprimer un doublon

#10198
From: Rapha�l THERY
Date: Tue, 28 Nov 2000 00:00
50 lines
2038 bytes
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: <72MU5.66$Fc.280770@nnrp1.proxad.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: FRENCH,ASCII
X-Google-Thread: 114f60,8a4f3d741be47a82,start
X-Google-Attributes: gid114f60,public
From: "Rapha�l THERY" <raphael.thery@nordnet.fr>
Subject: Supprimer un doublon
Date: 2000/11/28
Message-ID: <72MU5.66$Fc.280770@nnrp1.proxad.net>
X-Deja-AN: 698617938
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
X-Complaints-To: abuse@proxad.net
X-Trace: nnrp1.proxad.net 975408387 195.115.154.77 (Tue, 28 Nov 2000 11:46:27 MET)
Organization: Guest of ProXad - France
X-MSMail-Priority: Normal
NNTP-Posting-Date: Tue, 28 Nov 2000 11:46:27 MET
Newsgroups: fr.comp.text.xml