1. How can I launch a transformation task?

Transformations tasks are written within a Rakefile. There are several predefined tasks, such as the following:

model_to_model :class2java do |t|
  t.sources :package   => 'SimpleUML',
            :metamodel => 'metamodels/Simple_UML.ecore',
            :model     => 'models/classes.xmi'  

  t.targets :package   => 'Java',
            :metamodel => 'metamodels/Java.ecore',
            :model     => 'models/java.xmi'  

  t.transformation 'transformations/class2java-simple.rb'
end

There are two ways of launching the transformation task:

  • An Eclipse-launcher can be configured manually doing the following: click on Run -> Open Run Dialog....
  • The second way is selecting the transformation task name with the mouse, and doing right click to select the menu option Run as -> Run rakefile. This creates a new launcher automatically. This is the easiest way to launch a transformation task.

2. XMI parser crashes reading a model / metamodel.

Make sure that the nsPrefix and nsURI properties of each package of the metamodel are set (even when it crashes reading the model). Select the validate option to let Eclipse check the model for you.

In general, the XMI parser is able to read most of the models created by the Eclipse tree-editor.


3. Transformation finishes but I can open the generated model.

This is very likely related to the problem explained in the previous point: nsPrefix and nsURI need to be set in the metamodel.


4. I have the following error:

C:/ruby/lib/ruby/1.8/rexml/document.rb:186:in `write': 
undefined local variable or method `transitive' for <UNDEFINED> ... </>:REXML::Document (NameError)

This is because you are using an unstable version of Ruby (probably on Windows). Download an stable release, such as http://rubyforge.org/frs/download.php/18566/ruby186-25.exe.


5. The name of a package or metaclass is lowercase and there is an error when I try to access it in a transformation.

The problem appears because in Ruby each class, module or constant in general needs to start with an uppercase letter. The engine automatically renames the package/metaclass' name for it to have the first letter uppercase. For instance,

|------------------------------------------------------
| package / metaclass   | name in the transformation  |
-------------------------------------------------------
|     myMetaclass       |        MyMetaclass          |
|------------------------------------------------------
|     package           |         Package             |
|-----------------------------------------------------|
|     Attribute         |         Attribute           |                   
|-----------------------------------------------------|