Solved

Renaming attributes configuration in a custom transformer?


Userlevel 1
Badge +22

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
icon

Best answer by takashi 30 June 2016, 11:24

View original

11 replies

Userlevel 1
Badge +22
test-rename-in-custom-transformer.fmw
Userlevel 4

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.

Userlevel 2
Badge +17

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

Userlevel 4

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

Nice trick!

Userlevel 1
Badge +22

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
Userlevel 1
Badge +22

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
Userlevel 2
Badge +17

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

Userlevel 4

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.

Userlevel 1
Badge +22

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
Userlevel 1
Badge +22

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 :-)

Userlevel 2
Badge +17

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...

Reply