The W3C XQuery working group has posted new working drafts of XQuery Scripting Extension 1.0 and XQuery Scripting Extension 1.0 Use Cases:
The principal extensions introduced by XQSE are as follows:
An ordering is defined on the evaluation of certain kinds of XQuery expressions. An implementation may use any execution strategy as long as the result complies with the semantics of this ordering. The ordering is defined in a way that places no additional constraints on the evaluation of any valid XQUF or [XQuery 1.0] expressions.
Expressions in XQSE may have side-effects that are visible to subsequent expressions (according to the above ordering of evaluation).
XQSE introduces the following new kinds of expressions:
Apply (semicolon) expressions
Blocks
Assignment expressions
Exit expressions
While expressions
XQSE relaxes the constraints on the placement of updating expressions, so that a non-empty XDM instance can be returned by an expression as well as a non-empty pending update list. In order to allow this, new rules to determine the category and resulting pending update list are added to every existing expression.
XQSE introduces a new expression category called sequential expressions. The simple and updating expression categories introduced by XQUF are retained, but the vacuous expression category no longer has significance. Informal definitions of all the expression categories are summarized here. For normative definitions of the categories, see the "Category Rules" that are specified for each kind of expression in [2.3 New Kinds of Expressions] and [2.4 Changes to Existing Expressions].
[Definition: An updating expression is an expression that can return a non-empty pending update list.] Updating expressions include insert, delete, replace, rename, and calls to updating functions, as well as certain other expressions that contain nested updating expressions. An updating expression may return a non-empty XDM instance as well as a non-empty pending update list - however note that it does not actually apply any updates.
[Definition: A sequential expression is an expression that can have side effects other than constructing a new node or raising an error.] Side effects include applying updates to an XDM instance, altering the dynamic context, or affecting the flow of control. Sequential expressions include apply expressions, assignment, exit, while, and calls to sequential functions, as well as certain other expressions that contain nested sequential expressions. 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 a well-defined order. In addition to its side effects, a sequential expression may return a non-empty XDM instance, but it never returns a non-empty pending update list.
[Definition: A simple expression is an expression that is neither an updating expression nor a sequential expression.] A simple expression may return an XDM instance, and it may construct a node or raise an error.
The classification of each expression into one of the above categories is performed by static analysis. For each kind of expression, XQSE provides rules that specify the required categories of the operand expressions and the category of the expression itself.