Subject: Re: conditional variable assignment From: Paul Prescod <paul@xxxxxxxxxxx> Date: Tue, 18 May 1999 13:11:01 -0500 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: conditional variable assignment, David Carlisle | Thread | RE: conditional variable assignment, Bovone Stefano |
Re: XSL performance problem, Oren Ben-Kiki | Date | Wanna Write a Tutorial?, Jay Greenspan |
Month |