Example: MDD-TIF complete case study

<?xml version="1.0"?>
<project default="main">
  <epsilon.emf.register file="../metamodels/CompetitionDsl.ecore"/>
  <epsilon.emf.register file="../metamodels/TVAppDsl.ecore"/>
  <epsilon.emf.loadModel name="Competition"
                               read="true" store="false"/>
  <epsilon.emf.loadModel name="TVApp"
                               read="false" store="true"/>

  <target name="main">
    <epsilon.evl src="ValidateCompetition.evl">
      <model ref="Competition"/>
    <epsilon.etl src="Competition2TVApp.etl">
      <model ref="TVApp"/>
      <model ref="Competition"/>
rule Competition2Application
  transform c : Competition!Competition
  to a : TVApp!Application, v : TVApp!Vote {

  a.name = c.name + " Application";
  v.name = "Who will win the " + c.name + "?";  
  for (g in c.groups) {
    for (comp in g.competitors) {

rule Competitor2Choice
  transform co : Competition!Competitor
  to ch : TVApp!Choice {

  ch.name = co.name;

rule Group2Label
  transform g : Competition!Group
  to l : TVApp!Label {
  l.name = "Group " + g.name;
context Competition!NamedElement {
  constraint NameSpecified {
    check : self.name.isDefined() and self.name.trim().length > 0
    message : self.eClass().name + " must provide a name"

context Competition!Group {
  constraint NotEmpty {
    guard : self.satisfies("NameSpecified")
    check : self.competitors.size() > 0
    message : "Group " + self.name + " contains no competitors"

context Competition!Competitor {
  constraint InUniqueGroup {
    guard : self.satisfies("NameSpecified")
    check : Competition!Group.allInstances.
      select(g|g.competitors.includes(self)).size() <= 1
    message : "Competitor " + self.name + 
      " exists in more than one groups."

Clone Epsilon's Git repository:

  • navigate to examples
  • import the org.eclipse.epsilon.examples.mddtif project

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

  1. register any .ecore metamodels in the org.eclipse.epsilon.examples.mddtif project
  2. right click the .launch file in the org.eclipse.epsilon.examples.mddtif project
  3. select Run as... and click the first item in the menu that pops up

What's this?

In this example, we demonstrate how different languages in Epsilon (EVL, EGL, EML, ETL and ECL) can be combined to implement more complex operations.

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.