[xsl] greenhorn problem with variables

Subject: [xsl] greenhorn problem with variables
From: Volker Katz <Volker.Katz@xxxxxx>
Date: Sat, 19 Mar 2005 12:19:22 +0100
Hi,
I've got a quite simple problem. I've tested a lot, but didn't get the 
solution.So I hope you give me a hint.

In a template I calculate a bgcolor depending on position:
<xsl:template match="eintrag">
  <xsl:variable name="color"> 
    <xsl:choose>
      <xsl:when test="(position() mod 2) &gt; 0">#C0C0C0</xsl:when>  
      <xsl:otherwise>#FFFFFF</xsl:otherwise>
    </xsl:choose>
  </xsl:variable> 
  <tr>
     <xsl:apply-templates select="nr"/> 
     <xsl:apply-templates select="km"/>
   <!-- ... -->
  </tr>
</xsl:template>

I need to use the variable in the applied templates. Here is an example:
<xsl:template match="nr">
  <td bgcolor="{$color}"> 
    <xsl:value-of select="."/>
  </td>
</xsl:template>

How can I solve this? I can't calculate the color global... Can I solve 
this with params instead of varialbes? I tried but didn't get it.

Best regards
  Volker

Current Thread