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

RE: declaring global variable in XSL!

Subject: RE: declaring global variable in XSL!
From: Jarno.Elovirta@xxxxxxxxx
Date: Tue, 21 Aug 2001 07:33:32 +0300
declaring global variables in xsl
Hip hei

> how can i declare a global variable whose value has to be 
> updated based on
> some condition?

You can't in XSLT.

> for eg:
> <xsl:param name="js_var"/><!-- I am passing this variable 
> from javascript-->
> <xsl:variable name="var">zero</xsl:variable><!-- assigning 
> default value for
> the variable "var" -->
>  <xsl:if test="$js_var='1'">
>   <xsl:variable name="var">one</xsl:variable>
>  </xsl:if>
>  <xsl:if test="$js_var='2'">
>   <xsl:variable name="var">two</xsl:variable>
>  </xsl:if>>
>  <xsl:value-of select="$var"/>
> 
> the above code is not giving the proper output. can anybody 
> help me to solve
> this problem?

If the above is what you want to do, then 

<xsl:param name="js_var"/>
<xsl:variable name="var">zero</xsl:variable>
 <xsl:choose>
   <xsl:when test="$js_var='1'">one</xsl:when>
   <xsl:when test="$js_var='2'">two</xsl:when>
   <xsl:otherwise>
     <xsl:value-of select="$var"/>
   </xsl:otherwise>
 </xsl:choose>

Would work.

Jarno

 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.