How to re-asign a value to a variable in XSLT  
Author Message
RC





PostPosted: 2005-3-29 21:10:00 Top

java-programmer, How to re-asign a value to a variable in XSLT Sorry Dudes,

I couldn't find an appropriate group to post about XML/XSLT issues.
I can only post to these close groups.

In most of programming languages are VERY easy to do:

int i = 0;
i = 3;
i = i + 1;
i += 2;
i++;

But how can I do these in XSLT?

I got error when I do
<xsl:variable name="i" select='0' />
<xsl:variable name="i" select="$i + '1' />

Can dudes (American West Coast's Term) out there can help?

Thank Q!
 
kaeli





PostPosted: 2005-3-29 21:44:00 Top

java-programmer >> How to re-asign a value to a variable in XSLT In article <d2bk3l$5te$email***@***.com>, email***@***.com
enlightened us with...
>
> In most of programming languages are VERY easy to do:
>
> int i = 0;
> i = 3;
> i = i + 1;
> i += 2;
> i++;
>
> But how can I do these in XSLT?

You really shouldn't, even if you can.
Here's a great explanation why.

[quote src=http://www.xslt.com/html/xsl-list/2002-04/msg00185.html]
However, it's very dangerous to use extension functions or extension
elements that have side-effects in XSLT, such as counters or
extensions that read and update databases. This is because XSLT is
designed around the basic assumption that you can evaluate the same
expression multiple times without affecting the result of that or
other expressions.
[/quote]

More points made there, too. Check out the full link.
http://www.xslt.com/html/xsl-list/2002-04/msg00185.html

--
 
Anton Spaans





PostPosted: 2005-3-30 0:56:00 Top

java-programmer >> How to re-asign a value to a variable in XSLT
"RC" <email***@***.com> wrote in message
news:d2bk3l$5te$email***@***.com...
> Sorry Dudes,
>
> I couldn't find an appropriate group to post about XML/XSLT issues.
> I can only post to these close groups.
>
> In most of programming languages are VERY easy to do:
>
> int i = 0;
> i = 3;
> i = i + 1;
> i += 2;
> i++;
>
> But how can I do these in XSLT?
>
> I got error when I do
> <xsl:variable name="i" select='0' />
> <xsl:variable name="i" select="$i + '1' />
>
> Can dudes (American West Coast's Term) out there can help?
>
> Thank Q!

As the previous poster said as well, XSL is designed as a Meta Language, a
pure functional language that does not allow for so-called 'side-effects'.
Such languages are purely declarative in nature, allowing its
interpreters/compilers for any valid possible optimization that the
interpreters/compilers can come up with and no unpredictable side-effects
are introduced.
Take a look at this link:
http://www.kuro5hin.org/story/2002/1/13/223854/606

-- Anton Spaans.