Bonjour à tous, je suis actuellement confronté à un problème sur lequel je ne trouve pas d'explications.
J'ai actuellement une page php nommé index.php qui contient ce code :Ensuite voici le code du fichier xslt :Code:
1
2
3
4
5
6
7
8
9
10 <?php $XML2 = new DOMDocument(); $XML2->load("appel du webservice"); $proc = new XSLTProcessor(); $xsl = new DOMDocument; $xsl->load('base_liste_booking.xslt'); $proc->importStyleSheet($xsl); echo $proc->transformToXML($XML2); ?>
Et pour finir le code de carte.js :Code:
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 <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head> <link href="booking.css" rel="stylesheet" type="text/css"/> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript" src="carte.js"></script> </head> <body> <div id="carte" style="width:0px; height:0px"></div> <div id="informations" style="width:0px; height:0px"></div> <table border="1"> <xsl:for-each select="objs/obj"> <xsl:variable name="compteur"> <xsl:value-of select ="(position() mod2)"/> </xsl:variable> <xsl:if test="$compteur!=0"> <xsl:text disable-output-escaping="yes"><tr></xsl:text> </xsl:if> <xsl:variable name="latitude"> <xsl:value-of select="obj_common/lat"/> </xsl:variable> <xsl:variable name="longitude"> <xsl:value-of select="obj_common/lng"/> </xsl:variable> <xsl:variable name="societe"> <xsl:value-of select="societe"/> </xsl:variable> <xsl:variable name="cp"> <xsl:value-of select="cp"/> </xsl:variable> <xsl:variable name="insee"> <xsl:value-of select="insee"/> </xsl:variable> <xsl:variable name="ville"> <xsl:value-of select="localite"/> </xsl:variable> <td> <xsl:variable name="id"> <xsl:value-of select="id"/> </xsl:variable> <xsl:variable name="chemin_photo"> <xsl:value-of select="obj_common/photo/ass_obj_photo/fic_m"/> </xsl:variable> <xsl:if test="$chemin_photo!=''"> <xsl:variable name="chemin"> <xsl:value-of select="concat('http://www.cotedor-tourisme.com/fics_monespacetourisme/',obj_common/photo/ass_obj_photo/fic_m)"/> </xsl:variable> <div id="image"> <img src="{$chemin}" /> </div> </xsl:if> <xsl:if test="$chemin_photo=''"> <div id="image_non"></div> </xsl:if> <xsl:variable name="etoile"> <xsl:value-of select="obj_common/ass_all[tbl='ass_hot_cat']/src_img"/> </xsl:variable> <xsl:variable name="label"> <xsl:value-of select="obj_common/ass_all[tbl='ass_label']/src_img"/> </xsl:variable> <p id="nom_societe"><xsl:value-of select="societe"/> <xsl:if test="$etoile!=''"> <sup><img src="{$etoile}"/></sup> </xsl:if> </p> <p> <xsl:if test="$label!=''"> <img src="{$label}"/> </xsl:if> </p> <div id="lien"> <a href="fiche_detaillee.php?id={$id}">Voir la fiche</a> </div> <a href="#" onclick="initialiser({$latitude},{$longitude},{$cp});"> Voir sur la carte </a> </td> <xsl:if test="$compteur=0"> <xsl:text disable-output-escaping="yes"></tr></xsl:text> </xsl:if> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
Le problème se trouve lors de l'appel de la fonction initialiser dans le fichier xslt. Avec le code que je viens de fournir ça fonctionne sans problèmes par contre si je change le paramètre "cp" de la fonction initialiser par "societe" ça ne marche plus. La seul différence entre les deux est que cp est un numérique et que societe est une chaine de caractères. Je ne sais pas si il faut effectuer quelque chose de particulier pour pouvoir récupérer la chaine dans la fonction javascript ?Code:
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 function initialiser(latitude,longitude,cp) { var latlng = new google.maps.LatLng(latitude,longitude); var obj = document.getElementById('carte'); obj.style.height = "600px"; obj.style.width = "600px"; var infos = document.getElementById('informations'); infos.style.height = "50px"; document.getElementById('informations').innerHTML = cp; var options = { center: latlng, zoom: 15, mapTypeId: google.maps.MapTypeId.ROADMAP }; var carte = new google.maps.Map(document.getElementById("carte"), options); var marqueur = new google.maps.Marker({ position: new google.maps.LatLng(latitude, longitude), map: carte }); google.maps.event.addListener(marqueur, 'click', function() { infowindow.open(carte, marqueur); }); }
Merci d'avance.
pAnTiNhO