Updating variables in xquery
Composability constraints are given for updating expressions in new expressions as well as for sequential expressions.
In addition to the updating/non-updating categorization, XQSX introduces another dimension to classify expressions: sequential/non-sequential expressions.
It also introduces block expressions, which may contain statements and thus also have side effects.
Such expressions must be evaluated in a specific order, which is described here.
At the time this tutorial was written, there were already a few implementations: Monet DB (CWI), Qizx (XMLmind), Oracle Berkeley DB XML (Oracle), XQilla.
At least on Zorba, this is called the Zorba Scripting Extension (scroll to the bottom, header "Scripting") which adds side-effecting imperative programming constructs to XQuery.
XQuery Scripting Extension Proposal extends XQuery 3.0, enabling it to serve as a scripting language in order to satisfy XQuery Scripting Requirements.The side effects of a sequential expression are immediately effective and are visible to subsequent expressions.Because of their side effects, sequential expressions must be evaluated in evaluation order, as defined in this specification.Statements have to be executed in the evaluation order defined in XQSX.] XQSX introduces the following statements: XQSX builds on top of XQuery 3.0 and XQuery Update 1.0, so that it keeps the same constraints about an expression being simple (if it returns an empty PUL), updating (if it returns an empty XDM) or vacuous (if both are empty).This specification takes into account the fact that the XQUF specification might evolve and allow an updating expression to return both a PUL and an XDM.