|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: conditional variable 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
|
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
|

Cart








