Book a Demo

Author Topic: Transformation templates: variables  (Read 3031 times)

Orinoco

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Transformation templates: variables
« on: February 21, 2008, 01:00:18 pm »
I’m trying to pass a variable from one transform template to another.

My PIM package structure looks like this:
<<myRootPackage>>Foo(package)
--------------------------------------Bar(package)
-------------------------------------------Jan(package)
-------------------------------------------myClass1
-------------------------------------------myCass2

My goal in the transformation is to set the filename property of each of the classes to Foo.ext

In my Namespace template I tried:

%if packageStereotype == "myRootPackage"%
$filenameBase=%packageName% + ".ext"
%endIf%

This correctly sets that variable but I can’t then use it in my Class template to set the filename property there.
Maybe a user variable is not the best way to do this. Is there an appropriate “global” field/property I can set at the Namespace level, then access in Class?

Any thoughts much appreciated.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Transformation templates: variables
« Reply #1 on: February 21, 2008, 01:30:02 pm »
Are you trying to get all the classes to write to the same file?

If so you'll have to do some work. Search the forum for answers; there was something in the last week or so.

HTH, David
No, you can't have it!

Orinoco

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Transformation templates: variables
« Reply #2 on: February 21, 2008, 01:36:39 pm »
Thanks David

Yes, got that bit working (set filename property for each class and make sure "Synchronize model and code" is set)
I've even got it referencing a local path definition. Now I just want the file's name to be carried from the package I've stereotyped as <<myRootPackage>> two levels up.

Mark

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Transformation templates: variables
« Reply #3 on: February 21, 2008, 01:46:31 pm »
Tricky,

You might need an add-in to do this.

You should also check to make sure that each class isn't overwriting the one before.

David
No, you can't have it!