OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [xml-dev] 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.


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


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...


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>