Re: probleme variable xsl

Eric van der Vlist <[email protected]>
Newsgroups gmane.text.xml.french.tech
Organization Dyomedea (http://dyomedea.com)
Message-ID <[email protected]>
Bonjour,
Le mardi 19 septembre 2006 à 15:37 +0200, Stéphane Bonhomme a écrit :
> Stéphane ANCELOT wrote:

> 
> 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:

Exactement. Voir aussi
http://xmlfr.org/documentations/faq/010122-0003 ...

A noter également qu'il n'est pas indispensable d'utiliser une variable
dans ce cas et que vous pouvez écrire :

<polyline points="{$val}">
 <xsl:attribute name="style">
   <xsl:text>stroke:</xsl:text>
   <xsl:choose>
    <xsl:when test="$curvenr=1">red</xsl:when>
    <xsl:otherwise>yellow</xsl:otherwise>
   </xsl:choose>
   <xsl:text>; fill: none;stroke-width: 2;</xsl:text>
 </xsl:attribute>
 ...
</polyline>

Enfin, l'utilisation de l'attribut style en SVG est discutable et on
considère généralement et qu'il vaut mieux utiliser soit les attributs
spécifiques (stroke, stroke-width, ...) pour définir les styles dans les
documents (ce qui rendrait d'ailleurs l'option "sans variable" moins
verbeuse). 

Cordialement,

Eric van der Vlist

> S.B.
> 
-- 
GPG-PGP: 2A528005
Weblog:
                 http://eric.van-der-vlist.com/blog?t=category&a=English
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
(ISO) RELAX NG   ISBN:0-596-00421-4 http://oreilly.com/catalog/relax
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------


-- Attached file included as plaintext by Ecartis --

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQBFD/YtDvn+ZCpSgAURAqA6AJ9N0O1wNOqxJtp9hFZ/yEJi6cgVNQCfcXdD
zZKiOV5TDA/EVmB5UoYU5fc=
=QhaV
-----END PGP SIGNATURE-----
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.