Problèmes Variables XSLT/Javascript.
Bonjour,
J'ai un petit souci de variables XSL. J'ai une feuille XSLT que voici :
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
|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" standalone="no" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="requestreturn/facility">
<html>
<head>
</head>
<body>
<div>
<h3>
<xsl:variable name="CurrentFacSelect" select="facilityname"/>
<img src="http://172.25.162.15/Doc_Management_test/images/plus_case.png" id="buttonFac" onClick="doAnimation(this.name);" alt="+" width="15" height="15">
<xsl:attribute name="name">
<xsl:value-of select="$CurrentFacSelect"/>
</xsl:attribute>
</img>
<xsl:value-of select="facilityname"/>
</h3>
</div>
<xsl:variable name="CurrentFac" select="facilityname"/>
<div name="animDiv" style="display:none;">
<xsl:attribute name="id">
<xsl:value-of select="$CurrentFac"/>
</xsl:attribute>
<h5>Adresse de Livraison :</h5>
<xsl:value-of select="facadresse/addr1"/>
<xsl:value-of select="facadresse/addr2"/>
<xsl:value-of select="facadresse/city"/>
<xsl:value-of select="facadresse/zipcode"/>
<xsl:value-of select="facadresse/state"/>
<xsl:value-of select="facadresse/country"/>
<h5>Contact :</h5>
<table border="1">
<tr>
<th>Print</th>
<th>Session Number</th>
<th>Course Title</th>
<th>Start date</th>
<th>Instructor Name</th>
<th>Student Count</th>
</tr>
<xsl:for-each select="session">
<tr>
<td><input type="checkbox" id="" name=""></input></td>
<td><xsl:value-of select="numsession"/></td>
<td><xsl:value-of select="coursetitle"/></td>
<td><xsl:value-of select="startdate"/></td>
<td><xsl:value-of select="instructorname"/></td>
<td>
<xsl:variable name="StudCount" select="studentcount"/>
<input type="text" id="SCount" name="Scount">
<xsl:attribute name="value">
<xsl:value-of select="$StudCount"/>
</xsl:attribute>
</input>
</td>
</tr>
</xsl:for-each>
</table>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet> |
et une fonction javascript que voilà :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
function doAnimation(facIdDiv) {
faciIdDiv =this.name;
alert(faciIdDiv);
var currentEtat = document.getElementById(facIdDiv).style.display;
var currentImgButton = document.getElementById('buttonFac');
var wipeOut = dojo.fx.wipeOut({node: facIdDiv,duration: 500});
var wipeIn = dojo.fx.wipeIn({node: facIdDiv,duration: 500});
var currentAnimation;
if (currentEtat=="none"){
currentAnimation = wipeIn;
currentImgButton.src = "http://172.25.162.15/Doc_Management_test/images/moins_case.png";
}else{
currentAnimation = wipeOut;
currentImgButton.src = "http://172.25.162.15/Doc_Management_test/images/plus_case.png";
}
currentAnimation.play();
} |
Le but du jeu est de réussir à passer une variable XSL en tant que paramètre dans l'appel de ma fonction javascript. Pour cela je donne un "nom" à l'image qui sera récupérer en tant que paramètre de la fonction qui effectuera ses actions ensuite dans la div "animDiv" portant le même "id" passé en variables xsl aussi.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<div>
<h3>
<xsl:variable name="CurrentFacSelect" select="facilityname"/>
<img src="http://172.25.162.15/Doc_Management_test/images/plus_case.png" id="buttonFac" onClick="doAnimation(this.name);" alt="+" width="15" height="15">
<xsl:attribute name="name">
<xsl:value-of select="$CurrentFacSelect"/>
</xsl:attribute>
</img>
<xsl:value-of select="facilityname"/>
</h3>
</div>
<xsl:variable name="CurrentFac" select="facilityname"/>
<div name="animDiv" style="display:none;">
<xsl:attribute name="id">
<xsl:value-of select="$CurrentFac"/>
</xsl:attribute> |
Malheureusement, rien ne se passe, et quand je fais un "alert" de this.name, il me ramène une chaine vide.
Soit je me suis planté quelques part (au niveau XSLT, JS), ou alors ma variable de "name" n'est charger qu'après l'appel de ma fonction (et la cela craint :calim2:).
Auriez vous une idée ?
Merci d'avance.