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

RE: Variables in XSL!


variables in xsl
No, it is not possible to assign to a variable in XSL / XSLT. XSL is
intentionally designed to be free from side-effects, meaning a sections
could be evaluated in any order. Obviously, assignment to a variable would
break this. For an explanation of why this is a good thing, see Michael
Kay's XSLT 2nd Edition, p. 37-38.

So, obviously XSL is a very different kind of language. When you think
VBScript, you are thinking about _procedural_ programming languages. XSL is
a _declarative_ language. This doesn't mean you can't achieve the behavior
you want, it just means that you have to think about it in a different way.

When you write i=i+1 you are iterating over a set of values, which you can't
do in XSL. But you can use recursion which is provided by the
<xsl:apply-templates> and <xsl:for-each> tags. Again see Michael Kay's book,
the section on Computational Stylesheets, p. 608-627, esp. p. 620 which
virtually restates your problem.

Cheers,
Stuart

-----Original Message-----
From: Peter Thornqvist [mailto:thornqvist_peter@h...]
Sent: Tuesday, November 27, 2001 20:03
To: xml-dev@l...
Subject:  Variables in XSL!

Hi!

Is it possible to have variables/counters
in XSL, like in vbscript: i=i+1 etc?.
I would like to keep track of when the 10th value comes and then
do a line break...

/Peter

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


-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://lists.xml.org/ob/adm.pl>


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.