Re: [xsl] xsl:if @attribute + xsl:variable not working

Subject: Re: [xsl] xsl:if @attribute + xsl:variable not working
From: Alessio Mazzieri <mazzieri@xxxxxxxxxxx>
Date: Wed, 28 Nov 2001 09:35:01 +0100
This is an alternative solution to your problem:

<xsl:for-each select="area">
    <xsl:attribute name="bgcolor">
        <xsl:when test="@position=1">

About the message error, I think that the problem is an "out-of-scope" matter, because both the <xsl:variable> are inside an <xsl:if> element.
Give an eye to Mickeal Kay's XSLT Programmers Reference, page 315: the same example! :)

Aniceto Lopez wrote:

Hi all:
why if

<xsl:for-each select="area">
    <xsl:if test="@position = 1">
      <xsl:variable name="color" select="'#FFF7A0'"/>
    <xsl:if test="@position = 2">
      <xsl:variable name="color" select="'#FF980F"/>

<td bgcolor="{$color}">dadada asda</td>


I get this?

"A reference to variable or parameter 'colortabla' cannot be resolved.
The variable or parameter may not be defined, or it may not be in scope."

-> the variable IS in scope (if I define it without xsl:if it works)
xml -> <area position="1"> or <area position="2">

thanks in advance

Aniceto Lopez

XSL-List info and archive:

XSL-List info and archive:

Current Thread