You need to read the XSL Spec or M Kay's XSLT book about
side effect free programming. Variables in XSL can only be assigned
once and never modified.

John G

xavier gibouin wrote:

hi this is my xsl code : <xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:fo="" xmlns:svg="">
<xsl:variable name="x" select="10"/>
 <xsl:template name="codebarre">
  <xsl:variable name="index" select="string-length(codebarre)"/>

  <xsl:param name="i" select="0"/>   <xsl:if test="$i &lt; $index">
    <xsl:when test="substring(codebarre,$i+1,1)='1'">
     <fo:block><xsl:value-of select="$x"/></fo:block>
     <xsl:variable name="x" select="$x + 4"/>
    <xsl:when test="substring(codebarre,$i+1,1)='2'">
     <fo:block><xsl:value-of select="$x"/></fo:block>
     <xsl:variable name="x" select="$x + 1.5"/>
    <xsl:when test="substring(codebarre,$i+1,1)='3'">
     <fo:block><xsl:value-of select="$x"/></fo:block>
     <xsl:variable name="x" select="$x + 3"/>
    <xsl:when test="substring(codebarre,$i+1,1)='4'">
     <fo:block><xsl:value-of select="$x"/></fo:block>
     <xsl:variable name="x" select="$x + 1.5"/>
   </xsl:choose>    <xsl:call-template name="codebarre">
    <xsl:with-param name="i" select="$i+1"/>
   </xsl:call-template>   </xsl:if>
</xsl:stylesheet> this code always writes1010101010... $x is not incremented any ideas? thanks a lot Xavier Gibouin
Espace Mercoeur
8, rue Mercoeur
44000 Nantes

----- Original Message -----
Sent: Tuesday, November 05, 2002 5:52 PM
Subject: Re: variable and svg

put braces around the variable when it is outside an xsl tag:

      <rect height="50" width="4.0" x="{$x}" y="0.0"/>


Reply via email to