Re: transformation xml-xml

Tiscar Sebastien <[email protected]>
Newsgroups gmane.text.xml.french.tech
Message-ID <007601c65a60$0fd782a0$a7021cac@ODIN11>
non testé
<xsl:template match="SAP"><xsl:apply-templates/></xsl:template>

<xsl:template match="ficheInformation"><xsl:element
name="Information"><xsl:apply-templates/></xsl:element></xsl:template>

<xsl:template match="NE | DS"><xsl:element
name="doc">Interne</xsl:element></xsl:template>

<xsl:template match="IM"><xsl:element
name="doc">Externe</xsl:element></xsl:template>

<xsl:template match="*"><xsl:apply-templates/></xsl:template>



----- Original Message -----
From: "antisavicarth" <[email protected]>
To: <[email protected]>
Sent: Friday, April 07, 2006 4:10 PM
Subject: [xml-tech] transformation xml-xml



Voici le fichier de départ : SAPinput2.xml
<?xml version="1.0" encoding="UTF-16"?>
<SAP xsi:noNamespaceSchemaLocation="SAP.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ficheInformation>
<fiche>
<document>
<NE/>
</document>
</fiche>
<fiche>
<document>
<NE/>
</document>
</fiche>
<fiche>
<document>
<IM/>
</document>
</fiche>
<fiche>
<document>
<DS/>
</document>
</fiche>
</ficheInformation>
</SAP>

Je veux le transformer en utilisant XSLT pour obtenir en sortie le fichier
suivant : SAPoutputModel2.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<Information>
<ficheInfo>
<doc>Interne</doc>
</ficheInfo>
<ficheInfo>
<doc>Interne</doc>
</ficheInfo>
<ficheInfo>
<doc>Externe</doc>
</ficheInfo>
<ficheInfo>
<doc>Interne</doc>
</ficheInfo>
</Information>

Voici le fichier de transformation : SAP02.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--modification de encoding-->
<xsl:output method="xml" encoding="ISO-8859-1" indent="yes"/>
<xsl:template match="/SAP">
<xsl:for-each select="ficheInformation">
<Information>
<xsl:for-each select="fiche">
<ficheInfo>
<doc>
<xsl:apply-templates select="document"/>
</doc>
</ficheInfo>
</xsl:for-each>
</Information>
</xsl:for-each>
</xsl:template>
<xsl:template match="document">
<xsl:for-each select="descendant::*">
<xsl:copy-of select="local-name()"/>
<!--c'est là que je devrais opérer la sélection:
si enfants de <document> = NE ou DS alors renvoyer Interne en sortie
si enfants de <document> = IM alors renvoyer Externe en sortie-->
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


Voici ce que SAP02.xsl me retourne en output : SAPoutput02.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<Information>
<ficheInfo>
<doc>NE</doc>
</ficheInfo>
<ficheInfo>
<doc>NE</doc>
</ficheInfo>
<ficheInfo>
<doc>IM</doc>
</ficheInfo>
<ficheInfo>
<doc>DS</doc>
</ficheInfo>
</Information>

Je n'arrive pas à faire le changement de valeur en sortie selon la
condition commentée dans le fichier SAP02.xsl
Merci de venir à mon aide.


--
Devenez redacteur <XML>fr et contribuez au developpement du
xml francophone (http://xmlfr.org/infos/redacteurs/) !

Liste de diffusion "[email protected]" (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 [email protected]
(mailto:[email protected]?Subject=unsubscribe)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.