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] Obtenir la valeur d'un noeud namespacé


Sujet :

XSL/XSLT/XPATH XML

  1. #1
    Candidat au Club
    Inscrit en
    Mai 2010
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Mai 2010
    Messages : 4
    Points : 2
    Points
    2
    Par défaut [XSLT] Obtenir la valeur d'un noeud namespacé
    Bonjour,

    Je me résigne à poster ici mon problème en espérant trouver de l'aide car je n'ai pas fait de XSLT depuis un bon petit moment et je me casse la tête sur ce problème qui me semble pourtant simple.

    J'essaie de transformer en une table HTML les résultats de mon flux RSS. Mon flux RSS se présente sous cette forme :

    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
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    <rss version="2.0">
      <channel xmlns:dmx="http://www.bring2mind.net/dmx">
        <title>Bibliothèque de fichiers</title>
        <copyright/>
        <link>http://www.monurl.com/tabid/0/language/fr-FR/Default.aspx</link>
        <language>fr-FR</language>
        <description>Document Exchange Feed</description>
        <item>
          <title>ResourcePack.SimpleGallery.02.03.17.fr-FR</title>
          <description/>
          <link>http://www.monurl.com/tabid/0/language/fr-FR/Default.aspx?Command=Core_Download&amp;EntryId=81</link>
          <author>email@email.com</author>
          <guid>http://www.monurl.com/tabid/0/language/fr-FR/Default.aspx?Command=Core_Download&amp;EntryId=81</guid>
          <pubDate>Thu, 10 Dec 2009 23:20:41 GMT</pubDate>
          <dmx:Author>SuperUser Account</dmx:Author>
          <dmx:CollectionId>69</dmx:CollectionId>
          <dmx:Created>2009-12-08 12:41:38Z</dmx:Created>
          <dmx:LastModified>2009-12-10 23:20:41Z</dmx:LastModified>
          <dmx:EntryId>81</dmx:EntryId>
          <dmx:EntryType>File.Zip</dmx:EntryType>
          <dmx:FileSize>39580</dmx:FileSize>
          <dmx:Keywords/>
          <dmx:OriginalFileName>ResourcePack.SimpleGallery.02.03.17.fr-FR.zip</dmx:OriginalFileName>
          <dmx:Version>1</dmx:Version>
          <dmx:FolderTitle>Ventrian</dmx:FolderTitle>
          <dmx:Icon16>http://www.monurl.com/DesktopModules/Bring2mind/DMX/images/File.Zip.Gif</dmx:Icon16>
          <dmx:att2 dmx:name="Editeur">Core</dmx:att2>
          <dmx:att3 dmx:name="Nom du module"></dmx:att3>
          <dmx:att4 dmx:name="Site web de l'éditeur">www..com</dmx:att4>
          <dmx:att5 dmx:name="Version du module">4.3.7</dmx:att5>
          <dmx:att6 dmx:name="Commentaire de traduction">Repris de l'existant. Aucune note de traduction.</dmx:att6>
        </item>
        <item>
          <title>ResourcePack.Core.04.03.07.fr-FR</title>
          <description/>
          <link>http://www.monurl.com/tabid/0/language/fr-FR/Default.aspx?Command=Core_Download&amp;EntryId=49</link>
          <author>email@email.com</author>
          <guid>http://www.monurl.com/tabid/0/language/fr-FR/Default.aspx?Command=Core_Download&amp;EntryId=49</guid>
          <pubDate>Thu, 10 Dec 2009 23:13:57 GMT</pubDate>
          <dmx:Author>SuperUser Account</dmx:Author>
          <dmx:CollectionId>7</dmx:CollectionId>
          <dmx:Created>2009-12-08 12:36:00Z</dmx:Created>
          <dmx:LastModified>2009-12-10 23:13:57Z</dmx:LastModified>
          <dmx:EntryId>49</dmx:EntryId>
          <dmx:EntryType>File.Zip</dmx:EntryType>
          <dmx:FileSize>153914</dmx:FileSize>
          <dmx:Keywords/>
          <dmx:OriginalFileName>ResourcePack.Core.04.03.07.fr-FR.zip</dmx:OriginalFileName>
          <dmx:Version>1</dmx:Version>
          <dmx:FolderTitle>Noyau</dmx:FolderTitle>
          <dmx:Icon16>http://www.monurl.com/DesktopModules/Bring2mind/DMX/images/File.Zip.Gif</dmx:Icon16>
          <dmx:att2 dmx:name="Editeur">Core</dmx:att2>
          <dmx:att3 dmx:name="Nom du module"></dmx:att3>
          <dmx:att4 dmx:name="Site web de l'éditeur">www..com</dmx:att4>
          <dmx:att5 dmx:name="Version du module">4.3.7</dmx:att5>
          <dmx:att6 dmx:name="Commentaire de traduction">Repris de l'existant. Aucune note de traduction.</dmx:att6>
        </item>
        <item>
          <title>ResourcePack.Simple Gallery.02.02.06.fr-FR</title>
          <description/>
          <link>http://www.monurl.com/tabid/0/language/fr-FR/Default.aspx?Command=Core_Download&amp;EntryId=80</link>
          <author>email@email.com</author>
          <guid>http://www.monurl.com/tabid/0/language/fr-FR/Default.aspx?Command=Core_Download&amp;EntryId=80</guid>
          <pubDate>Tue, 08 Dec 2009 12:41:37 GMT</pubDate>
          <dmx:Author>SuperUser Account</dmx:Author>
          <dmx:CollectionId>69</dmx:CollectionId>
          <dmx:Created>2009-12-08 12:41:37Z</dmx:Created>
          <dmx:LastModified>2009-12-08 12:41:37Z</dmx:LastModified>
          <dmx:EntryId>80</dmx:EntryId>
          <dmx:EntryType>File.Zip</dmx:EntryType>
          <dmx:FileSize>38067</dmx:FileSize>
          <dmx:Keywords/>
          <dmx:OriginalFileName>ResourcePack.Simple Gallery.02.02.06.fr-FR.zip</dmx:OriginalFileName>
          <dmx:Version>1</dmx:Version>
          <dmx:FolderTitle>Ventrian</dmx:FolderTitle>
          <dmx:Icon16>http://www.monurl.com/DesktopModules/Bring2mind/DMX/images/File.Zip.Gif</dmx:Icon16>
        </item>
        <item>
          <title>ResourcePack.Quotes.01.01.01.fr-FR</title>
          <description/>
          <link>http://www.monurl.com/tabid/0/language/fr-FR/Default.aspx?Command=Core_Download&amp;EntryId=79</link>
          <author>email@email.com</author>
          <guid>http://www.monurl.com/tabid/0/language/fr-FR/Default.aspx?Command=Core_Download&amp;EntryId=79</guid>
          <pubDate>Tue, 08 Dec 2009 12:41:37 GMT</pubDate>
          <dmx:Author>SuperUser Account</dmx:Author>
          <dmx:CollectionId>69</dmx:CollectionId>
          <dmx:Created>2009-12-08 12:41:37Z</dmx:Created>
          <dmx:LastModified>2009-12-08 12:41:37Z</dmx:LastModified>
          <dmx:EntryId>79</dmx:EntryId>
          <dmx:EntryType>File.Zip</dmx:EntryType>
          <dmx:FileSize>4147</dmx:FileSize>
          <dmx:Keywords/>
          <dmx:OriginalFileName>ResourcePack.Quotes.01.01.01.fr-FR.zip</dmx:OriginalFileName>
          <dmx:Version>1</dmx:Version>
          <dmx:FolderTitle>Ventrian</dmx:FolderTitle>
          <dmx:Icon16>http://www.monurl.com/DesktopModules/Bring2mind/DMX/images/File.Zip.Gif</dmx:Icon16>
        </item>
        <item>
          <title>ResourcePack.PropertyAgent.01.07.12.fr-FR</title>
          <description/>
          <link>http://www.monurl.com/tabid/0/language/fr-FR/Default.aspx?Command=Core_Download&amp;EntryId=78</link>
          <author>email@email.com</author>
          <guid>http://www.monurl.com/tabid/0/language/fr-FR/Default.aspx?Command=Core_Download&amp;EntryId=78</guid>
          <pubDate>Tue, 08 Dec 2009 12:41:36 GMT</pubDate>
          <dmx:Author>SuperUser Account</dmx:Author>
          <dmx:CollectionId>69</dmx:CollectionId>
          <dmx:Created>2009-12-08 12:41:36Z</dmx:Created>
          <dmx:LastModified>2009-12-08 12:41:36Z</dmx:LastModified>
          <dmx:EntryId>78</dmx:EntryId>
          <dmx:EntryType>File.Zip</dmx:EntryType>
          <dmx:FileSize>45127</dmx:FileSize>
          <dmx:Keywords/>
          <dmx:OriginalFileName>ResourcePack.PropertyAgent.01.07.12.fr-FR.zip</dmx:OriginalFileName>
          <dmx:Version>1</dmx:Version>
          <dmx:FolderTitle>Ventrian</dmx:FolderTitle>
          <dmx:Icon16>http://www.monurl.com/DesktopModules/Bring2mind/DMX/images/File.Zip.Gif</dmx:Icon16>
        </item>
        <item>
          <title>ResourcePack.Property Agent.01.03.04.fr-FR</title>
          <description/>
          <link>http://www.monurl.com/tabid/0/language/fr-FR/Default.aspx?Command=Core_Download&amp;EntryId=77</link>
          <author>email@email.com</author>
          <guid>http://www.monurl.com/tabid/0/language/fr-FR/Default.aspx?Command=Core_Download&amp;EntryId=77</guid>
          <pubDate>Tue, 08 Dec 2009 12:41:35 GMT</pubDate>
          <dmx:Author>SuperUser Account</dmx:Author>
          <dmx:CollectionId>69</dmx:CollectionId>
          <dmx:Created>2009-12-08 12:41:35Z</dmx:Created>
          <dmx:LastModified>2009-12-08 12:41:35Z</dmx:LastModified>
          <dmx:EntryId>77</dmx:EntryId>
          <dmx:EntryType>File.Zip</dmx:EntryType>
          <dmx:FileSize>30595</dmx:FileSize>
          <dmx:Keywords/>
          <dmx:OriginalFileName>ResourcePack.Property Agent.01.03.04.fr-FR.zip</dmx:OriginalFileName>
          <dmx:Version>1</dmx:Version>
          <dmx:FolderTitle>Ventrian</dmx:FolderTitle>
          <dmx:Icon16>http://www.monurl.com/DesktopModules/Bring2mind/DMX/images/File.Zip.Gif</dmx:Icon16>
        </item>
      </channel>
    </rss>
    Pour ce faire, j'utilise le fichier XSLT suivant :

    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
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dmx="http://www.bring2mind.com/dmx">
      <xsl:output method="html" indent="yes"/>
      <xsl:param name="ItemsToShow"/>
      <xsl:param name="ShowItemDetails"/>
      <xsl:param name="ShowItemDate"/>
      <xsl:param name="Locale"/>
      <xsl:template match="rss">
        <table summary="Last Language Pack Table" id="businessTable">
          <thead>
            <tr>
              <th scope="col"> <span>Editeur</span> </th>
              <th scope="col"> <span>Module</span> </th>
              <th scope="col"> <span>Version</span> </th>
            </tr>
          </thead>
          <tbody>
            <xsl:for-each select="channel/item[position()&lt;=$ItemsToShow or $ItemsToShow&lt;1]">
              <tr class="sub">
                <td class="head">Ici j'aimerai afficher la valeur de chaque dmx:att2</td>
                <td>Ici j'aimerai afficher la valeur de chaque dmx:att3</td>
                <td>Ici j'aimerai afficher la valeur de chaque dmx:att4</td>
              </tr>
            </xsl:for-each>
          </tbody>
        </table>
      </xsl:template>
    </xsl:stylesheet>
    Comment afficher la valeur du noeud dmx:att2 ???

    Merci par avance pour toute aide que vous pourrez m'apporter

    Sébastien

  2. #2
    Membre expérimenté
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    1 466
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 1 466
    Points : 1 610
    Points
    1 610
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <xsl:value-of select="dmx:att2"/>

  3. #3
    Candidat au Club
    Inscrit en
    Mai 2010
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Mai 2010
    Messages : 4
    Points : 2
    Points
    2
    Par défaut
    Citation Envoyé par Morbo Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <xsl:value-of select="dmx:att2"/>
    Cela ne fonctionne pas. Une autre idée ?

  4. #4
    Rédacteur

    Avatar de Erwy
    Homme Profil pro
    Développeur Web
    Inscrit en
    Novembre 2003
    Messages
    4 967
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Novembre 2003
    Messages : 4 967
    Points : 10 927
    Points
    10 927
    Par défaut
    La solution de Morbo est la bonne mais tu t'es planté dans les déclarations
    dans ton XML
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    xmlns:dmx="http://www.bring2mind.net/dmx
    Dans ton XSLT
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    xmlns:dmx="http://www.bring2mind.com/dmx
    C'est pour cela que cela ne marche pas

  5. #5
    Candidat au Club
    Inscrit en
    Mai 2010
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Mai 2010
    Messages : 4
    Points : 2
    Points
    2
    Par défaut
    Citation Envoyé par Erwy Voir le message
    La solution de Morbo est la bonne mais tu t'es planté dans les déclarations
    dans ton XML
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    xmlns:dmx="http://www.bring2mind.net/dmx
    Dans ton XSLT
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    xmlns:dmx="http://www.bring2mind.com/dmx
    C'est pour cela que cela ne marche pas
    Aie aie aie
    C'était vraiment un détail qui tue ...

    Merci sincèrement pour votre précieuse aide, mon projet peut continuer

    Seb

Discussions similaires

  1. [XSLT] obtenir la valeur d'un noeud à partir de son nom
    Par gambic dans le forum XSL/XSLT/XPATH
    Réponses: 5
    Dernier message: 20/10/2009, 11h10
  2. [XSLT] Changer la valeur d'un noeud donné
    Par F.Victoire dans le forum XSL/XSLT/XPATH
    Réponses: 3
    Dernier message: 22/09/2009, 14h43
  3. Réponses: 4
    Dernier message: 18/09/2007, 00h32
  4. [XSLT]introduire la valeur d'un noeud dans une balise html
    Par delma dans le forum XSL/XSLT/XPATH
    Réponses: 3
    Dernier message: 19/10/2006, 22h08
  5. [XSLT] Obtenir la position d'un noeud
    Par zoubidaman dans le forum XSL/XSLT/XPATH
    Réponses: 3
    Dernier message: 27/09/2006, 09h34

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