RE: [xsl] XSL Variable not getting set

Subject: RE: [xsl] XSL Variable not getting set
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 14 Mar 2007 15:44:19 -0000
> <xsl:for-each select="1 to 12">
>              <xsl:variable name="p" select="."/>
>              <xsl:value-of select="if ($cg[@month=$p]) then 
> $cg[@month=$p]/@cost else 0"/>
>              <xsl:if
> test="position()!=last()">,</xsl:if>
>            </xsl:for-each>
> 
> 
> I had no idea you could loop that way with XSL. 

You can make it even tighter if you like:

<xsl:value-of 
  select="for $p in 1 to 12 return ($cg[@month=$p]/@cost, 0)[1]"
  separator=","/>

Michael Kay
http://www.saxonica.com/

Current Thread