Skip to main content

Loops within loops (nested loops)

Availability-noteDeprecated
This section describes the use of nested loops.

Consider that you want to model companies, the employees of a company and the email addresses of an employee, and that a company can have 0...many employees and each employee can have 0...many email addresses.

You could model this with a single MDM entity.

However, this has several disadvantages:

  • You would end up with one extremely large XML document for larger organizations, which would be hard to browse, process, search, view, etc.
  • The tXMLMap component in the Integration perspective of Talend Studio cannot easily (or at all, depending on the scenario) create such structures. You would need to use Talend Data Mapper, the Talend complex data mapping component which is more complicated to use than a tXMLMap and has potential performance implications.
  • You may be interested in a scenario where an individual works for more than one organization; this hierarchical approach cannot represent this.
  • You cannot use an MDM partial update to insert, update or delete an item in the email list. To use a partial update you need to be able to specify a pivot XPath, the XPath to the element that loops. But there are two pivots in this case:
    • company/employeeList/employeeItem: the loop for each employee
    • company/employeeList/employeeItem/emailList/email: the loop for each email of each employee
    As you can only specify one pivot, in the tMDMOutput component for example, a partial update on nested loops is not possible.

There will be more information on this in the following section. To summarize, the best practice is to avoid using loops within loops.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!