Subject: Re: [xsl] Assigning variable values From: Georges Claessen <georgesdamata@xxxxxxxxx> Date: Fri, 24 May 2002 12:30:07 -0700 (PDT) |
Hi Joerg. You said that I couldn't change the value of an global scope variable. But I do this and it works perfectly. In fact many people say that it won´t work, but it remains as a mistery to me cause I made it work. Thanks for your attention! :o) --- Joerg Heinicke <joerg.heinicke@xxxxxx> wrote: > Hello Georges, > > the variable got out of scope, if you declare them > in <xsl:when/>. You > have to turn around the XSL-elements: > > <xsl:variable name="teste" select="'um'"/> > <xsl:variable name="um" select="'um'"/> > <xsl:variable name="dois" select="'dois'"/> > > <xsl:template match="/"> > <xsl:variable name="teste"> > <xsl:choose> > <xsl:when test="$teste='um'"> > <xsl:value-of select="$dois"/> > </xsl:when> > <xsl:otherwise> > <xsl:value-of select="$um"/> > </xsl:otherwise> > </xsl:choose> > </xsl:variable> > <xsl:value-of select="$teste"/> > </xsl:template> > > But I don't know whether you know that variables > can't be re-assigned. > So in the global variable there is still stored > 'um', only in the local > one the value is 'dois'. This behaviour can be > reproduced with MSXML. > With Xalan it's not possible. You will get an error > "Variable accessed > before it is bound!" I think that's not the correct > behaviour, is it? > > Joerg > > Georges Claessen wrote: > > Could somebody help me on this issue? I am having > a > > problem assingning values to a variable. Look > > the example: > > > > -------------------------------------------- > > These ones were declared globally: > > > > <xsl:variable name="teste" select="'um'"/> > > <xsl:variable name="um" select="'um'"/> > > <xsl:variable name="dois" select="'dois'"/> > > -------------------------------------------- > > > > > > -------------------------------------------- > > This code was declared inside a template: > > > > <xsl:choose> > > > > <xsl:when test="$teste = 'um'"> > > <xsl:variable > name="teste"><xsl:value-of > > select="$dois"/></xsl:variable> > > </xsl:when> > > > > <xsl:otherwise> > > <xsl:variable name="teste" > select="$um"/> > > </xsl:otherwise> > > > > </xsl:choose> > > > > <font face="arial" size="3"><xsl:value-of > > select="$teste"/></font> > > -------------------------------------------- > > > > > > This code only returns me the value 'um'. The when > > clause is working, > > but the assigning of value to the $teste variable > is > > no working > > inside the choose clause. > > > > Could somebody please help me? Thank you very > much! > > > > Georges Claessen > > Brazil > > > XSL-List info and archive: > http://www.mulberrytech.com/xsl/xsl-list > __________________________________________________ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Assigning variable values, Joerg Heinicke | Thread | Re: [xsl] Assigning variable values, Joerg Heinicke |
Re: [xsl] xslt generator, E L | Date | [xsl] defaulting empty node to zero, Chuck Paussa |
Month |