A custom transformer can receive space delimited attribute names through "Attribute List (space delimited)" type user parameter.
Typically, a parameter of this type would be used to link to "Group By" of transformer(s) in the custom transformer. In such a case, it's not necessary to retrieve values of the attributes.
But there could also be some cases where those values are necessary. e.g. use concatenated attribute values as Counter Name of a Counter.
Value of the parameter is a string. If specified attributes are "attr1", "attr2", and "attr3", for example, the value of parameter will be "attr1 attr2 attr3" (space delimited attribute names). And if an attribute name contains white spaces, it will be quoted by double quotations.
I think Tcl scripting is an easy way to concatenate specified attribute values.
First, use a ParameterFetcher to store the parameter value (i.e. specified attribute names) as an attribute. e.g. named "_attr_names".
And then, use a TclCaller with this script to create a concatenated string.
If no attributes were specified, this procedure returns an empty string.
-----
proc concatAttributeValues {} {
set values {}
foreach attr [FME_GetAttribute "_attr_names"] {
lappend values [FME_GetAttribute $attr]
}
return [join $values {_}]
}
-----
It worked fine even if specified attribute names contain white spaces.
FME 2014 SP3 build 14391
No comments:
Post a Comment