Re: probleme variable xsl

Stéphane Bonhomme <[email protected]>
Newsgroups gmane.text.xml.french.tech
Message-ID <[email protected]>
Stéphane ANCELOT wrote:
> Bonjour,
> Je voudrais changer l'attribut stroke pour qu'il prenne des valeurs 
> differentes en fonction d'un no, mais ca ne marche pas !!!
> 
> 
> Voici le code ci dessous , une idée ?
> 
> Steph
> 
> <xsl:template match="curve" mode="svg" >
> 
> <g xmlns="http://www.w3.org/2000/svg"  id="curve{normalize-space(no)}">
> <xsl:variable name="val" select="normalize-space(coord)"/>	
> <xsl:variable name="curvenr" select="normalize-space(no)"/>	
> 
> 
> <!--choix de la couleur = f(i) -->
> <xsl:if test="$curvenr=1">
> <xsl:variable name="color" select="'red'" />
> </xsl:if>
> 
> <xsl:if test="$curvenr!=1">
> <xsl:variable name="color" select="'yellow'" />
> </xsl:if>
> 
> 
> <polyline points="{$val}" style="stroke:{$color}; fill: 
> none;stroke-width: 2;"/>
> 
> </g>
> </xsl:template>
> 

il faut simplement déplacer le test dans la déclaration de la variable 
de façon à ce que la portée de celle-ci soit plus grande.

<xsl:variable name="color">
   <xsl:choose>
     <xsl:when test="$curvenr=1">red</xsl:when>
     <xsl:otherwise>yellow</xsl:otherwise>
   </xsl:choose>
</xsl:variable>
<polyline points="{$val}" style="stroke:{$color}; fill:

S.B.

-- 
    Stéphane Bonhomme           --           Exselt Services

Formations, Conseil et Réalisations en Ingénierie Documentaire,
             Technologies Web et Logiciels Libres
      [email protected]   -   http://www.exselt.com
         04 76 17 09 40        /      06 88 57 27 08
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.