The ListAppender adds new elements to an existing list, starting at a desired key or at the first available one. The user can set the values for the elements, based on constants, parameters or other feature attributes.
A user can specify a regular attribute for the List Attribute input parameter of this transformer, which will result in all features being rejected. The reason why this is possible in the first place, is because the ListAppender also supports nested lists, but FME has no parameter type that only allows selection of the "deepest nested list". Therefore, the only way this can be achieved, is by using a regular attribute input parameter, that will show the list key selection dialog once a list attribute has been selected. Below are a couple of examples that explain how the List Attribute parameter can be used.
Example 1
If the user wants to append elements at the end of nested list parent{3}.child{} (i.e. append children to parent nr. 3), the List Attribute input parameter should be set to parent{3}.child{0}. As a general rule, setting the last key to 0 means "just append the values at the end of whatever is there already". This means that even if parent{3}.child{} contains 6 elements (keys 0 - 5) already, the ListAppender will start appending values at key 6. No elements will ever be overwritten.
Example 2
If the user wants to append elements starting at exactly key 8 of list example{} (i.e. add elements example{8}, example{9}, etc.), the List Attribute input parameter should be set to example{8}. Note that if this list contains more than 8 elements already (e.g. 10 elements, so keys 0 - 9), the new ones will be appended starting at key 10 and further. No elements will ever be overwritten.
Example 3
If the user wants to append elements at the end of list example{}.value, the List Attribute parameter could be set to example{0}.value. If the user has specified 3 new items to add and the list already contained 2 elements, the result will be:
example{0}.value = 'existing item1'
example{1}.value = 'existing item2'
example{2}.value = 'new item1'
example{3}.value = 'new item2'
example{4}.value = 'new item3'
Note that if the ListAppender failed to append attributes to the list, the feature will be rejected and a _listappender_error attribute containing the failure reason will be added.
- Also available on FME Hub for convenient installation.
- This transformer has been tested on Python 2.7 and 3.4.
- Released under GNU General Public License v3.0.
- If you notice a bug or desire a new feature, please contact me. Or make a pull request!
- The test workspace is used for testing and provides some examples.
List Attribute
Select the list to which you would like to add new elements. Note that you can select regular attributes as well, but this will not work. Please refer to the examples in the Overview section.
Values to Add
Sets the element values you would like to append to the list. The number of values you specify here equals the number of elements that will be added. You can choose to insert values from other (list) attributes, parameters or constants, including null.