Bonjour à tous,

Comme indiqué dans le titre je débute complètement en XSL, c'est pas faute d'avoir chercher... mais je ne parviens pas à générer un CSV propre.
Je souhaite transformer un XML en CSV en passant par XSL.

J'ai un XML de la structure suivante :

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
 
<?xml version="1.0" encoding="UTF-8"?>
<commandes>
  <commande>
    <commande_numclient>123456</commande_numclient>
    <commande_date>16/07/2009</commande_date>
    <commande_num>100000064</commande_num>
    <commande_emailclient>123456@domaine.fr</commande_emailclient>
    <commande_produit>
      <commande_produit_ref>11020</commande_produit_ref>
      <commande_produit_nom>Tee-Shirt</commande_produit_nom>
      <commande_produit_prix>12.1000</commande_produit_prix>
      <commande_produit_qte>1.0000</commande_produit_qte>
      <commande_produit_totalht>12.1000</commande_produit_totalht>
    </commande_produit>
   <commande_produit>
      <commande_produit_ref>11030</commande_produit_ref>
      <commande_produit_nom>Pull</commande_produit_nom>
      <commande_produit_prix>16.1000</commande_produit_prix>
      <commande_produit_qte>1.0000</commande_produit_qte>
      <commande_produit_totalht>16.1000</commande_produit_totalht>
    </commande_produit>
    <commande_fraislivraison>5.0000</commande_fraislivraison>
    <commande_commentaire>commentaire</commande_commentaire>
    <commande_totalht>38.2000</commande_totalht>
  </commande>
</commandes>
Que je voudrai transformer en CSV (en php) pour qu'il est cette forme :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
commande_numclient,commande_date,commande_num,commande_emailclient,commande_produit_ref,commande_produit_nom,commande_produit_prix,commande_produit_qte,commande_produit_totalht,commande_fraislivraison,commande_commentaire,commande_totalht
"123456","16/07/2009","100000064","123456@domaine.fr","A11020","Tee-Shirt","12,1","1","12,1","5","commentaire","38,2"
"123456","16/07/2009","100000064","123456@domaine.fr","A11030","Pull","16,1","1","16,1","5","commentaire","38,2"
J'ai commencé à faire un XSL mais je galère....

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
<xsl:output method="text" encoding="utf-8"/>
 
  <xsl:template match="commandes">
    <xsl:apply-templates/>
  </xsl:template>
 
<xsl:template match="commande">
    <xsl:apply-templates select="commande_numclient"/>
    <xsl:text>,</xsl:text>
    <xsl:apply-templates select="commande_num"/>
    <xsl:text>,</xsl:text>
    <xsl:apply-templates select="commande_date"/>
 
        <xsl:template match="commande_produit">
            <xsl:apply-templates select="commande_produit_ref"/>
            <xsl:text>,</xsl:text>
            <xsl:apply-templates select="commande_produit_nom"/>
            <xsl:text>,</xsl:text>
            <xsl:apply-templates select="commande_produit_qte"/>
            <xsl:text>,</xsl:text>
            <xsl:apply-templates select="commande_produit_totalht"/>
        </xsl:template>
 
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>
 
  <xsl:template match="commande_numclient">
    <xsl:value-of select="text()"/>
  </xsl:template>
 
  <xsl:template match="commande_num">
    <xsl:value-of select="text()"/>
  </xsl:template>
 
  <xsl:template match="commande_date">
    <xsl:value-of select="text()"/>
  </xsl:template>
 
  <xsl:template match="commande_produit_ref">
    <xsl:value-of select="text()"/>
  </xsl:template>
 
  <xsl:template match="commande_produit_nom">
    <xsl:value-of select="text()"/>
  </xsl:template>
 
  <xsl:template match="commande_produit_qte">
    <xsl:value-of select="text()"/>
  </xsl:template>
 
  <xsl:template match="commande_produit_totalht">
    <xsl:value-of select="text()"/>
  </xsl:template>
 
</xsl:stylesheet>
Est-ce que quelqu'un aurait la gentillesse d'éclairer ma lanterne de newbie

Merci !