Subject: conditional variable assignment From: Mike Brown <mbrown@xxxxxxxxxxxxx> Date: Tue, 18 May 1999 10:46:47 -0600 |
I'm having to unlearn everything I take for granted in Perl when dealing with XSL. Take conditional variable assignments, like "if x, then a=b". Easy enough to do in XSL: <xsl:if test="some_expr"> <xsl:variable name="a" expr="b"> </xsl:if> Easy, that is, if you don't mind the fact that your variable only exists within the <xsl:if> node and its children. So, the following won't work: <xsl:variable name="color" expr="Get/Color/From/Some/@Attribute"> <xsl:choose> <xsl:when test="$color='red'"> <xsl:variable name="tint" expr="'pink'"> <xsl:variable name="shade" expr="'maroon'"> </xsl:when> <xsl:when test="$color='violet"> <xsl:variable name="tint" expr="'lavender'"> <xsl:variable name="shade" expr="'indigo'"> </xsl:when> <xsl:otherwise> <xsl:variable name="tint" expr="'light gray'"> <xsl:variable name="shade" expr="'dark gray'"> </xsl:otherwise> </xsl:choose> <xsl:text> The color is <xsl:value-of select="$color"/>... The tint is <xsl:value-of select="$tint"/> (not there, is it?)... The shade is <xsl:value-of select="$shade"/> (not there either!) </xsl:text> So, then, is the solution to be found in some less than obvious hierarchy of XSL instructions, or is an entirely different approach necessary? XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Need help with XSL Variable, Scott_Boag/CAM/Lotus | Thread | Re: conditional variable assignment, G. Ken Holman |
Re: XSL performance problem, Rick Ross | Date | Re: conditional variable assignment, G. Ken Holman |
Month |