Bonjour,
J'ai un fichier XML comme ceci :
J'aimerai le traiter via un fichier XSL, mais j'ai un problème.Code:
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 <choice name="CHOICE1" select="Text">13</choice> <table name="TABLE1"> <data> <tr> <td>1.0</td> <td>1111</td> </tr> <tr> <td>2.0</td> <td>2222</td> </tr> </data> </table> <choice name="CHOICE1" select="Text">14</choice> <table name="TABLE1"> <data> <tr> <td>1.0</td> <td>3333</td> </tr> <tr> <td>2.0</td> <td>4444</td> </tr> </data> </table> etc...
Je fais comme ceci :
Et j'obtiens :Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14 <xsl:for-each select="$c/table[@name='TABLE1']"> <SIGMA_UNITE> <xsl:variable name="iSol" select="string($c/choice[@name='CHOICE1'])" /> <NUM_MECA><xsl:value-of select="$iSol"/></NUM_MECA> <xsl:for-each select="./data/tr"> <xsl:variable name="S_RR" select="td[1]" /> <xsl:variable name="S_TT" select="td[2]" /> <SIGMA_MECA> <S_RR><xsl:value-of select="$S_RR"/></S_RR> <S_TT><xsl:value-of select="$S_TT"/></S_TT> </SIGMA_MECA> </xsl:for-each> </SIGMA_UNITE> </xsl:for-each>
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 <SIGMA_UNITE> <NUM_MECA>13</NUM_MECA> <SIGMA_MECA> <S_RR>1.0</S_RR> <S_TT>1111</S_TT> </SIGMA_MECA> <SIGMA_MECA> <S_RR>2.0</S_RR> <S_TT>2222</S_TT> </SIGMA_MECA> </SIGMA_UNITE> <SIGMA_UNITE> <NUM_MECA>13</NUM_MECA> <SIGMA_MECA> <S_RR>1.0</S_RR> <S_TT>3333</S_TT> </SIGMA_MECA> <SIGMA_MECA> <S_RR>2.0</S_RR> <S_TT>4444</S_TT> </SIGMA_MECA> </SIGMA_UNITE>
Bon, je vais pouvoir commencer ma question !
Dans le resultat, j'obtiens bien les différents tableaux, mais j'obtiens toujours la valeur du premier choice. Il ne va pas chercher le suivant.
Ca parait plausible, puisque je boucle sur les balise table, mais comment faire pour boucler en même temps sur les balises choice ? :(