Create a transformation ruleset

Transformation rules are defined in a ruleset.

To create a ruleset:

  1. Click File > New > Rule Set.
  2. Type com.sodius.mdw.samples.tutorial/src in the Source folder field.
  3. Type tutorial.uml2relational in the Package field.
  4. Type UML2Relational in the Name field.

  5. Click Finish.

A file UMLRelational.mqr is created in the folder com.sodius.mdw.samples.tutorial/src/tutorial/uml2relational and is opened in an editor.

package tutorial.uml2relational;

public ruleset UML2Relational() {

    public rule myRule() {
    }

}

The ruleset UML2Relational is defined in the package tutorial.uml2relational and contains an sample rule myRule.

We want to transform a UML model into a Relational model. This ruleset will take an input UML model, query its instances, and create new model elements in an output Relational model. So we need to add model parameters to the ruleset:

package tutorial.uml2relational;

public ruleset UML2Relational(in source : uml21, out target : relational) {

    public rule myRule() {
    }

}

Add the code "in source : uml21, out target : relational" and click File > Save.

uml21 and relational are the metamodel identifiers of the models to be used, while source and target are the parameter names. The direction in tells MDWorkbench the source UML model is an input and must be loaded (from an XMI file for example). The direction out tells MDWorkbench the target Relational model is an output and may be saved (into an XMI file for example).

Related concepts
Metamodel
Ruleset

Related reference
MQL (Model Query Language)
package