visibility rule ruleName(parameters) : returnType {
visibility rule parentRuleName::ruleName(parameters) : returnType {


Each parameter is of the form:

name : type




The rule statement defines the signature of a rule, as well as the contents to be evaluated.

The name of a rule must be unique within its ruleset: two rules defined in the same ruleset must have different names, regardless their parameters.

The rule may define expected parameters, used to compute the returned value. Any caller of the rule must provide matching arguments. A rule may return any type of object (or may not return anything). You can specify the return type in the rule signature.

The parameters declared by the ruleset are directly available in each rule. Thus, a parameter or a local variable of a rule must not collide with a ruleset parameter.


A rule may point at to a parent rule, in which case it means :

Using subrules may help to organize a ruleset into logical rule trees. The main point is to share parameters: subrules don't have to redefine parent rules parameters.


package com.mycompany.example;

// Expects a loaded UML 2.1 model as input
// The model is modified and may be saved once the evaluation is completed
public ruleset CreateUMLModel(inout model : uml21) {

    public rule main() {
        // loop on each Class of the UML 2.1 model
        foreach (class in model.getInstances("Class")) {
            @transformClass(class) {
    private rule transformClass(class : uml21.Class) {
        // loop on each feature of the class
        foreach (feature in class.feature)) {
            @transformFeature(feature) {
    // defines a subrule of transformClass
    private rule transformClass::transformFeature(feature : uml21.Feature) {
        // the transformClass 'class' parameter is available here
        System.out.println("Feature " + + " of class " +;

Related concepts