From: Emmanuel.COLLAIN@tcc.thomson-csf.com
Date: 25/01/2001 - 15:35
Bonjour,
Je cherche à transfomer un fichier XML en un autre avec XSLT.
Le fichier source est de la forme :
<?xml version="1.0"?>
<foo>
<bar ID="I1">
<name>BAR1</name>
</bar>
<bar ID="I2">
<name>BAR2</name>
</bar>
<link>
<from>I1</from>
<to>I2</to>
</link>
</foo>
et je veut obtenir quelque chose de la forme :
<?xml version="1.0" encoding="UTF-8"?>
<foo>
<bar>BAR1</bar>
<bar>BAR2</bar>
<link>
<from>BAR1</from>
<to>BAR2</to>
</link>
</foo>
la feuille de style est de la suivante :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" indent="yes"/>
<xsl:template match="/">
<foo>
<xsl:apply-templates select="foo/bar"/>
<xsl:apply-templates select="foo/link"/>
</foo>
</xsl:template>
<xsl:template match="bar">
<bar><xsl:value-of select="name"/></bar>
</xsl:template>
<xsl:template match="link">
<link>
<from><xsl:value-of select="../bar[@ID = from]/name"/></from>
<to><xsl:value-of select="../bar[@ID = to]/name"/></to>
</link>
</xsl:template>
</xsl:stylesheet>
et j'obtiens :
<?xml version="1.0" encoding="UTF-8"?>
<foo>
<bar>BAR1</bar>
<bar>BAR2</bar>
<link>
<from/>
<to/>
</link>
</foo>
Je cherche donc pour l'élément link le nom d'un élément dont l'ID et celui
de l'élément form ou to.
Y-a-t-il un problème dans le template dans les tests du template link ?
Merci d'avance.
Emmanuel
--
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)
Archive générée par hypermail 2.1.3 le 28/06/2004 - 11:05 UTC
webmaster@xmlfr.org
|