Rule sets are used to define model transformations and to launch text generations. Rule sets are written in MQL (Model Query Language).
MQL has been designed with one primary goal: to allow the user to focus on the semantics of the model transformation instead of programmatic details. Here are some benefits:
MQL is also used as an expression language for text templates statements.
Here is an example of ruleset that generates a Java source file for each Class contained in a UML 2.1 model:
package com.mycompany.example;
// expects a loaded UML 2.1 model as input
public ruleset GenerateAllJavaClasses(in model : uml21) {
public rule generate() {
// loop on each Class of the UML 2.1 model
foreach (class in model.getInstances("Class")) {
// calls the text template GenerateJavaClass
$GenerateJavaClass(class);
}
}
}