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

Re: conditional variable assignment

Subject: Re: conditional variable assignment
From: Paul Prescod <paul@xxxxxxxxxxx>
Date: Tue, 18 May 1999 13:11:01 -0500
perl conditional assignment
Mike Brown wrote:
> I'm having to unlearn everything I take for granted in Perl when dealing
> with XSL.

Unlearning Perl is always a good thing.

> So, then, is the solution to be found in some less than obvious hierarchy of
> XSL instructions, or is an entirely different approach necessary?

It depends on what you consider obvious and what you consider an entirely
different approach!

<xsl:variable name="color" expr="Get/Color/From/Some/@Attribute">

<xsl:variable name="tint">
<xsl:choose>
    <xsl:when test="$color='red'">
           pink
    </xsl:when>
    <xsl:when test="$color='violet">
           lavender
    </xsl:when>
    <xsl:otherwise>
           light grey
    </xsl:otherwise>
</xsl:choose>
</xsl:variable>

<xsl:variable name="shade">
<xsl:choose>
    <xsl:when test="$color='red'">
           maroon
    </xsl:when>
    <xsl:when test="$color='violet">
           indigo
    </xsl:when>
    <xsl:otherwise>
           dark grey
    </xsl:otherwise>
</xsl:choose>
</xsl:variable>

Another way would have been to put shade and tint into the same variable
using the technique above. Then you could use the substring functions to
get the part you wanted. A real list data structure would be nicer.

Who-was-it-that-said-if-a-programming-languge-doesn't-change-the-way-
you-think-about-programming-then-what-good-is-it 'ly yrs,

 Paul Prescod  - ISOGEN Consulting Engineer speaking for only himself
 http://itrc.uwaterloo.ca/~papresco

The dress code in Las Cruces New Mexico has been tightened [to] target 
Gothic clothing, such as dark trench coats. "It is not a witch hunt"
Superintendent Jesse L. Gozales said. "It is for the safety of the kids
in our schools."  - Associated Press, May 16 1999


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.