Bonjour à tous !!!
Je suis en train de faire un projet pour la fac , c'est un projet de géolocalisation .Je dois sélectionner des produits dans des listes déroulantes et que les produits s'affiche sur un plan ..
J'ai donc mon xml qui se présente comme sa :
(avec plusieurs secteur)
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 <?xml version="1.0" encoding="utf-8" ?> <?xml-stylesheet href="magasin.xsl" type="text/xsl" ?> <magasin> <secteur nom="Cosmetologie" > <rayon nom="Podologie"> <produit type="Creme" marque="Loreal" prix="5,50" x="295" y="180"> </produit> <produit type="Creme" marque="YvesRocher" prix="4,25 " x="295" y="160"> </produit> <produit type="Rabot" marque="LeRabot" prix="4,00 " x="295" y="200"> </produit> </rayon> <rayon nom="Soin du visage"> <produit type="Masque" marque="Loreal" prix="6,75 " x="282" y="180" > </produit> <produit type="Fond de teint" marque="Loreal" prix="5,75 " x="282" y="160"> </produit> <produit type="Masque" marque="YvesRocher" prix="3.90 " x="282" y="200"> </produit> </rayon> </secteur> </magasin>
et mon xsl :
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 <?xml version="1.0" encoding="ISO-8859-1" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" encoding="ISO-8859-1" /> <xsl:template match="/"> <html> <body style="background:url('plan.jpg');background-repeat:no-repeat; background-position: top right"> <center><font color="white"><h2>* * * Bienvenue dans votre hypermarche * * *</h2></font><font color="#e00080"><i><h4>Service de localisation de vos produits</h4></i></font></center> <form method="get" action="relais.php" target="maFrame"> <xsl:apply-templates select="//*" /> <!-- selection de tous les noeuds de l'arbre dom --> <input type="submit" value="Rechercher" /> <input type="reset" value="Annuler" /> </form> <br/><br/><br/><br/><br/><br/><br/><br/><br/> <center><iframe width="850" height="600" name="maFrame" frameborder="0"></iframe></center> </body> </html> </xsl:template> <xsl:template match="*[not(preceding::*[name()=name(current())])]"> <b><u><font color="black"><xsl:value-of select="name()" /></font></u></b> <table> <xsl:apply-templates select="@*" /> </table> </xsl:template> <xsl:template match="@*"> <xsl:variable name="baliseParente" select="name(..)" /> <xsl:variable name="nomAttribut" select="name()" /> <td> <tr bgcolor="#ffe0a0"> <font color="#e00080"><xsl:value-of select="$nomAttribut" /></font> <select name="{concat($baliseParente,'-',$nomAttribut)}"> <option value="">-- Tous --</option> <xsl:for-each select="//*[name()=$baliseParente]/@*[name()=$nomAttribut]"> <option> <xsl:value-of select="."/> </option> </xsl:for-each> </select> <br/> </tr> </td> </xsl:template> </xsl:stylesheet>
Mais dans mes liste de produits par exemple j'ai deux fois la valeur"creme" alors que j'aimerais qu'elle ne saffiche q'une fois ...
Est ce que qu'elqu'un sais ce que je dois faire pour regler ce petit pb??
Merci à tous d'avance
Bonne journée
Emilie![]()
Partager