The advanced, utilities workflow component, Repeat creates a loop in which the components following it are executed a number of times. At the start of each repetition, the workflow payload and variables are reset to the state they have at the point where the repeat component is placed, so you cannot keep track of the current number of repetitions with a variable.
The maximum number of allowed repetitions is 1000.
The repeat workflow component has these parameters:
Number of repetitions
This is the number of repetitions, that will be executed. The number can be not only fixed, but can also be set via an XPath expression, where e.g. contents of an input file is used. You can also consider to count the number of nodes in the input XML file and use that with this XPath expression: count(/Root/Document).
Keep variable values and payload between repeats
If this option is disabled, then the initial set of variables and payload is reset to the initial values for all repeat iterations, but if you enable this option, then the workflow variables and the payload is kept for each iteration.
So if you want e.g. to do a repeat loop and keep track of the current number of repeats, then you will need to enable this option. If you want to keep the initial payload for each iteration, then you can consider first to save the initial payload before the repeat e.g. with the component, Payload to named property and then start each iteration in the repeat loop with the component, Named property to payload to reload the original payload.
Important: Please note, that a workflow variable is always defined as a string, so if you use such a variable as index in XPath, then you need to cast this as a number e.g. like so:
/Root/Document[number($Index)]/@Company.
Also if you want to create a counter to keep track of the current number of repeats, then you need also to use the number function, when you increment the value e.g. like so:
Example
This will create 3 identical print outs: