Bonjour,
Je début en XML/XSL et je dois dire que ce langage m'ouvre de nombreuses perceptives.
Je souhaiterais générer sur une page plusieurs modèles selon différents critères.
Je suis parvenu à afficher mes deux tableaux tests avec les codes ci-dessous.
Par contre, je souhaiterais rajouter un critère à mon <xsl:apply-templates select="catalogue/domaine[@type='dom1']" /> pour filtrer sur la balise data.
J'ai tenté sans succès <xsl:apply-templates select="catalogue/domaine[@type='dom1'] and "caatalogue/data[@type='aaa']" />.
Pourriez-vous, s'il vous plait, m'aider et m'orienter pour cette réalisation.
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 <?xml version="1.0"?> <?xml-stylesheet type="application/xml" href="bdd.xsl"?> <catalogue> <domaine type="dom1"> <data type="aaa"> <profil>profil 1</profil> <dispo>oui</dispo> </data> </domaine> <domaine type="dom1"> <data type="aaa"> <profil>profil 2</profil> <dispo>non</dispo> </data> </domaine> <domaine type="dom1"> <data type="bbb"> <profil>profil 3</profil> <dispo>oui</dispo> </data> </domaine> <domaine type="dom2"> <data type="bbb"> <profil>profil 1</profil> <dispo>non</dispo> </data> </domaine> <domaine type="dom2"> <data type="bbb"> <profil>profil 2</profil> <dispo>non</dispo> </data> </domaine> </catalogue>
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"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/"> <html> <head> <title>Ma bibliotheque</title> <style type="text/css"> th {background-color:silver;} td {border-style:solid; border-width:1px;} </style> </head> <body> <h2>Bibliotheque</h2> <table> <tr> <th>profil</th> <th>dispo</th> </tr> <xsl:apply-templates select="catalogue/domaine[@type='dom1']" /> </table> <br/> <table> <tr> <th>profil</th> <th>dispo</th> </tr> <xsl:apply-templates select="catalogue/domaine[@type='dom2']" /> </table> </body> </html> </xsl:template> <xsl:template match="domaine"> <tr> <td><xsl:value-of select="data/profil"/><i>blablabla</i><xsl:value-of select="data/profil"/><xsl:value-of select="data/profil"/><xsl:value-of select="data/profil"/><xsl:value-of select="data/profil"/></td> <td><xsl:value-of select="concat(data/profil, ' ', data/dispo)"/></td> </tr> </xsl:template> </xsl:stylesheet>
Merci,
Partager