Bonjour,
Voilà ce que je vous propose pourvu que votre document en entrée ne soit
pas trop volumineux :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Units>
<xsl:for-each
select="/Units/UnitType[not(preceding-sibling::UnitType=.)]">
<Unit>
<xsl:variable name="current" select="."/>
<xsl:copy-of select="."/>
<NumberOfUnits><xsl:value-of
select="count(parent::*/UnitType[.=$current])"/></NumberOfUnits>
</Unit>
</xsl:for-each>
</Units>
</xsl:template>
</xsl:stylesheet>
Bien cordialement,
Alain COUTHURES
<agenceXML>
http://www.agencexml.com
Aguero, Dimitri a écrit :
> Bonjour,
>
> Est-ce qu'il y aurait un moyen de convertir
>
> <Units>
> <UnitType>STB</UnitType>
> <UnitType>LNK-ROUTER-123</UnitType>
> <UnitType>DKTbox</UnitType>
> <UnitType>STB</UnitType>
> <UnitType>STB</UnitType>
> <UnitType>DKTbox</UnitType>
> </Units>
>
> Dans:
>
> <Units>
> <Unit>
> <UnitType>STB</UnitType>
> <NumberOfUnits>3</ NumberOfUnits >
> </Unit>
> <Unit>
> <UnitType> LNK-ROUTER-123</UnitType>
> <NumberOfUnits>1</ NumberOfUnits >
> </Unit>
> <Unit>
> <UnitType> DKTbox </UnitType>
> <NumberOfUnits>2</ NumberOfUnits >
> </Unit>
> </Units>
>
> Et ce, avec une seule transformation ?
> Merci d'avance de toute aide
>
> Cordialement
> Dimitri
>
> --
> Devenez redacteur <XML>fr et contribuez au developpement du
> xml francophone (http://xmlfr.org/infos/redacteurs/) !
>
> Liste de diffusion "xml-tech@xmlfr.org" (http://xmlfr.org).
>
> Cette liste est a votre disposition pour discuter en francais de
> tout sujet technique lie a XML.
>
> Pour resilier votre abonnement, envoyez un message contenant
> la commande "unsubscribe" a xml-tech-request@xmlfr.org
> (mailto:xml-tech-request@xmlfr.org?Subject=unsubscribe)
>
>
>
--
Devenez redacteur <XML>fr et contribuez au developpement du
xml francophone (http://xmlfr.org/infos/redacteurs/) !
Liste de diffusion "xml-tech@xmlfr.org" (http://xmlfr.org).
Cette liste est a votre disposition pour discuter en francais de
tout sujet technique lie a XML.
Pour resilier votre abonnement, envoyez un message contenant
la commande "unsubscribe" a xml-tech-request@xmlfr.org
(mailto:xml-tech-request@xmlfr.org?Subject=unsubscribe)
Received on Thu Mar 27 15:18:40 2008