Skip to main content
Solved

Create sub-element to every element of the list

  • December 31, 2024
  • 1 reply
  • 57 views

syedh2993
Contributor
Forum|alt.badge.img+7

Hi All,

I am working with lists and require some guidance on the below scenario

I have list which contains 'n' elements. I would like to add a sub-element to each element in the list.

Assuming my list name called as "list{}"

Example: (My list currently looks like this)

    List{0}
        element1
        element2
        element3
    List{1}
        element1
        element2
        element3
    List{2}
        element1
        element2
        element3
    List{n}
        element1
        element2
        element3

        
I would like to add new sub-element called "element4" at the end of each list element (i.e., add "element4" as sub-element below "element3" )        

Expected Output (I would like to achieve something like below)

    List{0}
        element1
        element2
        element3
        element4
    List{1}
        element1
        element2
        element3
        element4
    List{2}
        element1
        element2
        element3
        element4
    List{n}
        element1
        element2
        element3
        element4


In Java world, I would ideally use looping to iterate through the list and add sub-element. Not sure how to perform similar scenario in FME. Would really appreciate your help in achieving the above expected output.

Thanks in advance

Best answer by geomancer

In the example you provided, one way would be to explode the list, add the extra attribute, and finally rebuild the list including the new attribute.

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

geomancer
Evangelist
Forum|alt.badge.img+60
  • Evangelist
  • Best Answer
  • January 1, 2025

In the example you provided, one way would be to explode the list, add the extra attribute, and finally rebuild the list including the new attribute.