Please enable JavaScript to view this site.

Altova MapForce 2022 Basic Edition

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.

mf-func-replicate-item

 

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.

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>
  <person>
    <name>Michelle</name>
    <count>2</count>
  </person>
  <person>
    <name>Ted</name>
    <count>4</count>
  </person>
  <person>
    <name>Ann</name>
    <count>3</count>
  </person>
</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:

mf-func-replicate-item-example

The output is as follows:

 

<TargetLists>
  <TargetList>
    <TargetString>Michelle</TargetString>
    <TargetString>Michelle</TargetString>
  </TargetList>
  <TargetList>
    <TargetString>Ted</TargetString>
    <TargetString>Ted</TargetString>
    <TargetString>Ted</TargetString>
    <TargetString>Ted</TargetString>
  </TargetList>
  <TargetList>
    <TargetString>Ann</TargetString>
    <TargetString>Ann</TargetString>
    <TargetString>Ann</TargetString>
  </TargetList>
</TargetLists>

© 2016-2022 Altova GmbH