[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: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 18 May 1999 13:01:46 -0400
xsl param assignment
At 99/05/18 10:46 -0600, Mike Brown wrote:
>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:
>...
>So, then, is the solution to be found in some less than obvious hierarchy of
>XSL instructions, or is an entirely different approach necessary?

Something along the following lines should work for you:

<xsl:choose>
    <xsl:when test="$color='red'">
      <xsl:call-template name="text-template>
        <xsl:param name="tint" expr="'pink'">
        <xsl:param name="shade" expr="'maroon'">
      </xsl:call-template>
    </xsl:when>
    <xsl:when test="$color='violet">
      <xsl:call-template name="text-template>
        <xsl:param name="tint" expr="'lavender'">
        <xsl:param name="shade" expr="'indigo'">
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="text-template/>
    </xsl:otherwise>
</xsl:choose>

<xsl:template name="text-template">
  <xsl:variable name="color" expr="Get/Color/From/Some/@Attribute">
  <xsl:param-variable name="tint" expr="'light gray'">
  <xsl:param-variable name="shade" expr="'dark gray'">
  <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>
</xsl:template>

Note the use of defaults (I copied the ones from the otherwise clause).

I hope this helps.

.............. Ken

--
G. Ken Holman                  mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.           http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0  +1(613)489-0999  (Fax:-0995)
Website: XSL/XML/DSSSL/SGML services outline,  XSL/DSSSL shareware,
         stylesheet resource library, conference training schedule,
         commercial stylesheet training materials, on-line XSL CBT.


 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.