Re: [xsl] Variable value change based on condition

Subject: Re: [xsl] Variable value change based on condition
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 05 Oct 2010 14:09:11 +0100
On 05/10/2010 13:59, sudheshna iyer wrote:
Can this be achieved in xslt 1.0?



You just repeated your initial question.


XSLt doesn't have "inout variables" and "output variables" I'm guessing that you mean, respectively, parameters and variables, but it's hard to be sure.

variables always have a value if declared so you need to say what value you want for each of your three variables.

I'm guessing that you want, for variable3 something like the first of input3,input2,input1 that is not empty.

In XSLT2 that would be

<xsl:variable name="variable3"
select="($var3,$var2,$var1)[not(.='')][1]"/>

on xslt1 if you could use



<xsl:variable name="variable3" >
<xsl:choose>
<xsl:when test=not($var3='')"><xsl:value-of select="$var3"/></xsl:when>
<xsl:when test=not($var2='')"><xsl:value-of select="$var2"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$var1"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>


David


________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________


Current Thread