CAs with the @while attribute, an @iterate should be added to perform the action to which the attribute is attached once for each node of the nodeset.
- iterate expression is evaluated only once when encountered and not subsequently reevaluated
- insert/delete have the same impact they do if they impact the context node of a regular expression
- they don't cause the iterate expression to be reevaluated
- this means you can have detached nodes in an iteration
- XPath 2.0, iterate over a sequence rather than nodeset.
Spec ready text
The iterate attribute
The iterate attribute can be added to any XForms action. It contains an expression that is evaluated once using the in-scope evaluation context before the action is executed, which will result in a sequence of items. The action will be executed with each item in the sequence as its context. This context replaces the default in scope evaluation context.
<xforms:delete nodeset="." at="1" iterate="node[@selected='true']"/>
Note: Notice that the iterate changes the evaluation context for if and while. Also notice the iterate is evaluated before any of the two
Ednote: Deleting the current iteration node, or a node that is not at a position after the current node in the iteration sequence, no effect on following iterations. But we currently didn't came to a consensus on what should happen with the iteration sequence when a node is deleted that is at a position after the current node in the iteration sequence. There are two possibilities. The first is to to behave as if those removed nodes are also removed from the iteration sequence, and consequently don't visit those nodes in the future iterations. The second is to just visit the nodes that are already deleted (the nodes were there when the iteration sequence was created)
Please see John's note (http://lists.w3.org/Archives/Public/public-forms/2011Oct/0009.html) for proposed answers to these issues
The specification should identify what happens:
- if the contained action sequence deletes nodes from the nodeset being iterated (JB: should skip nodes that are stale due to deletion)
- if nodes are inserted into the nodeset (JB: should ignore new nodes in for-each behavior)
- if the action sequence sets a value that is consumed by a predicate in the nodeset, thereby indirectly adding to or deleting from the nodeset (JB: should ignore new nodes in for-each behavior; shouldn't be different if new nodes come from predicate match versus name test match)
- what is order of application of @iterate @if @while? Are they all allowed on the same action or must you nest the actions to clearly show intent? http://lists.w3.org/Archives/Public/public-forms/2011Sep/att-0019/2011-09-21.html#topic5 (JB: iterate outermost and sets context for while and if, while next per current spec, then if; perhaps set support to MAY)
* Orbeon * FormsPlayer