Bonjour à tous !
Je n'arrive pas faire correctement un apply-templates en utilisant la selection.
Mon XML :
Mon XSL :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <TABLES> <TABLE ID="chiffre"> <RECORD id="MaVariable1" value="MaValeur1" /> <RECORD id="MaVariable2" value="MaValeur2" /> <RECORD id="MaVariable3" value="MaValeur3" /> </TABLE> <TABLE ID="lettre"> <RECORD id="MaVariableA" value="MaValeurA" /> <RECORD id="MaVariableB" value="MaValeurB" /> <RECORD id="MaVariableC" value="MaValeurC" /> </TABLE> </TABLES>
Mes apply-templates sont inopérants. Quelle est mon erreur ?
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 <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> Hello ! <xsl:apply-templates select="/TABLES/TABLES[@ID='chiffre']"/> <xsl:apply-templates select="/TABLES/TABLES[@ID='lettre']"/> </body> </html> </xsl:template> <xsl:template match="/TABLES/TABLE[@ID='chiffre']"> <h1>Chiffres</h1> <xsl:for-each select="RECORD" > <xsl:value-of select="@id" /> : <xsl:value-of select="@value" /><br /> </xsl:for-each> </xsl:template> <xsl:template match="/TABLES/TABLE[@ID='lettre']"> <h1>Lettres</h1> <xsl:for-each select="RECORD" > <xsl:value-of select="@id" /> : <xsl:value-of select="@value" /><br /> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Merci d'avance !
@++
NeoMan
Partager