This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: declaring global variable in XSL!


Hi All,

If you are running your XSLT on the server (and your XSLT engine support 
extensions, like Xalan) you can create the extension, for example java 
extension, and save your variable in java class, then you have global 
variable for all transformations. See example here:

http://www.softcorporation.com/xsl/xsleasy3.html


>From: "Tim Watts" <timw@3d3.com>
>Reply-To: xsl-list@lists.mulberrytech.com
>To: <xsl-list@lists.mulberrytech.com>
>Subject: RE: [xsl] declaring global variable in XSL!
>Date: Tue, 21 Aug 2001 14:58:59 +1000
>
>You are unable to reassign variables in XSL.
>
>You will need to rethink the way you are approach this problem.
>
>Try :
>
><xsl:param name="js_var"/>
>
><xsl:variable name="var">
>   <xsl:choose>
>     <xsl:when test="$js_var='2'">two</xsl:when>
>     <xsl:when test="$js_var='1'">one</xsl:when>
>     <xsl:otherwise>zero</xsl:otherwise>
>   </xsl:choose>
></xsl:variable>
>
><xsl:value-of select="$var"/>
>
>Also, I think I remember somone saying recently that you cannot declare a
>*global* variable based on a condition.
>
>You might want to check on it, but prehaps if you look at your problem the
>variable may not need to be global, but local anyway.
>
>Tim Watts
>
>PS
>
>You say "I am passing this variable from javascript".  You do realise that
>XSL doesn't do client side transformations.
>
> > -----Original Message-----
> > From: owner-xsl-list@lists.mulberrytech.com
> > [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Syed
> > Abuthaheer
> > Sent: Tuesday, 21 August 2001 2:01 PM
> > To: Gitanjali; xsl-list@lists.mulberrytech.com
> > Subject: [xsl] declaring global variable in XSL!
> >
> >
> > hi all,
> > how can i declare a global variable whose value has to be
> > updated based on
> > some condition?
> > 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?
> > thanks in advance.
> > regards,
> > syed.
> >
> >
> >
> >  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]