AttributeManager
Allows user to create new attributes or rename, copy, delete and reorder existing attributes. The user may also set the values of both new and existing attributes to any combination of constants, attribute values, conditionals and expressions. Any feature that enters the transformer emerges with a new set of attributes as defined in the transformer’s parameters dialog.
Input Ports
This transformer accepts any feature.
Output Ports
Features with the created and modified attributes.
Parameters
Enabling this setting allows the user to set an attribute value based on the attributes of features prior or subsequent to the current feature. Attributes of prior features are referenced as feature[-1].AttrName, feature[-2].AttrName, etc. Attributes of subsequent features are referenced as feature[+1].AttrName, feature[+2].AttrName, etc. The attributes of the currently processed feature are accessed directly without a prefix, such as AttrName.
When retrieving the value of a prior feature, any changes made by the AttributeManager to that feature will take effect.
This parameter specifies the maximum number of prior features that can be referenced by the AttributeManager. If Multiple Feature Attribute Support is enabled, this must be a value from 0 to 100.
This parameter specifies the maximum number of subsequent features that can be referenced by the AttributeManager. If Multiple Feature Attribute Support is enabled, this must be a value from 0 to 100.
This parameter specifies the desired behavior when the specified attribute does not exist, has a null value, or has an empty string value. Such attributes can be thought of as unresolved attributes. For example, since there are no features prior to the first input feature, the AttributeManager will fail to resolve the value of feature[-1].AttrName for the first input feature. If this parameter is set to Use Empty String, the AttributeManager will resolve all unresolved attributes with an empty string. As another example, if the value of feature[+2] is the empty string and Use Other Value is specified, then the empty string will be treated as an unresolved attribute, and will be resolved as the value specified under Attribute Replacement Value.
If this parameter is set to Use Attribute Value of Closest Feature, then the unresolved attributes will be resolved as the corresponding attribute of the closest feature, if such a feature exists. When looking for closest features, features with unresolved attributes are skipped. For example, if the value of feature[-2].AttrName is unresolved, then to resolve the value of feature[-2].AttrName the AttributeCreator will look at the closest features to feature[-2], alternating between features prior to and subsequent to feature[-2]. It will first look at feature[-3].AttrName, followed by feature[-1].AttrName if needed, and then feature[-4].AttrName if needed, until all prior and subsequent features specified have been exhausted. If the attribute remains unresolved within the specified prior and subsequent features, then it will be resolved as the value specified in the Attribute Replacement Value parameter.
This parameter specifies the value used to resolve unresolved attributes when the If Attribute Value is Missing, Null, or Empty parameter is set to Use Attribute Value of Closest Feature (but there is no closest value found) or Use Other Value.
• Input Attribute: When the transformer is first opened this column will be populated with the full list of exposed attributes sent to the input port. The user does not have the ability to edit this field. When new attributes are created this field will be left blank.
• Output Attribute: This displays the name of the attribute after modification by the attribute creator. In the case of new attributes, this column simply gives the new attribute name. In the case of rename, this column displays the new name given to the corresponding input attribute. Similarly when the Action is set to Copy, this column gives the name of the copy. When Action is set to Delete this column becomes uneditable.
• Action: this column determines the action to be taken on the attribute. When creating a new attribute, the only action available is “Set Value” . When working with existing attributes the options available are “Rename”,”Copy”,”Delete”, and “Set Value”.
- When action is set to “Rename “ the attribute manager will behave similarly to the AttributeRenamer, it will rename the input attribute to the name specified in the ouput attribute.
- When action is set to “Copy“ the attribute manager will behave similarly to the AttributeCopier, it will create a copy of the input attribute with the name specified in the ouput attribute.
- When the action is set to “Delete” the input attribute will be deleted and removed from the output schema.
- When the action is set to “Set Value” the value of the input attribute will be changed to the value specified in the “Attribute Value” column.
- Attribute Value: the value in this column will be used to set the value of the input attribute in the case where “Action” is “Set Value”. In the case where “Action” is rename or copy this value will be applied when the input attribute is missing.
• Value: Enter values associated with attribute names.
- For the Value column, you can also click the browse button in the cell to open a code editor, as shown highlighted yellow in the image below:
This editor is useful for entering multi-line attribute values, such as HTML or XML fragments.
Characters can be expressed as regular characters but they can also include any number of control characters.
Special character sequences (Advanced Editor only) are interpreted as shown below:
Sequence |
Description |
---|---|
Ctrl+Shift+h (^H) |
Backspace (0x08) |
Ctrl+Shift+l (^L) |
Form feed (0x0c) |
Ctrl+Shift+j (^J) |
Newline (0x0a) |
Ctrl+Shift+r (^M) |
Carriage return (0x0d) |
Ctrl+Shift+i (^I) |
Tab (0x09) |
Ctrl+Shift+k (^K) |
Vertical tab (0x0b) |
Defining Special Characters
You can define special characters through the Basic or Advanced Editors. Click Open Editor from the parameter menu:
Basic Text Editor
Select Constant from the String Type column (or, in some transformers, the Value column) and click on the empty field in the column:
Click the browse button to the right of the column to open an Edit Value dialog. In this editor, enter characters using the shortcut keys from the table above.
Advanced Text Editor
Enter characters using the shortcuts from the table above.
Note: To see tab characters, click the Options menu on the bottom left and select Show Spaces/Tabs.
Arithmetic Editor
For more information, see ExpressionEvaluator and Arithmetic Editor.
Example
Features with the created attributes.
In Workbench, the new attributes are added to the transformer:
And if you output to an Inspector, the attributes and values appear in the Information pane:
Suppose we are given the dataset below:
ID |
Latitude |
Longitude |
---|---|---|
0 |
49.1640 |
-123.061 |
1 |
49.1643 |
-123.063 |
2 |
49.1642 |
-123.062 |
3 |
49.1642 |
-123.064 |
If the Number of Prior Features and Number of Subsequent Features parameters are both set to 2, then when the first feature is read, the AttributeManager has access to the following features:
Feature Reference |
ID |
Latitude |
Longitude |
---|---|---|---|
feature[-2] |
<missing> |
<missing> |
<missing> |
feature[-1] |
<missing> |
<missing> |
<missing> |
current feature |
0 |
49.1640 |
-123.061 |
feature[+1] |
1 |
49.1643 |
-123.063 |
feature[+2] |
2 |
49.1642 |
-123.062 |
Note that some attributes are missing because no features exist prior to the first feature.
After the second feature is read, the window of prior and subsequent features available to AttributeManager shifts to produce the following:
Feature Reference |
ID |
Latitude |
Longitude |
---|---|---|---|
feature[-2] |
<missing> |
<missing> |
<missing> |
feature[-1] |
0 |
49.1640 |
-123.061 |
current feature |
1 |
49.1643 |
-123.063 |
feature[+1] |
2 |
49.1642 |
-123.062 |
feature[+2] |
3 |
49.1642 |
-123.064 |
The following settings can be used to compute the average latitude and longitude of the two features prior to the currently processed feature:
When using multi feature mode, the Advanced Editor sorts the attributes for the current feature above the attributes of prior and subsequent features.
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
Search FME Knowledge Center
Search for samples and information about this transformer on the FME Knowledge Center.