ListRenamer
Renames or promotes list names or components. When promoting or renaming, if the resulting name collides with an existing attribute name, the existing attribute will be overwritten.
For the discussion below the following terms are introduced:
- Component – This is a piece of an attribute name. For example, in list{}.blat{}.foo, there are 3 components. Two components are lists: list{} and blat{}. One component is not a list: foo.
- Subcomponent – This is a component of a list. Thus, in list{}.blat{}.foo, blat{} is a subcomponent of list{}. Similarly, foo is a subcomponent of blat{}.
- Structured List – a list for which a subcomponent contains more than one piece of data. The elements of the structure are represented as foo{}.a or foo{}.b.
Parameters
The selected list and list components that will be renamed or promoted. Selecting a list will cause the table to populate with the components available for renaming.
Changing the List to Process will cause the List Action to switch to Rename.
The action to perform on the list.
- Rename means the components in the selected name will be renamed only. The components of the selected list will be listed in the ‘List Component Name’ column of the List Components To Rename table. The ‘New Name’ will default to the old one.
-
Promote means the last component of the List to Process will be promoted. It will no longer be a subcomponent of the list but a ‘sibling component’.
If the last component is not a list, that item will become a list at the same level as its parent list.
If the last component of the List To Process is a list, then the user will be prompted to select a list index to promote. When promoting a specific element within a list, the behavior will depend on whether the list is structured (ie. List{}.bar{}.a). If it is structured, then the subcomponents will become subcomponents of the parent. If the list is unstructured (ie. List{}.bar{}.foo{}), then the list name will become a component at the same level as the parent list (ie. List{}.foo).
If this option is selected, the List Components to Rename will be populated with the components of the List to Process up until the last component.
-
Promote All Subcomponents means that all subcomponents of the selected list will be promoted. This option is only available if none of the subcomponents are lists. Each subcomponent will become a list at the same level as the parent list.
If this option is selected, the List Components to Rename will give the list of the subcomponents of the List to Process.
When promoting list components, the promoted components will receive the index of their parent. As a result, if the incoming list has gaps, the outgoing list will also have gaps.
Whether or not to delete the original list entry when renaming. If set to Yes then renaming will create a new attribute with the desired name and the original entry will still remain. If set to No then the attribute will be renamed.
When promoting a specific element in a list, if Keep Original List is set to No, all list elements that do not match the specified element to promote will be removed.
This table will be populated appropriately when the user selects a List to Process and List Action. For each component, the ‘New Name’ column specifies the desired name for the component.
To rename a component, type the desired component name in the ‘New Name’ column for that component. Then at runtime, the transformer will rename the components to the desired component names.
Examples
Example 1
If the List to Process is somelist{} and the incoming feature contains:
somelist{0}.length = 7.3
somelist{2}.length = 5
somelist{3}.height = 6
If somelist{} is renamed to anotherName{}, the result will be:
anotherName{0}.length = 7.3
anotherName{2}.length = 5
anotherName{3}.height = 6
Example 2
If the List to Process is somelist{}.listTwo{}, the List Action is Promote – listTwo{1}, and the incoming feature contains:
somelist{0}.listTwo{0} = 0
somelist{0}.listTwo{1} = 1
somelist{0}.listTwo{3} = 2
Then the result will be:
somelist{0}.listTwo = 1
Example 3
If the List to Process is somelist{}.listTwo{}, the List Action is Promote – listTwo{1} and the incoming feature contains:
somelist{0}.listTwo{0}.length = 0
somelist{0}.listTwo{1}.length = 1
somelist{0}.listTwo{1}.height{0} = 3
somelist{0}.listTwo{3}.length = 2
Then the result will be:
somelist{0}.length = 1
somelist{0}.height{0} = 3
Example 4
If the List to Process is somelist{}, the List Action is Promote All Subcomponents and incoming feature contains the following:
somelist{0}.length = 7.3
somelist{2}.length = 5
somelist{3}.height = 6
The result will be:
length{0} = 7.3
length{2} = 5
height{3} = 6
Additional Resources
Editing Transformer Parameters
Using a set of menu options, transformer parameters can be assigned by referencing other elements in the workspace. More advanced functions, such as an advanced editor and an arithmetic editor, are also available in some transformers. To access a menu of these options, click beside the applicable parameter. For more information, see Transformer Parameter Menu Options.
Transformer Categories
FME Community
The FME Community is the place for demos, how-tos, articles, FAQs, and more. Get answers to your questions, learn from other users, and suggest, vote, and comment on new features.
Search for samples and information about this transformer on the FME Community.