Bonsoir tous le monde
Voici le fichier XML
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
|
<?xml version="1.0" encoding='ISO-8859-1'?>
<?xml-stylesheet type="text/xsl" href="Devellopez.xsl"?>
<LISTE-A><A>
<NUM>20-10</NUM>
<C> <ANI>non</ANI> </C>
<S><SIT>
<DEP>Aaaa</DEP>
<COM>BB</COM>
</SIT> </S>
</A>
<A> <NUM>20-11</NUM>
<C> <ANI>oui</ANI> </C>
<S><SIT>
<DEP>Abbb</DEP>
<COM>BB</COM>
</SIT> </S>
</A>
<A> <NUM>20-12</NUM>
<C> <ANI>oui</ANI> </C>
<S><SIT>
<DEP>Aaaa</DEP>
<COM>BB</COM>
</SIT> </S>
</A>
</LISTE-A> |
le fichier XSL est le suivant
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
|
<?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" media-type="text/html; charset=ISO-8859-1" version="4.0"/>
<xsl:template match="/">
<html>
<body>
<table border="0" width="*" >
<tr><th>Nombre noeud</th>
<th>Numero du A</th>
</tr>
<xsl:call-template name="doc">
<xsl:with-param name="requete" select="document('requete.xml')/requete"/>
</xsl:call-template>
</table>
</body>
</html>
</xsl:template>
<xsl:template name ="doc" match="LISTE-A">
<xsl:param name="requete"/>
<xsl:for-each select="//A">
<xsl:choose>
<xsl:when test=".//DEP = $requete/DEP and .//ANI= $requete/ANI">
<tr><td><xsl:variable name="num">
<xsl:number level="any" from="LISTE-A"/>
</xsl:variable>
<xsl:value-of select="$num"/> </td>
<td><font color="#FF8040"> <xsl:value-of select="NUMERO"/></font></td>
<td><font color="#FF8040"> dep</font></td>
<td><font color="blue">ani</font></td></tr>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template></xsl:stylesheet> |
Je recoit le resultat CORRECT SUIVANT
Nombre noeud Numero du A
2 20-11 dep ani
LE PROBLEME COMMENCE lorsque je change l'instruction <xsl:when test=".//DEP = $requete/DEP and .//ANI= $requete/ANI"> PAR une variable et je met cette instruction dans le fichier suivant test.xml
1 2 3 4
| <?xml version="1.0" encoding='ISO-8859-1'?>
<test1>
<cle>.//DEP = $requete/DEP and .//ANI= $requete/ANI </cle>
</test1> |
DANS ce cas je cahnge le fichier XSL par le code suivant
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
| <?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" media-type="text/html; charset=ISO-8859-1" version="4.0"/>
<xsl:template match="/">
<html>
<body>
<table border="0" width="*" >
<tr><th>Nombre noeud</th>
<th>Numero du A</th>
</tr>
<xsl:call-template name="doc">
<xsl:with-param name="requete" select="document('requete.xml')/requete"/>
<xsl:with-param name="varReq1" select="document('test.xml')/test1/cle[1]"/>
</xsl:call-template>
</table>
</body>
</html>
</xsl:template>
<xsl:template name ="doc" match="LISTE-A">
<xsl:param name="requete"/>
<xsl:param name="varReq1"/>
<xsl:value-of select="$varReq1"/>
<xsl:for-each select="//A">
<xsl:choose>
<xsl:when test="$varReq1">
<tr><td><xsl:variable name="num">
<xsl:number level="any" from="LISTE-A"/>
</xsl:variable>
<xsl:value-of select="$num"/>
</td>
<td><font color="#FF8040"> <xsl:value-of select="NUMERO"/></font></td>
<td><font color="#FF8040"> dep</font></td>
<td><font color="blue">ani</font></td></tr>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet> |
resultat Non ATTENDU
Nombre noeud Numero du A
1 20-10 dep ani
2 20-11 dep ani
3 20-12 dep ani
ce que j’attend qu’il m’affiche le meme resultat que celle du precedent pourrier vous me dire pq ?
MALGRE il affiche le contenu du fichier test.xml suite à l'instruction suivante
<xsl:value-of select="$varReq1"/>
Merci d'avance
Partager