Skip to main content
Solved

Renaming attributes configuration in a custom transformer?

  • June 30, 2016
  • 11 replies
  • 38 views

lifalin2016
Supporter
Forum|alt.badge.img+39

Hi,

I've tried to wrap some specific functionality in a custom tranformer in Workbench, and have defined a parameter (in the custom transformer) to be the name of the new attribute containing the output I'm calculating.

I'm creating the value into a temp local attribute (for a reason, I'm deleting it at the end), but cannot apparently rename or copy this temp attribute to an attribute with the configured name ?

Cheers

 

Lars

Best answer by takashi

My usual (secret ;) trick is to use a BulkAttributeRenamer. This exposes the specified attribute name automatically.

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.

11 replies

lifalin2016
Supporter
Forum|alt.badge.img+39
  • Author
  • Supporter
  • June 30, 2016

david_r
Celebrity
  • June 30, 2016

You can indeed rename an attribute in a custom transformer based on a published parameter, e.g. if your parameter is called "NewName":

What complicates it slightly, though, is that the attribute name "NewName" isn't automatically exposed (made visible) in the Workbench editor, you will have to do that manually using e.g. an AttributeExposer after calling the custom transformer.


takashi
Celebrity
  • Best Answer
  • June 30, 2016

My usual (secret ;) trick is to use a BulkAttributeRenamer. This exposes the specified attribute name automatically.


david_r
Celebrity
  • June 30, 2016

My usual (secret ;) trick is to use a BulkAttributeRenamer. This exposes the specified attribute name automatically.

Nice trick!


lifalin2016
Supporter
Forum|alt.badge.img+39
  • Author
  • Supporter
  • June 30, 2016

You can indeed rename an attribute in a custom transformer based on a published parameter, e.g. if your parameter is called "NewName":

What complicates it slightly, though, is that the attribute name "NewName" isn't automatically exposed (made visible) in the Workbench editor, you will have to do that manually using e.g. an AttributeExposer after calling the custom transformer.

Hi David,

No, that doesn't work, and I did try this before I posted.

I get the error: Undefined macro `NEW_NAME' dereferenced in file `C:\\Users\\lin\\Documents\\My FME Workspaces\\wb-xlate-1467288075556_12320'

Cheers

 

Lars

lifalin2016
Supporter
Forum|alt.badge.img+39
  • Author
  • Supporter
  • June 30, 2016

My usual (secret ;) trick is to use a BulkAttributeRenamer. This exposes the specified attribute name automatically.

Hi Takashi,

This doesn't work either.

Please note that I want to rename the attribute _inside_ the custom transformer, not outside.

Have either of you tried to run the workspace I attached with the changes ?

Cheers

 

Lars

takashi
Celebrity
  • June 30, 2016

Hi Takashi,

This doesn't work either.

Please note that I want to rename the attribute _inside_ the custom transformer, not outside.

Have either of you tried to run the workspace I attached with the changes ?

Cheers

 

Lars

please check this demo: test-rename-in-custom-transformer-2.fmw


david_r
Celebrity
  • June 30, 2016

Hi David,

No, that doesn't work, and I did try this before I posted.

I get the error: Undefined macro `NEW_NAME' dereferenced in file `C:\\Users\\lin\\Documents\\My FME Workspaces\\wb-xlate-1467288075556_12320'

Cheers

 

Lars

Worked perfectly when I tested it using FME 2016.1. The attribute gets renamed inside the custom transformer.

But I think Takashi's suggestion was even better than mine, so you might want to look at that first.


lifalin2016
Supporter
Forum|alt.badge.img+39
  • Author
  • Supporter
  • July 1, 2016

Hi Takashi,

That works !

Which is strange, because I did exactly what you described and did here, and it didn't work for me !?!

Ah well, my motto in these cases is: You shouldn't strive to understand why something doesn't work, just rejoyce when it does :-D

And so I shall. Thanks again.

Cheers

 

Lars

lifalin2016
Supporter
Forum|alt.badge.img+39
  • Author
  • Supporter
  • July 1, 2016

Hi Takashi,

That works !

Which is strange, because I did exactly what you described and did here, and it didn't work for me !?!

Ah well, my motto in these cases is: You shouldn't strive to understand why something doesn't work, just rejoyce when it does :-D

And so I shall. Thanks again.

Cheers

 

Lars

Ah, found my mistake. You used ".+", I entered ".*". Need stronger glasses :-)


takashi
Celebrity
  • July 1, 2016

Hi Takashi,

That works !

Which is strange, because I did exactly what you described and did here, and it didn't work for me !?!

Ah well, my motto in these cases is: You shouldn't strive to understand why something doesn't work, just rejoyce when it does :-D

And so I shall. Thanks again.

Cheers

 

Lars

Good to hear it works!

I also thought ".*" could work theoretically, but it doesn't work in fact. In my observation, available regex for the trick are:

  • .+
  • ^.+
  • .+$
  • ^.+$
  • ^.*
  • ^.*$

These two regex were unavailable:

  • .* (this will not rename the attribute)
  • .*$ (surprisingly, this will concatenate two specified string)

I don't know the reason why the last two expressions don't work...