Example: Transform a Tree model to a Graph model with ETL

rule Tree2Node 
  transform t : Tree!Tree
  to n : Graph!Node {
  n.name = t.label;
  // If t is not the top tree
  // create an edge connecting n
  // with the Node created from t's parent
  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;

Clone Epsilon's Git repository and then:

Once you have checked out/imported the code, to run the example you need to go through the following steps:

  1. register all .ecore metamodels in the org.eclipse.epsilon.examples.metamodels project (select all of them and then right click and select Register EPackages)
  2. register any .ecore metamodels in the org.eclipse.epsilon.examples.tree2graph project
  3. right click the .launch file in the org.eclipse.epsilon.examples.tree2graph project
  4. select Run as... and click the first item in the menu that pops up

What's this?

In this example, we use ETL to transform a model that conforms to a Tree metamodel to a model that conforms to a Graph metamodel.

What are .emf files?

.emf files are Ecore metamodels expressed using the Emfatic textual syntax.

More examples...

Epsilon Object Language
Epsilon Transformation Language
Epsilon Generation Language
Epsilon Validation Language
Epsilon Merging Language
Epsilon Flock
Epsilon Model Generation Language
Epsilon Pattern Language
Combining the Epsilon Languages

Even more examples...

More examples are available in the examples folder of the Git repository.