[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

conditional variable assignment

Subject: conditional variable assignment
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Tue, 18 May 1999 10:46:47 -0600
conditional variable
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">

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:when test="$color='red'">
        <xsl:variable name="tint" expr="'pink'">
        <xsl:variable name="shade" expr="'maroon'">
    <xsl:when test="$color='violet">
        <xsl:variable name="tint" expr="'lavender'">
        <xsl:variable name="shade" expr="'indigo'">
        <xsl:variable name="tint" expr="'light gray'">
        <xsl:variable name="shade" expr="'dark gray'">
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!)

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


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.