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

Re: Assigning variable values

Subject: Re: Assigning variable values
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Fri, 24 May 2002 22:11:29 +0200
assigning variable in xsl
Georges Claessen wrote:
Hi Joerg. You said that I couldn't change the value of
an global scope variable. But I do this and it works
perfectly. In fact many people say that it won´t work,
but it remains as a mistery to me cause I made it
work.
Thanks for your attention! :o)

I don't know what processor you are using, but I don't believe that. It's not possible in XSLT! You didn't change the value, you only create a local variable.


Test it in the following way:

XML:

<root>
</root>

XSLT:

<xsl:variable name="teste" select="'um'"/>
<xsl:variable name="um" select="'um'"/>
<xsl:variable name="dois" select="'dois'"/>

<xsl:template match="/">
  <xsl:text>original: </xsl:text>
  <xsl:variable name="teste">
    <xsl:choose>
      <xsl:when test="$teste='um'">
        <xsl:value-of select="$dois"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$um"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:text>after "changing the value":</xsl:text>
  <xsl:value-of select="$teste"/>
  <xsl:apply-templates select="root"/>
</xsl:template>

<xsl:template match="root">
  <xsl:text>value still changed? :</xsl:text>
  <xsl:value-of select="$teste"/>
</xsl:template>

You will see, that you didn't change the value of the global variable - or you don't have a XSLT-processor.

Regards,

Joerg


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.