Defines a loop step iterating on XML nodes result from a source.
Also called For Each step, the Iterator step:
• defines a source as input list to work on, i.e. a list of nodes from a previous step, used as a recurring element (for example table rows),
• iterates on each element of the specified source,
• contains child steps that are executed on each iteration, as other loop steps (for example, see “jIterator”, “jWhile” and “jDoWhile” steps documentation and examples).
In the iteration, child steps can access and use the current iterated element:
• using a source pointing on the Iterator step itself,
• using the JavaScript variable named item, which is a Java Node object (item of the NodeList resulting from the input source).
They also can access the current iteration index using the JavaScript variable named index updated on each iteration, which is an integer.
Note: The current item value can be accessed using the following code statement:
• item.getTextContent() if the Node is of Text or Attribute type,
• item.getNodeValue() if the Node is of Element type.
Property | Type | Category | Description |
---|---|---|---|
Comment | String | standard | Describes the object comment to include in the documentation report. This property generally contains an explanation about the object. |
Is active | boolean | standard | Defines whether the step is active. |
Starting index | JS expression | standard | Defines the index from which the Iterator should start to iterate. In the case you do not want to start an iteration at the first item (index 0), you can specify a starting index in this property. This property is a JavaScript expression that is evaluated during the sequence execution. By default, it is set to 0 for starting at the first item of the source list. If the defined starting index does not exist in the source list, the loop does not execute its child steps and the parent sequence execution continues. |
Stopping index | JS expression | standard | Defines the exclusive index to which the Iterator should stop to iterate. Intended mostly for testing purposes, this (optional) parameter limits the number of times the iterator loops if this last index is reached. This property is a JavaScript expression that is evaluated during the sequence execution. By default, it is not filled, so the Iterator loops on each node from the source. |
Output | boolean | expert | Defines whether the XML generated by this step should be appended to the resulting XML. Set this property to true to add the step’s resulting XML to the sequence’s output XML (default value for steps generating XML). Set this property to false to prevent the steps’s XML result to appear in the sequence’s output XML. Setting this property to false does not prevent the step’s generated XML from being used as a source by other steps. |
Source | XMLVector | expert | Defines the source list to iterate on. This property allows defining a list of nodes from a previous step on which current step works. A source is defined as a reference on a step previously existing in the parent sequence, associated with an XPath applied on the step’s result DOM. At runtime, the XPath is applied on the step’s current execution result XML and extracts a list of XML nodes resulting from this execution. If the XPath doesn’t match or if the source is left blank, the step has no data to work on: the loop does not execute its child steps and the parent sequence execution continues. |