[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] conditional variable assignment
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|