Bonjour,
j'essaie de transformer un XML en fichier plat(du type CSV), un element du XML est comme celui ci :
J'utilise la tranformation :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 <Utilisateur Id="1221" Nom="Name" Prénom="M" Email="" Login="m.k"> <Chp Id="42" Code="NAI_DEP">99 - Etranger</Chp> <Chp Id="63" Code="ADR">120 rue D </Chp> <Chp Id="66" Code="CIV">Mlle</Chp> <Chp Id="67" Code="CPO">20 500</Chp> <Chp Id="68" Code="NAI">22/01/1986</Chp> <Chp Id="71" Code="NAI_LIEU">CASABLANCA</Chp> <Chp Id="78" Code="VIL">Casablanca</Chp> <Chp Id="95" Code="NAT">MAROCAINE</Chp> <Chp Id="60" Code="NOM_JF"> </Chp> <Chp Id="102" Code="NOM_PERE"> </Chp> <Chp Id="104" Code="PRE_PERE"></Chp> <Chp Id="103" Code="NOM_MERE"></Chp> <Chp Id="105" Code="PRE_MERE"></Chp> <Chp Id="309" Code="ECOLE"></Chp> <Chp Id="64" Code="ADR2"> </Chp> <Chp Id="169" Code="ADR2_F"> </Chp> <Chp Id="168" Code="ADR_F"> </Chp> <Chp Id="171" Code="CPO_F"> </Chp> <Chp Id="172" Code="VIL_F"> </Chp> <Chp Id="91" Code="N_SS"> </Chp> </Utilisateur>
Le résultat
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" encoding="iso-8859-1" indent="no"/> <xsl:template match="/"> <xsl:for-each select="//Utilisateur"> <xsl:value-of select="Chp[@Code='CIV']/text()"/>;<xsl:value-of select="@Nom"/>;<xsl:value-of select="Chp[@Code='NOM_JF']/text()"/>;<xsl:value-of select="Chp[@Code='PRE']/text()"/>;<xsl:value-of select="Chp[@Code='MAI']/text()"/>;<xsl:value-of select="Chp[@Code='NOM_PERE']/text()"/>;<xsl:value-of select="Chp[@Code='PRE_PERE']/text()"/>;<xsl:value-of select="Chp[@Code='NOM_MERE']/text()"/>;<xsl:value-of select="Chp[@Code='PRE_MERE']/text()"/>;<xsl:text>
</xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Comment faire pour que les valeurs des champs n'ayant que des retours chariots n'apparaissent pas ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 Mlle;Name;; ; ;;;;;
moi je voudrais un résultat >>Comment ne pas prendre en compte ce saut de ligne ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part Mlle;Name;;;;;;;;
Partager