Bonjour
Je n'arrive pas a finir mon PB. Si quelqu'un pouvais m'apporter un petit d'aide ce serait sympa. Merci par avance.
Je me suis servi d'un post du forum http://www.developpez.net/forums/d14...e/#post7787761
Je souhaitais créer un tableau avec des paramètres biologique en colonne et des dates de test en ligne. Mes données ne comportent pas toujours les mêmes paramètres.
Les tests sont regroupés par des numéros de lot.
J'ai bien réussi a avoir tous mes paramètres en colonnes dans certaines conditions mais je n'arrive pas remplir mon tableau. Les données ne sont pas correctement filtrées
Voici mes données
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 <qcdata> <labinfo> <instrument serialnumber='PNX9999'> NEXDX </instrument> </labinfo> <sampleset lot="PX033L" > <result time="2013-03-27 17:40:00"> <value param="GB"> GB 2013-03-27 </value> <value param="GR"> GR 2013-03-27 </value> </result> <result time="2014-12-27 6:40:00"> <value param="GR"> GR 2014-12-27 </value> <value param="PLA"> PLA 2014-12-27 </value> </result> </sampleset> <sampleset lot="PX033N" > <result time="2013-04-27 17:40:00"> <value param="GB"> GB 2013-04-27 </value> <value param="HB"> HB 2013-04-27 </value> </result> <result time="2014-13-27 6:40:00"> <value param="GB"> GB 2014-13-27 </value> <value param="GR"> GR 2014-13-27 </value> <value param="NEU"> NEU 12 2014-13-27 </value> </result> </sampleset> </qcdata>
Le code entre les lignes 30 et 42 me posent PB. J'ai d'autre soucis mais celuici est le principal. Les autres je pourrais sans doute m'en sortir. Il faut bien que je bosse aussi ;-)
Voici ce que je souhaiterai
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 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" omit-xml-declaration="yes" encoding="utf-8" indent="yes" /> <xsl:key name="parametre" match="result/value/@param" use="." /> <xsl:template match="/"> <html> <head></head> <body> <xsl:apply-templates select="qcdata/sampleset" mode="table" /> </body> </html> </xsl:template> <xsl:template match="sampleset" mode="table"> <table border="1"> <tbody> <tr> <th scope="col">LOT</th> <th scope="col" >date heure</th> <th scope ="col"> nb </th> <xsl:for-each select="result/value/@param[generate-id()=generate-id(key('parametre', .)[1])]"> <th><xsl:value-of select="." /></th> </xsl:for-each> </tr> <xsl:for-each select="/qcdata/sampleset"> <xsl:for-each select="current()/result"> <xsl:variable name="ctime" select="@time" /> <tr> <td><xsl:value-of select="current()/../@lot"/></td> <td><xsl:value-of select="current()/@time"/></td> <td><xsl:number /></td> <xsl:for-each select="//value[generate-id(@param)=generate-id(key('parametre', @param)[1])]"> <td> <xsl:value-of select="current()"/> <xsl:variable name="cparam" select="@param" /> <br/> <xsl:choose> <xsl:when test="$ctime/../result[@time=$ctime]/value[@param=$cparam]"> <xsl:value-of select="$ctime/../result[@time=$ctime]/value[@param=$cparam]" /> </xsl:when> <xsl:otherwise>   </xsl:otherwise> </xsl:choose> </td> </xsl:for-each> </tr> </xsl:for-each> </xsl:for-each> </tbody> </table> </xsl:template> </xsl:stylesheet>
ou sous une forme plus parlante
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 <tr> <th>LOT</th> <th>date heure</th> <th> nb </th> <th>GB</th> <th>GR</th> <th>HB</th> <th>PLA</th> <th>NEU</th> </tr> <tr> <td>PX033L</td> <td>2013-03-27 </td> <td>1</td> <td>valGB1</td> <td>valGR1</td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>PX033L</td> <td>2014-12-27 </td> <td>2</td> <td> </td> <td>valGR2</td> <td> </td> <td>valPLA2</td> <td> </td> </tr> <tr> <td>PX033N</td> <td>2013-04-27 </td> <td>1</td> <td>valGB3</td> <td> </td> <td>valHB3</td> <td> </td> <td> </td> </tr> <tr> <td>PX033N</td> <td>2014-13-27 </td> <td>2</td> <td>valGB4</td> <td>valGR4</td> <td> </td> <td> </td> <td>valNEU4</td> </tr>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 LOT | date heure | nb | GB | GR | HB | PLA | NEU | PX033L | 2013-03-27 | 1 | valGB1 | valGR1 | | | | PX033L | 2014-12-27 | 2 | | valGR2 | | valPLA2 | | PX033N | 2013-04-27 | 1 | valGB3 | | valHB3 | | | PX033N | 2014-13-27 | 2 | valGB4 | valGR4 | | | valNEU4 |
Partager