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

Re: Initializing global variables

Subject: Re: Initializing global variables
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Wed, 5 Jun 2002 03:59:28 -0700
pgp global variable
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 05 June 2002 01:49, trang_nguyen@xxxxxxxxxxx wrote:
> I understand that the value of a variable cannot be modified once it has

[Semantic nitpicking: *all* variables, global or not, cannot be modified -- 
only "covered up" by local declarations]

> been assigned, but is it possible to allocate a global variable at the
> start of a stylesheet and then assign it a value at a later time, such as
> within a named template?
>
> Example (doesn't work since notepadDesc is treated as a local variable in
> portFreqTemplate):
>...

There is no way to make your example work, because allocating a global 
variable with no value is the same thing as, well, assigning it to the empty 
string/node-set.  Your analysis is correct, but there is no way around it.

The way most people achieve what you want is to move the call to the template 
that outputs the value into the variable declaration itself:

<xsl:variable name="notepadDesc">
  <xsl:call-template name="portFreqTemplate">
    <xsl:with-param name="portFreqParam"
      select="/path/to/portFreqParam"/>
  </xsl:call-template>
</xsl:variable>

Sorry, but there is no other way to do it, unless you want to do some 
preprocessing of the source XML by an external program and pass the value as 
a stylesheet param.

- -- 
Peter Davis
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8/e8SNSZCJx7tYycRAvpzAKCVtKuhNy/KV/sxX2JLiDrYwEAFcgCgm9j0
s8yjKw8ql2sfUugvELSy7PE=
=NSjT
-----END PGP SIGNATURE-----


 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.