Bonjour à tous !
Je dois réaliser un questionnaire au moyen de XML et XSL.
C'est la première fois que j'utilise ces deux là.
J'ai implémenté un code mais à l'affichage la question s'affiche deux fois alors que je souhaite qu'elle ne s'affiche qu'une fois !
Voici le code:
Fichier XML:
Fichier 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 <?xml version="1.0" encoding="ISO-8859-1" ?> <?xml-stylesheet href="qcm.xsl" type="text/xsl" ?> <qcm matiere="qi"> <question> <libellé> Trouver le domino manquant. </libellé> <imgsrc> imgXml/1.bmp </imgsrc> <choix score="1"> 4 - 2 </choix> <choix score="0"> 6 - 4 </choix> <choix score="0"> 2 - 4 </choix> </question> <question> <libellé> Quel est le carré qui suit la ligne ? </libellé> <imgsrc> imgXml/2.bmp </imgsrc> <choix score="0"> 1 </choix> <choix score="1"> 2 </choix> <choix score="0"> 3 </choix> </question> <question> <libellé> Trouver les deux nombres qui manquent. </libellé> <imgsrc> imgXml/3.bmp </imgsrc> <choix score="0"> 6.5 </choix> <choix score="0"> 7.8 </choix> <choix score="1"> 7.7 </choix> </question> <question> <libellé> Tenter de résoudre cette analogie. </libellé> <imgsrc> imgXml/4.bmp </imgsrc> <choix score="1"> A </choix> <choix score="0"> E </choix> <choix score="0"> H </choix> </question> </qcm>
Voilà !
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 <?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> <head> <title> <xsl:value-of select="@matiere"/> </title> </head> <body bgcolor="skyblue"> <center> <table border="9" cellsspacing="3" cellpadding="6" width="700" bgcolor="skyblue"> <td><img src="imgXml/logo.jpg"/></td> <td> <center> <h1> <font color="darkblue"> Questionnaire pour neuneus </font> </h1> </center> </td> <td><img src="imgXml/logo.jpg"/></td> </table> </center> <form action="..."> <xsl:apply-templates/> <br/> <br/> <center> <input type="submit" value="Résultats du test" /> </center> </form> </body> </html> </xsl:template> <xsl:template match="question"> <br/> <center> <table border="1" cellsspacing="3" cellpadding="6" width="500" bgcolor="skyblue"> <tr> <td> <center> <h3><font color="darkblue"><xsl:value-of select="libellé"/></font></h3> </center> </td> </tr> </table> <table border="1" cellsspacing="3" cellpadding="6" width="500" bgcolor="skyblue"> <tr> <td> <img> <xsl:attribute name="src"> <xsl:value-of select="imgsrc"/> </xsl:attribute> </img> </td> <td> <xsl:apply-templates/> </td> </tr> </table> <br/> </center> </xsl:template> <xsl:template match="choix"> <br/> <input type="radio"> <xsl:attribute name="name"> <xsl:value-of select="concat('Q',count(preceding::question)+1)"/> </xsl:attribute> <xsl:attribute name="value"> <xsl:value-of select="count(preceding::choix)+1"/> </xsl:attribute> </input> <xsl:value-of select="."/> </xsl:template> </xsl:stylesheet>
Si quelqu'un a la solution je le remercie !
Partager