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 :

Requete XPATH pour transformation XSLT


Sujet :

XSL/XSLT/XPATH XML

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Inscrit en
    Septembre 2011
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Secteur : Distribution

    Informations forums :
    Inscription : Septembre 2011
    Messages : 27
    Points : 27
    Points
    27
    Par défaut Requete XPATH pour transformation XSLT
    Bonjour,
    J'ai le code XML ci dessous et j'applique le code XSLT à la suite, seulement il me renvoi toujours le 1er ingrédient (ananas) : quelqu'un peut il m'aider?
    Merci par avance.

    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
    16
    17
    18
    19
    20
    21
    22
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <?xml-stylesheet type="text/xsl" href="../xslt/commandeTest.xsl"?>
    <cmd:commande xmlns:cmd="http://chez.mario.fr/commande" xmlns:clt="http://chez.mario.fr/client" xmlns:piz="http://chez.mario.fr/pizza">
        <cmd:dateCommande>2013-09-24-06:00</cmd:dateCommande>
        <cmd:numCommande>2</cmd:numCommande>
        <cmd:infosClient noAdherent="000-222">
            <clt:nom>Baret</clt:nom>
            <clt:prénom>Bruno</clt:prénom>
            <clt:téléphone>0685648963</clt:téléphone>
            <clt:adresse>fef</clt:adresse>
        </cmd:infosClient>
        <cmd:listePizza>
            <cmd:pizza base="tomate" taille="M">
                <piz:ingredient>ananas</piz:ingredient>
                <piz:ingredient>aubergine</piz:ingredient>
                <piz:ingredient>aubergine</piz:ingredient>
                <piz:ingredient>ananas</piz:ingredient>
                <piz:ingredient>champignons</piz:ingredient>
                <piz:quantite>1</piz:quantite>
            </cmd:pizza>
        </cmd:listePizza>
    </cmd:commande>
    XSLT:
    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
        <xsl:template match="/">
            <html xmlns="http://www.w3.org/1999/xhtml">
     
                <head>
                    <title>commandeTest.xsl</title>
                    <link rel="stylesheet" href="../css/pizzeria.css" />
                </head>
                <body>
                    <div id="mainContainer">
                        <header>
                            <img src="../img/banniere.png" alt="banniere pizzeria chez Mario"/>
                        </header>
                        <nav>		
                            <ul id="menu">
                                <li>
                                    <a href="index.xhtml">Accueil</a>
                                </li>
                                <li>
                                    <a href="#">A propos de nous</a>
                                    <ul>
                                        <li>
                                            <a href="#">Bruno Seuzaret</a>
                                        </li>
                                        <li>
                                            <a href="#">Sylvain Baret</a>
                                        </li>
                                    </ul>
                                </li>
                                <li>
                                    <a href="commandePizza.xhtml">Passer une commande</a>
                                </li>
                                <li>
                                    <a href="#">Livrer une commande</a>
                                </li>
                                <li id="RSS">
                                    <a href="#">RSS</a>
                                </li>
                                <li>
                                    <a href="#">Contact</a>
                                </li>
                            </ul>	
                        </nav>
                        <h1>Merci pour votre commande!</h1>
                        <h2>Commande de pizzas n° <xsl:value-of select="cmd:commande/cmd:numCommande"/></h2>                 
                        <h2>Date de la commande: <xsl:value-of select="cmd:commande/cmd:dateCommande"/></h2>
                        <xsl:apply-templates select="cmd:commande"/>
                    </div>
                </body>
            </html>
        </xsl:template>
     
        <xsl:template match="cmd:commande">
            <h2>Information client :</h2>
            <br/>
            <i>Nom : </i>
            <xsl:value-of select="cmd:infosClient/clt:nom"/>
            <br/>
            <i>Prénom : </i>
            <xsl:value-of select="cmd:infosClient/clt:prénom"/>
            <br/>
            <i>Téléphone : </i>
            <xsl:value-of select="cmd:infosClient/clt:téléphone"/>
            <br/>
            <i>Adresse : </i>
            <xsl:value-of select="cmd:infosClient/clt:adresse"/>
            <br/>
            <i>Numéro d'adhérent : </i>
            <xsl:value-of select="cmd:infosClient/@noAdherent"/>
            <br/> 
     
            <h2>Information pizza :</h2>
            <br/>
            <i>Base : </i>
            <xsl:value-of select="cmd:listePizza/cmd:pizza/@base"/>
            <br/>
            <i>Taille : </i>
            <xsl:value-of select="cmd:listePizza/cmd:pizza/@taille"/>
            <br/>
            <xsl:apply-templates select="cmd:listePizza/cmd:pizza/piz:ingredient"/>
            <i>Quantité : </i>
            <xsl:value-of select="cmd:listePizza/cmd:pizza/piz:quantite"/>
            <br/>
        </xsl:template>
     
        <xsl:template match="piz:ingredient">
            <xsl:variable name="myIngredient" select="//piz:ingredient"/>
            <i>Ingrédient : </i>
            <xsl:value-of select="$myIngredient"/>
            <br/>
        </xsl:template>    
     
    </xsl:stylesheet>

  2. #2
    Modérateur

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

    Informations forums :
    Inscription : Septembre 2004
    Messages : 12 559
    Points : 21 621
    Points
    21 621
    Par défaut
    Elle sert à rien, ta variable myIngredient. L'ingrédient que tu veux c'est le nœud en cours, fais juste select="." .

    (Ananas - aubergine - champignons... Beeeeeeeh )

Discussions similaires

  1. SimpleXML avec XPATH pour une requete simple en apparence
    Par NissqR dans le forum XML/XSL et SOAP
    Réponses: 8
    Dernier message: 23/03/2010, 10h09
  2. Transformation XSLT pour générer du XML
    Par kalbo dans le forum XSL/XSLT/XPATH
    Réponses: 8
    Dernier message: 18/07/2008, 10h57
  3. [XPATH] Résultat vide pour une requete xpath
    Par bitbis dans le forum Format d'échange (XML, JSON...)
    Réponses: 2
    Dernier message: 20/06/2008, 14h41
  4. Conseils pour bien débuter: transformation xslt
    Par rider74 dans le forum XSL/XSLT/XPATH
    Réponses: 3
    Dernier message: 14/01/2008, 20h22
  5. [XML/XSL/XPATH]Requete XPATH pour transformation
    Par Le-Cortex dans le forum XSL/XSLT/XPATH
    Réponses: 6
    Dernier message: 04/01/2006, 17h32

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