rule Tree2Node transform t : Tree!Tree to n : Graph!Node { n.name := t.label; if (t.parent.isDefined()) { var e : new Graph!Edge; e.source ::= t.parent; e.target := n; } }
@namespace(uri="Tree", prefix="Tree") package Tree; class Tree { val Tree[*]#parent children; ref Tree#children parent; attr String label; }
@namespace(uri="Graph", prefix="Graph") package Graph; class Graph { val Node[*] nodes; } class Node { attr String name; val Edge[*]#source outgoing; ref Edge[*]#target incoming; } class Edge { ref Node#outgoing source; ref Node#incoming target; }
There are two ways to get the code of this example:
Once you have checked out/imported the code, to run the example you need to go through the following steps:
In this example, we use the Epsilon Transformation Language to transform a model that conforms to the Tree.emf metamodel to a model that conforms to the Graph.emf metamodel.
.emf files are Ecore metamodels expressed using the Emfatic textual syntax.
More examples are available in the examples folder of the SVN repository.