Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Setting a a variable to a default value >Thread Next - Re: Setting a a variable to a default value Re: Setting a a variable to a default valueTo: NULL Date: 12/4/2008 4:40:00 PM kpg wrote:
> So something like this will not work:
>
> <xsl:choose>
> <xsl:when test="not(//Display_Count)">
> <xsl:variable name="loop_num" select="1"/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:variable name="loop_num" select="//Display_Count"/>
> </xsl:otherwise>
> </xsl:choose>
The other way round works:
<xsl:variable name="loop_num">
<xsl:choose>
<xsl:when test="not(//Display_Count)">3</xsl:when>
<xsl:otherwise>
<xsl:value-of select="//Display_Count"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
With XSLT 2.0 you could use the much shorter
<xsl:variable name="loop_num"
select="if (not(//Display_Count)) then 3 else
//Display_Count"/>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
