IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

XSL/XSLT/XPATH XML Discussion :

XSLT mise en form XML


Sujet :

XSL/XSLT/XPATH XML

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 26
    Points : 9
    Points
    9
    Par défaut XSLT mise en form XML
    Bonjour à tous,
    J'espère que quelqu'un pourra m'aider sur ce problème. J'ai écrit un code code XSL pour un fichier XML, mais j'ai un problème le mise en forme s'affiche mais sans les donnée... C'est un problème !!! et ca fait 2 jours que je tourne en rond...
    le voici mon code
    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
     
     
    <?xml version="1.0" encoding="utf-8"?>
     
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     
      <xsl:template match="/">
        <html>
          <head>
            <title>Lettre d'information 001 du CIAA (Centre Informatique Assistance et Applications)</title>
            <style>
              body {margin:0;background-color: #0E747B;;text-align:center; }
              ul {list-style-type:square;}
              .page {background-color:white; width:800px;}
              .title {font-family: arial;	text-align: center;	color: #A1C3C9;	font-weight: bold;font-size: 16px;}
              .demande {color: #2B525D;font-size: 12px;font-family: Arial;	font-style: normal;	font-weight: bold;}
              .domaine {color: #2B525D;font-size: 12px;font-family: Arial;	font-style: normal;	font-weight: bold;}
              .grdAltItem { background-color: #F7F7F7; color: #2B525D;font-size: 12px;font-family: Arial;	font-style: normal;	font-weight: normal;}
              .grdItem { background-color: #BED5D9;color: #2B525D;font-size: 12px;font-family: Arial;	font-style: normal;	font-weight: normal;}
              .pageHeader {background-color: #2b525d;color: #F7F7F7;font-size: 16px;font-family: Arial;font-style: normal;font-weight: bold;text-align: center;}
              .grdHeader {background-color: #2b525d;color: #F7F7F7;font-size: 12px;font-family: Arial;font-style: normal;font-weight: bold;text-align: center;}
              .default_text {	font-family: Arial;	font-size: 12px;	font-style: normal;	text-align: left;}
              .txtLabel {	font-family: Arial;	font-size: 12px;font-style: italic;	font-weight: normal;color: #2B525D;text-align: left;}
              .tableau {border: 1px solid #A5ACB2;width: 100%; cellspacing:1;}
            </style>
          </head>
          <body>
            <!--
            This is an XSLT template file. Fill in this area with the
            XSL elements which will transform your XML to XHTML.
        -->
     
     
     
              <table class="page">
                <tr>
                  <td>
                    <h1 class="pageHeader">Lettre d'information </h1>
     
                    <table class="tableau">
                      <tr class="grdHeader">
                        <td>ID du Produit</td>
                        <td>Satut</td>
                        <td>Libellé du Produit</td>
                        <td>Pays</td>
                        <td>Date validation</td>
                        <td>Date Ordre</td>
                        <td>Numéro Pays</td>
                      </tr>
     
                      <xsl:for-each select="ListeNegocs/ListeNegoc">
                        <tr class="grdItem">
                          <td align="center">
                            <xsl:value-of select="ID_PROD_US"></xsl:value-of>
                            <xsl:text></xsl:text>
                          </td>
                          <td align="center">
                            <xsl:value-of select="FG_STATUT"></xsl:value-of>
                            <xsl:text></xsl:text>
                          </td>
                          <td align="center">
                            <xsl:value-of select="LB_PROD_US"></xsl:value-of>
                            <xsl:text></xsl:text>
                          </td>
                          <td align="center">
                            <xsl:value-of select="LB_PAYS"></xsl:value-of>
                            <xsl:text></xsl:text>
                          </td>
                          <td align="center">
                            <xsl:value-of select="DT_VALID"></xsl:value-of>
                            <xsl:text></xsl:text>
                          </td>
                          <td align="center">
                            <xsl:value-of select="DT_ORDRE"></xsl:value-of>
                            <xsl:text></xsl:text>
                          </td>
                          <td align="center">
                            <xsl:value-of select="ID_PAYS"></xsl:value-of>
                            <xsl:text></xsl:text>
                          </td>
     
                        </tr>
                      </xsl:for-each>
                    </table>
     
                  </td>
                </tr>
              </table>
     
          </body>
        </html>
      </xsl:template>
     
    </xsl:stylesheet>
    Et voici le fichier XML qui va avec

    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
     
    <?xml version="1.0" encoding="utf-8"?>
     
    <?xml-stylesheet href="XSLTFile1.xsl" type="text/xsl"?>
     
    <ListeNegocs xmlns="http://tempuri.org/ListeNegoc.xsd">
      <ListeNegoc>
        <ID_PROD_US>3015</ID_PROD_US>
        <FG_STATUT>O</FG_STATUT>
        <LB_PROD_US>Embryon et ovule</LB_PROD_US>
        <LB_PAYS>MARTINIQUE</LB_PAYS>
        <DT_VALID>2011-05-19T00:00:00+02:00</DT_VALID>
        <DT_ORDRE>2011-05-19T11:53:02.673+02:00</DT_ORDRE>
        <ID_PAYS>328</ID_PAYS>
       </ListeNegoc>
    </ListeNegocs>

    Merci par avance

  2. #2
    Modérateur

    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    12 567
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 12 567
    Points : 21 635
    Points
    21 635
    Par défaut
    Tu as oublié que ton document XML a un namespace.

    Il faudrait que tu mettes un truc genre
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    xmlns:neg="http://tempuri.org/ListeNegoc.xsd"
    dans la balise <xsl:stylesheet>

    Puis, mettre à jour tous tes XPath comme ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <xsl:for-each select="neg:ListeNegocs/neg:ListeNegoc">
    Tous les noms de balises doivent y avoir un préfixe.

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 26
    Points : 9
    Points
    9
    Par défaut XSLT for XML
    Citation Envoyé par thelvin Voir le message
    Tu as oublié que ton document XML a un namespace.

    Il faudrait que tu mettes un truc genre
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    xmlns:neg="http://tempuri.org/ListeNegoc.xsd"
    dans la balise <xsl:stylesheet>

    Puis, mettre à jour tous tes XPath comme ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <xsl:for-each select="neg:ListeNegocs/neg:ListeNegoc">
    Tous les noms de balises doivent y avoir un préfixe.
    Bonjour,
    Merci pour ta réponse,

    J'ai rajouté le name space, mais ça ne marche pas. Mais j'ai réécrit bout à bout le XSL et là ça marche... Je ne sais pas pkoi quoi... Le premier qui ne marche pas est écrit sous VS2005 et le second ci-après avec notepad++.
    Voici le code qui marche
    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
     
    <?xml version="1.0" encoding="utf-8"?>
     
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     
      <xsl:template match="/">
        <html>
     
            <head>
              <title>Lettre d'information</title>
              <style>
                body {margin:0;background-color: #0E747B;;text-align:center; }
                ul {list-style-type:square;}
                .page {background-color:white; width:800px;}
                .title {font-family: arial;	text-align: center;	color: #A1C3C9;	font-weight: bold;font-size: 16px;}
                .demande {color: #2B525D;font-size: 12px;font-family: Arial;	font-style: normal;	font-weight: bold;}
                .domaine {color: #2B525D;font-size: 12px;font-family: Arial;	font-style: normal;	font-weight: bold;}
                .grdAltItem { background-color: #F7F7F7; color: #2B525D;font-size: 12px;font-family: Arial;	font-style: normal;	font-weight: normal;}
                .grdItem { background-color: #BED5D9;color: #2B525D;font-size: 12px;font-family: Arial;	font-style: normal;	font-weight: normal;}
                .pageHeader {background-color: #2b525d;color: #F7F7F7;font-size: 16px;font-family: Arial;font-style: normal;font-weight: bold;text-align: center;}
                .grdHeader {background-color: #2b525d;color: #F7F7F7;font-size: 12px;font-family: Arial;font-style: normal;font-weight: bold;text-align: center;}
                .default_text {	font-family: Arial;	font-size: 12px;	font-style: normal;	text-align: left;}
                .txtLabel {	font-family: Arial;	font-size: 12px;font-style: italic;	font-weight: normal;color: #2B525D;text-align: left;}
                .tableau {border: 1px solid #A5ACB2;width: 100%; cellspacing:1;}
              </style>
            </head>
    		<body>       
    	   <!--
            This is an XSLT template file. Fill in this area with the
            XSL elements which will transform your XML to XHTML.
            -->
            <table class="page">
              <tr>
                <td>
    			  <h1 class="pageHeader">Lettre d'information</h1>
                  <h2 class="title">Informations générales</h2>
                  <table class="tableau">
                    <tr class="grdHeader">
                      <th>ID du Produit</th>
                      <th >Satut</th>
                      <th >Libellé du Produit</th>
                      <th >Pays</th>
                      <th >Date validation</th>
                      <th >Date Ordre</th>
                      <th >Numéro Pays</th>
                    </tr>
                    <xsl:for-each select="ListeNegocs/ListeNegoc">
                      <tr class="grdItem">
                        <td align="center">
                          <xsl:value-of select="ID_PROD_US"></xsl:value-of>
                        </td>
                        <td align="center">
                          <xsl:value-of select="FG_STATUT"></xsl:value-of>
                        </td>
                        <td align="center">
                          <xsl:value-of select="LB_PROD_US"></xsl:value-of>
                        </td>
                        <td align="center">
                          <xsl:value-of select="LB_PAYS"></xsl:value-of>
                        </td>
                        <td align="center">
                          <xsl:value-of select="DT_VALID"></xsl:value-of>
                        </td>
                        <td align="center">
                          <xsl:value-of select="DT_ORDRE"></xsl:value-of>
                        </td>
                        <td align="center">
                          <xsl:value-of select="ID_PAYS"></xsl:value-of>
                        </td>
                      </tr>
                    </xsl:for-each>
                  </table>
                </td>
              </tr>
            </table>
          </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>
    Le XML
    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
     
    <?xml version="1.0" encoding="utf-8"?>
    <?xml-stylesheet href="XSLTFile4.xsl" type="text/xsl"?>
     
    <ListeNegocs>
      <ListeNegoc>
        <ID_PROD_US>3015</ID_PROD_US>
        <FG_STATUT>O</FG_STATUT>
        <LB_PROD_US>Abattage</LB_PROD_US>
        <LB_PAYS>GUADELOUPE</LB_PAYS>
        <DT_VALID>2011-06-21T00:00:00+02:00</DT_VALID>
        <DT_ORDRE>2011-06-21T11:43:24.943+02:00</DT_ORDRE>
        <ID_PAYS>327</ID_PAYS>
      </ListeNegoc>
    </ListeNegocs>

  4. #4
    Modérateur

    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    12 567
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 12 567
    Points : 21 635
    Points
    21 635
    Par défaut
    Ça marche parce que tu as enlevé le namespace du document XML. Doh -_-°.

    Si tu as le droit de faire ça, c'est sûr que c'est plus simple.

Discussions similaires

  1. [XSLT] Mise en forme d'un élément dans "complextype" "mixed"
    Par LionelMoi dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 08/06/2010, 20h25
  2. [XSLT] Indexation et mise en forme XML
    Par newguy dans le forum XSL/XSLT/XPATH
    Réponses: 6
    Dernier message: 23/03/2007, 09h41
  3. [XSLT]Mise en forme d'un tableau par categorie
    Par dibox dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 06/12/2006, 16h42
  4. [XSLT] mise en forme de termdefs sur XML perso
    Par Galeenet dans le forum XSL/XSLT/XPATH
    Réponses: 3
    Dernier message: 26/06/2006, 14h51

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo