Bonjour,
J'ai le fichier XML suivant:
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 <racine> <fichier nom="index.xml"> <title> Authentification du titulaire </title> <logo_head> "images/logo_codoc.gif" </logo_head> <bienvenue> </bienvenue> <logo_foot> images/logo_infra.gif </logo_foot> <foot> </foot> <main> <form > <table id="tab1"> <ligne> <texte> Identifiant </texte> <input type="text"> yes </input> </ligne> <ligne> <texte> Mot de passe </texte> <input type="password" > </input> </ligne> <ligne> <bouton type="button"> connexion </bouton> <link href="recup_pwd.xml"> Mot de passe oublié </link> </ligne> <ligne> <link href="inscription.xml"> Inscription </link> </ligne> </table> </form> </main> </fichier> </racine>
et le fichier XSL associé doit chercher dans le fichier XML les lignes qui ont les balises <input> avec la valeur 'yes' pour insérer alors un champ de texte dans l'outpout HTML. Le fichier est le suivant:
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 <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <title> <xsl:value-of select="racine/fichier/title"/> </title> <link rel="stylesheet" media="screen" type="text/css" title="Style" href="stylelogin.css" /> </head> <body> <table align="center"> <tr> <td><img src="images/logo.gif"/></td> <td id="entete" style="background-color:#cccc"> </td> </tr> </table > <br/> <br/> <br/> <br/> <form id="form"> <table align="center" class="tableLogin"> <xsl:for-each select="racine/fichier/main/form/table/ligne"> <tr> <td><xsl:value-of select="texte"/></td> <xsl:if test=".[input='yes']"> <td><input type="text" id= "tit_id" name="tit_id" value="" /></td> </xsl:if> <td> <a href=""> <xsl:value-of select="link"/> </a></td> </tr> </xsl:for-each> </table> </form> <br/> <br/> <br/> <br/> <table align="center"> <tr> <td><img src="images/logo.gif"/></td> <td bgcolor="#ccccff" width="705" height="90"></td> </tr> </table> </body> </html> </xsl:template> </xsl:stylesheet>
Le problème est qu'à l'exécution, il m'affiche l'erreur suivante:
Invalid XPath expression
Unexpected token - "[input='yes']"
test=".[input='yes']"
Partager