How to re-asign a value to a variable in XSLT

R

RC

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!
 
K

kaeli

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=[URL]http://www.xslt.com/html/xsl-list/2002-04/msg00185.html[/URL]]
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

--
 
A

Anton Spaans

RC said:
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.
 
B

Bryce

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?

You can't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,436
Messages
2,571,696
Members
48,796
Latest member
Greg L.
Top