1 pièce(s) jointe(s)
[XSLT][>HTML] Affichage d'un tableau
Bonjour,
Je souhaite afficher un tableau dans une JSP, suite au parsing d'un fichier XML, en passant par une XSL.
Le parsing du fichier XML, ainsi que l'affichage des champs du XML fonctionne, cependant, il me faut afficher ses valeurs dans un tableau. Or dans la XSL, lorsque je crée le tableau, j'utilise une boucle qui me permet de créer les différentes lignes.J'obtiens le tableau qui se trouve en pièce jointe. Il y a un problème au niveau de la seconde ligne du troisième tableau, qui est dû à la fermeture et réouverture de tableau (cf note)
Voici le code XSL, le contenu du fichier XML, et le résultat obtenu (en pièce jointe) merci d'avance pour votre aide.
Voici le code de la XSL :
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 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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
| <?xml version="1.0" encoding="UTF-8"?>
<table>
<xsl:for-each select="ANOMALY">
<xsl:choose>
<xsl:when test="@FACTORISATION='O'">
<tr>
<td>
Compte-Rendu
Premier Salarié concerné
Première rubrique
</td>
</tr>
<tr>
<td>
<table>
<tr>
<th>Rubrique</th>
<th>Valeur</th>
<th>Libellé</th>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<xsl:value-of select="@CODE_RUB" />
</td>
<td>
<xsl:value-of select="@VAL_RUB" />
</td>
<td>
<xsl:value-of select="@LIBELLE_RUB" />
</td>
<td>
<xsl:value-of select="@LIBELLE" />
</td>
</tr>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="(preceding-sibling::*[1]/@FACTORISATION='O') or not(preceding-sibling::*[1]/@FACTORISATION)">
<tr>
<td>
Anomalie
</td>
</tr>
<tr>
<td>
<table>
<tr>
<th>Rubrique</th>
<th>Valeur</th>
<th>Libellé</th>
<th>Anomalie</th>
</tr>
<tr>
<td>
<xsl:value-of select="@CODE_RUB" />
</td>
<td>
<xsl:value-of select="@VAL_RUB" />
</td>
<td>
<xsl:value-of select="@LIBELLE_RUB" />
</td>
<td>
<xsl:value-of select="@LIBELLE" />
</td>
</tr>
-------- comment faire pour ne pas fermer cette balise dans le when???
</table>
</td>
</tr>
</xsl:when>
<xsl:otherwise>
<tr>
<td>
<table>
------- idem : comment faire pour ne pas ouvrir cette balise dans le otherwise??
<tr>
<td>
<xsl:value-of select="@CODE_RUB" />
</td>
<td>
<xsl:value-of select="@VAL_RUB" />
</td>
<td>
<xsl:value-of select="@LIBELLE_RUB" />
</td>
<td>
<xsl:value-of select="@LIBELLE" />
</td>
</tr>
</table>
</td>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</table> |
Voici le contenu du fichier XML :
Code:
1 2 3 4
| <ANOMALY CODE_RUB="124" LIBELLE_RUB="Nom de la personne " VAL_RUB="NOM" LIBELLE="ne repond pas"/>
<ANOMALY FACTORISATION="O" LIBELLE="test" LIBELLE_RUB="Identification du salarié" CODE_RUB="35" VAL_RUB="" NOM_SALARIE="NOM" PRENOM_SALARIE="PRENOM"/>
<ANOMALY CODE_RUB="154" LIBELLE_RUB="Nom de la personne " VAL_RUB="NOM " LIBELLE="rubrique "/>
<ANOMALY CODE_RUB="30" LIBELLE_RUB="Nom" VAL_RUB="NOM SL" LIBELLE="erreur"/> |