replicate-item
Repeats every item in the input sequence the number of times specified in the count argument. If you connect a single item to the node/row input, the function returns N items, where N is the value of the count argument. If you connect a sequence of items to the node/row input, the function repeats each individual item in the sequence count times, processing one item at a time. For example, if count is 2, then the sequence 1,2,3 produces 1,1,2,2,3,3. It is also possible to supply a different count value for each item in the input sequence, as illustrated in the example below.
Languages
Built-in, C++, C#, Java, XQuery, XSLT 2.0, XSLT 3.0.
Parameters
Name | Description |
---|---|
node/row | This input must receive a connection from a mapping item that provides a sequence of zero or more values. For example, the connection may originate from a source XML item, a CSV field, a database record, and so on. |
count | Specifies the number of times to replicate each item or sequence connected to node/row. |
Example
Let's assume that you have a source XML file with the following structure:
<SourceList> |
With the help of the replicate-item function, you can repeat each person name a different number of times in a target component. To achieve this, connect the count node of each person to the count input of the replicate-item function:
The output is as follows:
<TargetLists> |