Hello,
I'm a little bit confused concerning variable updates in XQuery: On [1] it says:
Variables can't be updated. This means you can't write something like let $x := $x+1. This rule might seem very strange if you're expecting XQuery to behave in the same way as procedural languages such as JavaScript. But XQuery isn't that kind of language, it's a declarative language and works at a higher level. There are no rules about the order in which different expressions are executed (which means that the little yellow triangle that shows the current execution point in the Stylus Studio XQuery debugger and XSLT debugger can sometimes behave in surprising ways), and this means that constructs whose result would depend on order of execution (like variable assignment) are banned.
I'm wondering if there is really no way to reliable update a variable? Maybe I'm just to used to those things in other languages, but I can't really imagine / believe it ;-)
[1] http://www.stylusstudio.com/xquery_flwor.html, second paragraph below the screenshots of the chapter "L is for LET"
UPDATE: I have to add a question to this: Shouldn't it be possible to update an existing variable in an if statement because in this case the order of execution is clear? I guess you just aren't allowed to use something like $x = $x+1 in a loop?