Bonjour,
Je dispose d'un fichier XML ci-dessous:
Comme on peut le voir, on trouve deux fois le centre de nom "011". Je veux le transformer en un tableau où le centre "011" n'apparaît que sur une ligne, mais en ayant en colonne les différentes valeurs des autres balises. j'avais fait ce fichier xsl (dismig.xsl appelé dans le fichier xml)
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 <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="dismig.xsl"?> <DISCO> <CENTRE> <NOM>043</NOM> <DATE>13/03/07</DATE> <RRF>0461</RRF> <VLAGRDE>0</VLAGRDE> <VLAGRDG>1</VLAGRDG> <MIGNRE>2</MIGNRE> </CENTRE> <CENTRE> <NOM>011</NOM> <DATE>13/03/07</DATE> <RRF>0471</RRF> <VLAGRDE>0</VLAGRDE> <MIGNRE>2</MIGNRE> </CENTRE> <CENTRE> <NOM>012</NOM> <DATE>13/03/07</DATE> <RRF>0471</RRF> <VLAGRDE>0</VLAGRDE> <VLAGRDG>1</VLAGRDG> <MIGNRE>2</MIGNRE> </CENTRE> <CENTRE> <NOM>011</NOM> <VLAGRDG>1</VLAGRDG> </CENTRE> </DISCO>
Mais il me crée autant de lignes qu'il trouve de CENTRE (vous me direz, c'est normal pour un xsl:for-each select="DISCO/CENTRE"). Comment faire pour n'avoir qu'une ligne pour le centre de nom "011" avec sur cette ligne les valeurs des balises NOM; DATE; RRF; VLAGRDE; VLAGRDG; MIGNRE ?
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 <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="ISO-8859-1" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd" indent="yes"/> <xsl:template match="/"> <html> <head> <title>Indicateurs</title> <style> td {font-size: 10 pt; font-family: verdana; font-weight: normal} </style> </head> <body> <h1>Indicateurs</h1> <table border="1" width="500"> <tbody> <tr> <td><b> nom</b></td> <td><b> date</b></td> <td colspan="3" align="center"><b> VLAGRD</b></td> <td colspan="7" align="center"><b> resid(REG)</b></td> </tr> <tr> <td><b> </b></td> <td><b> </b></td> <td bgcolor="green"><b> </b></td> <td><b> G</b></td> <td bgcolor="green"><b> </b></td> <td bgcolor="green"><b> </b></td> <td><b> MIG</b></td> <td><b> SD</b></td> <td><b> ME</b></td> <td><b> FA</b></td> <td><b> AC</b></td> <td bgcolor="green"><b> </b></td> </tr> <xsl:for-each select="DISCO/CENTRE"> <xsl:sort select="DATE" data-type="text" order="descending" /> <xsl:sort select="NOM" data-type="text" order="ascending" /> <!--<xsl:sort select="NOM"/>--> <tr> <td> <xsl:value-of select="NOM"/></td> <td> <xsl:value-of select="DATE"/></td> <td bgcolor="green"><b> </b></td> <td> <xsl:value-of select="VLAGRDG"/></td> <td bgcolor="green"><b> </b></td> <td bgcolor="green"><b> </b></td> <td> <xsl:value-of select="MIGREG"/></td> <td> <xsl:value-of select="MIGSDREG"/></td> <td> <xsl:value-of select="MIGMEREG"/></td> <td> <xsl:value-of select="MIGFAREG"/></td> <td> <xsl:value-of select="MIGACREG"/></td> <td bgcolor="green"><b> </b></td> </tr> </xsl:for-each> </tbody> </table> </body> </html> </xsl:template> </xsl:stylesheet>
Merci de votre aide
Partager