SlideShare a Scribd company logo
L0082 - 2010-11-18
Redistribution and other use of this material requires written permission from The RCP Company.
ITU - MDD – Model-to-Model Transformations
This presentation describes the use Model-to-Model transformations (M2M). It
focus on the why, what and how.
This presentation is developed for MDD 2010 course at ITU, Denmark.
Some materials by Artur Boronat, University of Leicester (UK) and Emilio Insfrán,
TU Valencia (Spain) with permissions.
L0082 - 2010-11-18
2
What is Model-to-Model Transformations
 Two kinds of model transformation:
 Model-to-Text transformation (M2T)
 Model-to-Model transformation (M2M)
 A Model-to-Model transformation is the automated creation of m target models from n
source models
 Each model conforms to a given reference model (which can be the same for
several models)
M2MM2M
M2T
M2T
L0082 - 2010-11-18
3
Why use Model-to-Model Transformations
 Translation
 Refactoring
 Refinement
 Code Generation
 Specialization
 Migration
 Normalization
L0082 - 2010-11-18
4
Model-to-Model Transformations Principles
L0082 - 2010-11-18
5
M2
M1
relational schema (model)
class diagram metamodel specification (CD) relational metamodel specification (RDBS)
conforms to
conforms to
context ForeignKey
inv: self.owningTable.columns -> includesAll( self.columns)
context AssociationEnd
inv: not(self.opposite.oclIsUndefined) implies
(self.type=self.opposite.owningClass and
self.owningClass=self.opposite.type)
inv: (lower = 0 or lower = 1) and (upper = 1 or upper = -1)
class diagram model (cd)
Example of Model Transformation
M2
M1
L0082 - 2010-11-18
6
Example of Model Transformation
L0082 - 2010-11-18
7
Approaches for Model Transformations
 Model-to-model
 Model transformations are based on rules. These rules map constructs in the source model to
constructs in the target model
Meta-model A Meta-model B
Model A Model B
Transformation
Apply Transformation
conformsToconformsTo based onbased on
input output
L0082 - 2010-11-18
8
Some Terms
Endogeneous
Exogeneous
Horizontal
vertical
M2
M1
L0082 - 2010-11-18
9
- 9 -
Combining both approaches in an MDE process
Application on a concrete use case:
UML2 to Java
 An M2T solution
 A single transformation
performing at the same time:

Refactoring (e.g. delete of
multiple inheritance)

Mapping (UML2 concepts to
Java concepts)

Extraction to a concrete syntax
(conforming to the Java
grammar)
L0082 - 2010-11-18
10
- 10 -
Combining both approaches in an MDE process
Application on a concrete use case: UML2 to Java
 Same case using an M2M+M2T solution
L0082 - 2010-11-18
11
- 11 -
Combining both approaches in an MDE process
Application on a concrete use case: UML2 to Java
 Same case using an M2M+M2T solution + new refactoring
L0082 - 2010-11-18
12
- 12 -
Combining both approaches in an MDE process
Application on a concrete use case: UML2 to Java and C#
 Same case using an M2M+M2T solution + new mapping
L0082 - 2010-11-18
13
- 13 -
Combining both approaches in an MDE process
Application on a concrete use case: UML2 to Java
 Same case using an M2M+M2T solution + new extraction
L0082 - 2010-11-18
14
- 14 -
Combining both approaches in an MDE process
Advantages of such a generic M2M+M2T solution
 Modularity

Clearly separate the concerns (refactoring, mapping, extraction to a given
syntax, etc)
 Extensibility

Easily add new features (additional refactoring, different mapping, other
extraction to a textual or graphical syntax, etc)
 Reusability

Apply the same feature in different contexts (i.e., the same refactoring for
targeting different languages)
 Homogeneity

Handle mostly models (extraction is just the final step)
 Abstraction

Focus is set only on the concepts (abstract syntax) and not on their
various possible representations (concrete syntaxes)
L0082 - 2010-11-18
15
Important Success Factors for Model-to-Model Technologies
 Ease of use
 It is likely not going to be the primary tool of any developer
 Requirements on source and target models
 Form and format (text, XML, graph, …)
 Traceability
 Can you trace changes in the input to changes in the final results
 Very important for certain industries
 Reasoning about the transformation themselves
 Termination, Completeness, etc
L0082 - 2010-11-18
16
Several Types of Transformation Technologies
 Text based model
 Using sed, awk, perl, Snobol…
 Data often represented as a text files
 Tree based model
 Using XSLT
 Difficulties with models that’s are not pure trees
 Data often represented as simple XML files
 Graph based model
 Using QVT, ATL, XTend, …
 Data often represented as XMI files
L0082 - 2010-11-18
17
General Purpose Languages
 Java, VB, C# (take your favourite poison)
 Rules are implemented from scratch
 Depending on the form of the model you can have APIs to access the data
 Example: JMI or EMF (MOF-compliant Java Interfaces)
 No overhead to learn a new language
 The programming complexity problem continues
L0082 - 2010-11-18
18
Text Manipulation Tools
 Unix “pipe-line” tools
 sed, awk, perl, ….
 Special purpose programming languages
 Snobol
 Rules are typically based on regular expressions
L0082 - 2010-11-18
19
Extensible Stylesheet Language Transformation (XSLT)
 XML-based language used for the transformation of XML documents
 Part of a W3C family of languages (XSL)
 Describes how to format and transform XML files
 XSLT, XSL-FO, XPath
 Used to model transformation
 Where models are in XMI encoding format
L0082 - 2010-11-18
20
Extensible Stylesheet Language Transformation (XSLT)
 Metamodels are provided as XML schemas (XSD or DTD)
 Models are represented as XML documents
 XSLT Characteristics
 Declarative rather than imperative
 Consist of a template rules collection
 Each rule specifies what to add to a target fragment

Based on a source fragment and a fixed algorithm
 XSLT processor scan the source tree, apply rules and generate the target tree
 Syntactical & inefficient for model transformations

XML (XMI) is verbose

Operates on tree structures

More batch than interactive

Parameters passed by value
L0082 - 2010-11-18
21
XML
Document 1
XMLS
Document 1
Valid
XSLT
Document
XSLT
Engine
Source
Schema
Fragment
Matching
Patterns
XML
Document 2
XMLS
Document 2
Valid
Target
Schema
Fragment
Insertion Actions
Matched
Source Fragments
Extensible Stylesheet Language Transformation (XSLT)
 Transformation process:
 Source document matching patterns
 XSLT document specifying actions that copy matched elements and attributes
from source document and assemble them
 Target document matching transformations
L0082 - 2010-11-18
22
<model xmlns:uml="http://www.eclipse.org/uml2/1.0.0/UML" xmlns:xmi="http://www.omg.org/XMI">
<package id="pck1" name=“library">
<class id="c1" name="Book">
<association aggregationType="composite" id="c1_ass1" name="chapters" targetClass="c2"/>
<attribute id="c1_atr1" name="title" type="dt1"/>
</class>
<class id="c2" name="Chapter">
<attribute id="c2_atr1" name="nbPages" type="dt2"/>
<attribute id="c2_atr2" name="title" type="dt2"/>
<attribute id="c2_atr3" name="author" type="dt1"/>
<association aggregationType="none" id="c2_ass1" name="book"
targetClass="c1"/>
</class>
</package>
</model>
Extensible Stylesheet Language Transformation (XSLT)
L0082 - 2010-11-18
23
<model xmlns:uml="http://www.eclipse.org/uml2/1.0.0/UML" xmlns:xmi="http://www.omg.org/XMI">
<package id="pck1" name=“library">
<class id="c1" name="Publication">
<attribute id="c1_atr1" name="title" type="dt1"/>
<attribute id="c1_atr2" name="nbPages" type="dt2"/>
<attribute id="c1_atr3" name="authors" type="dt1"/>
</class>
<datatype id="dt1" name="String"/>
<datatype id="dt2" name="Integer"/>
</package>
</model>
Extensible Stylesheet Language Transformation (XSLT)
L0082 - 2010-11-18
24
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" />
<xsl:template match="library.Book" >
<xsl:variable name="title" select="@title" />
<xsl:variable name="authors" select="concat(@chapters.author, ',')"/>
<xsl:variable name="nbPages" select="sum(@chapters.nbPages)"/>
<xsl:call-template name="createPublication">
<xsl:with-param name="title" select="$title"/>
<xsl:with-param name="authors" select="$authors"/>
< xsl:with-param name="nbPages" select="$nbPages"/>
</xsl:call-template>
</xsl:template>
</xsl:transform>
Extensible Stylesheet Language Transformation (XSLT)
L0082 - 2010-11-18
25
Graph Transformations
L0082 - 2010-11-18
26
Graph Transformations
 Basic Operation:
 Match a set of nodes in the source graph
 Transform matched data
 Output nodes to the target graph
 Some basic problems
 Graphs are not directed acyclic graphs (DAGs) so there can be multiple
references to the same nodes
 How to you prevent the rules from matching the same data multiple times
 How to handle inheritance for nodes – especially the nodes in the target
model
L0082 - 2010-11-18
27
Book Chapter
nbPages : Integer
author : String
chapters
*
ElementWithTitle
title : String
RHSt : ElementWithTitle
LHS
The pattern matches all nodes of type ElementWithTitle,
considering the inheritance hierarchy
Type graph
Production rule
Inheritance
L0082 - 2010-11-18
28
Tree versus Graphs Transformations
 XSLT
 Operates on tree structures
 Data conversion
 XPath to traverse documents
 XML based commands: transformation
definitions tend to be quite verbose,
low level of detail
 Available in many platforms (libraries)
 Graph transformations
 Operates on graphs
 Models without containments
 Graph patterns
 Graphical approach: large patterns can
be difficult to draw
 Higher conceptual level: inheritance,
dangling edges, pattern matching
 Formal approach: reasoning about
termination and confluence, model
checking
L0082 - 2010-11-18
29
QVT
 QVT stands for Query/Views/Transformations
 OMG standard language for expressing queries, views, and transformations on
MOF models
 Three language: Core, Relational and Operational
 QVT is standards based language
 OMG QVT Request for Proposals (QVT RFP, ad/02-04-10) issued in 2002
 Seven initial submissions that converged to a common proposal
 Current status (June, 2006): final adopted specification, OMG document
ptc/05-11-01
 Automatic handling of traceability links
L0082 - 2010-11-18
30
Requirements for QVT Language
Some requirements formulated in the QVT RFP
Mandatory requirements
Query language Proposals shall define a language for querying models
Transformation language Proposals shall define a language for transformation definitions
Abstract syntax The abstract syntax of the QVT languages shall be described as MOF 2.0 metamodel
Paradigm The transformation definition language shall be declarative
Input and output All the mechanisms defined by proposals shall operate on models instances of MOF 2.0 metamodels
Optional requirements
Directionality Proposals may support transformation definitions that can be executed in two directions
Traceability Proposals may support traceability between source and target model elements
Reusability Proposals may support mechanisms for reuse of transformation definitions
Model update Proposals may support execution of transformations that update an existing model
L0082 - 2010-11-18
31
QVT – Relations and Core Languages
 Relations Language
 A declarative specification of the relationships between MOF models
 Supports complex object pattern matching, and implicitly creates trace
classes and their instances to record what occurred during a transformation
execution.
 Core Language
 A small model/language which only supports pattern matching over a flat set
of variables by evaluating conditions over those variables against a set of
models
 It is equally powerful to the Relations language, and because of its relative
simplicity, its semantics can be defined more simply, although transformation
descriptions are more verbose
L0082 - 2010-11-18
32
QVT Relations – When and Where Clauses
 when clause: conditions under which the
relationship needs to hold. The relation
ClassToTable needs to hold only when the
PackageToSchema relation holds between
the package containing the class and the
schema containing the table.
 where clause: condition that must be
satisfied by all model elements
participating in the relation, and it may
constrain any of the variables in the
relation and its domains.
 when and where clauses may contain also
any arbitrary OCL expressions
relation ClassToTable
/* map each persistent class to a table */
{
domain uml c:Class {
namespace = p:Package {},
kind='Persistent',
name=cn
}
domain rdbms t:Table {
schema = s:Schema {},
name=cn,
column = cl:Column {
name=cn+'_tid',
type='NUMBER'},
primaryKey = k:PrimaryKey {
name=cn+'_pk',
column=cl}
}
when {
PackageToSchema(p, s);
}
where {
AttributeToColumn(c, t);
}
}
L0082 - 2010-11-18
33
Operational QVT
 Operational == Procedural
 Uses OCL as procedural language
 Needed when there are big differences between the input and output models
 Very difficult to map multiple source nodes to multiple target nodes in
Declarative languages
 Likewise difficult to handle shared nodes
L0082 - 2010-11-18
34
Operational QVT Example
 Flattening UML class hierarchies: given a
source UML model transform it to another
UML model in which only the leaf classes
(classes not extended by other classes) in
inheritance hierarchies are kept.
 Rules:
 Transform only the leaf classes in the
source model
 Include the inherited attributes and
associations
 Attributes with the same name override
the inherited attributes
 Copy the primitive types
L0082 - 2010-11-18
35
Operational QVT Example: Input Model
L0082 - 2010-11-18
36
Operational QVT Example: Expected Output Model
L0082 - 2010-11-18
37
Operational QVT Example: Expected Output Model
transformation SimpleUML2FlattenSimpleUML(in source : SimpleUML, out target : SimpleUML);
main() { source.objectsOfType(Class)->map leafClass2Class(source); }
mapping Class::leafClass2Class(in model : Model) : Class
when {not model.allInstances(Generalization)->exists(g | g.general = self)} {
name:= self.name;
abstract:= self.abstract;
attributes:= self.derivedAttributes()->map property2property(self)->asOrderedSet();
}
mapping Property::property2property(in ownerClass : Class) : Property {
name:= self.name;
type:= self.type;
owner:= ownerClass;
}
query Class::derivedAttributes() : OrderedSet(Property){
if self.generalizations->isEmpty() then self.attributes
else
self.attributes->union(
self.generalizations->collect(g |
g.general.derivedAttributes()->select(attr |
not self.attributes->exists(att | att.name = attr.name)
)
)->flatten()
)->asOrderedSet()
endif
}
L0082 - 2010-11-18
38
ATL – Atlas Transformation Language
 ATL is the ATLAS INRIA & LINA research group answer to the OMG MOF/QVT
 mix of declarative and imperative constructs
 expression language based on OCL 2.0
 supports queries, views and transformations
 described by a MOF metamodel and a textual concrete syntax
 ATL transformations:
 are defined via the
corresponding
MOF based metamodels
 are not bidirectional
 ATL has become a reference
language for model
transformations and it is now
part of the Eclipse Modeling Project
MetamodelA MetamodelB
ModelA ModelB
MOF
ATL
defines
M1
M0
M2 ATL Transformation
Model Transformation
conforms to
conforms to
L0082 - 2010-11-18
39
ATL Example
 Assume we want to translate data from a hierarchical model (Family) to a flat
model (Person)
L0082 - 2010-11-18
40
ATL Example
L0082 - 2010-11-18
41
ATL Example
module Families2Persons;
-- @path Families=/Families2Persons/Families.ecore
-- @path Persons=/Families2Persons/Persons.ecore
create OUT: Persons from IN: Families;
rule Member2Male {
from
s: Families!Member (not s.isFemale())
to
t: Persons!Male (
fullName <- s.firstName + ' ' + s.familyName
)
}
rule Member2Female {
from
s: Families!Member (s.isFemale())
to
t: Persons!Female (
fullName <- s.firstName + ' ' + s.familyName
)
}
L0082 - 2010-11-18
42
ATL Example
helper context Families!Member def: isFemale(): Boolean =
if not self.familyMother.oclIsUndefined() then
true
else
if not self.familyDaughter.oclIsUndefined() then
true
else
false
endif
endif;
helper context Families!Member def: familyName: String =
if not self.familyFather.oclIsUndefined() then
self.familyFather.lastName
else
if not self.familyMother.oclIsUndefined() then
self.familyMother.lastName
else
if not self.familySon.oclIsUndefined() then
self.familySon.lastName
else
self.familyDaughter.lastName
endif
endif
endif;
L0082 - 2010-11-18
43
More Information
 “QVT Repository”
 http://www.toodoc.com/qvt-pdf.html

Repository with many QVT documents
 “MOF QVT Final Adopted Specification”
 http://www.omg.org/docs/ptc/05-11-01.pdf

You usual very hard to read OMG model

More Related Content

PDF
XML Schema Computations: Schema Compatibility Testing and Subschema Extraction
PPT
03 x files
PPT
Oodbms ch 20
PPT
ITU - MDD – Modeling Techniques
PDF
XML-talk
PPT
9. Object Relational Databases in DBMS
PDF
Chapt 1 odbms
PPT
Overview of Object-Oriented Concepts Characteristics by vikas jagtap
XML Schema Computations: Schema Compatibility Testing and Subschema Extraction
03 x files
Oodbms ch 20
ITU - MDD – Modeling Techniques
XML-talk
9. Object Relational Databases in DBMS
Chapt 1 odbms
Overview of Object-Oriented Concepts Characteristics by vikas jagtap

What's hot (20)

PPTX
XML - Data Modeling
PPTX
Xml schema
DOCX
Object relationship mapping and hibernate
PDF
COQUEL: A CONCEPTUAL QUERY LANGUAGE BASED ON THE ENTITYRELATIONSHIP MODEL
PPTX
Islamic University Previous Year Question Solution 2018 (ADBMS)
PPS
Xml session08
PDF
Model versioning in context of living
PPTX
XML Schemas
PPT
Xml schema
PPT
SQL Queries
PPS
03 sm3 xml_xp_05
PPTX
Database Design and Normalization Techniques
PPS
04 sm3 xml_xp_07
PPT
02 xml schema
PPT
Cs583 information-integration
PPS
03 sm3 xml_xp_06
PPTX
XML Schema
PPT
Automated Syntactic Mediation for Web Service Integration
PDF
Xml document probabilistic
XML - Data Modeling
Xml schema
Object relationship mapping and hibernate
COQUEL: A CONCEPTUAL QUERY LANGUAGE BASED ON THE ENTITYRELATIONSHIP MODEL
Islamic University Previous Year Question Solution 2018 (ADBMS)
Xml session08
Model versioning in context of living
XML Schemas
Xml schema
SQL Queries
03 sm3 xml_xp_05
Database Design and Normalization Techniques
04 sm3 xml_xp_07
02 xml schema
Cs583 information-integration
03 sm3 xml_xp_06
XML Schema
Automated Syntactic Mediation for Web Service Integration
Xml document probabilistic
Ad

Viewers also liked (13)

PDF
End-to-end Model-driven Development of Applications with Eclipse using the ...
PPTX
The visual history of A
PPTX
Back of the Napkin / Blah-Blah-Blah Seminar
PPTX
The Fry and the Cranberry
PDF
ATL tutorial - EclipseCon 2009
PDF
Draw to Win: Why drawing is your secret sales weapon
PDF
Getting Started With Sketchnoting
PDF
A is for iCar
PDF
Visual Note Taking / Sketchnotes
PDF
Practical Sketchnoting
PDF
Sketchnote Mini-Workshop: DSGNDAY 2014
PDF
7 tips to create visual presentations
PDF
Visual Note-Taking 101: Sketchnoting Techniques
End-to-end Model-driven Development of Applications with Eclipse using the ...
The visual history of A
Back of the Napkin / Blah-Blah-Blah Seminar
The Fry and the Cranberry
ATL tutorial - EclipseCon 2009
Draw to Win: Why drawing is your secret sales weapon
Getting Started With Sketchnoting
A is for iCar
Visual Note Taking / Sketchnotes
Practical Sketchnoting
Sketchnote Mini-Workshop: DSGNDAY 2014
7 tips to create visual presentations
Visual Note-Taking 101: Sketchnoting Techniques
Ad

Similar to ITU - MDD – Model-to-Model Transformations (20)

PPTX
Generic and Meta-Transformations for Model Transformation Engineering
PPTX
Web data management
PDF
What is diazo
PDF
Impact 2014 - IIB - selecting the right transformation option
PPTX
UML 2.5: Specification Simplification
PDF
Model Transformation Reuse
PDF
RepreZen DSL: Pushing the limits of language usability with XText
PDF
RAPID - Building a highly usable API Design language with XText
PPT
Web services Overview in depth
PDF
Approaches to Model Transformation Reuse: from Concepts to A-posteriori typing
PDF
The Lumber Mill Xslt For Your Templates
PPSX
MDE in Practice
PDF
xml test
PDF
test slideshare
PDF
Enriching Tool Support for Model-Driven Software Development
PPTX
Xml data transformation
PPT
ITU - MDD - XText
PPT
ERP_Up_Down.ppt
PDF
26xslt
PDF
On the Customization of Model Management Systems for File-Centric IDEs
Generic and Meta-Transformations for Model Transformation Engineering
Web data management
What is diazo
Impact 2014 - IIB - selecting the right transformation option
UML 2.5: Specification Simplification
Model Transformation Reuse
RepreZen DSL: Pushing the limits of language usability with XText
RAPID - Building a highly usable API Design language with XText
Web services Overview in depth
Approaches to Model Transformation Reuse: from Concepts to A-posteriori typing
The Lumber Mill Xslt For Your Templates
MDE in Practice
xml test
test slideshare
Enriching Tool Support for Model-Driven Software Development
Xml data transformation
ITU - MDD - XText
ERP_Up_Down.ppt
26xslt
On the Customization of Model Management Systems for File-Centric IDEs

More from Tonny Madsen (20)

KEY
L0043 - Interfacing to Eclipse Standard Views
PPT
L0037 - Basic Eclipse Configuration
KEY
L0036 - Creating Views and Editors
KEY
L0033 - JFace
KEY
L0020 - The Basic RCP Application
KEY
L0018 - SWT - The Standard Widget Toolkit
KEY
L0016 - The Structure of an Eclipse Plug-in
KEY
L0001 - The Terminology of the Eclipse Platform
KEY
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
KEY
PROSA - Eclipse Is Just What?
PPT
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
PPT
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
PPT
IDA - Eclipse Workshop II (In Danish)
PPT
IDA - Eclipse Workshop I (In Danish)
PPT
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
PPT
ITU - MDD - EMF
PPT
ITU - MDD - Eclipse Plug-ins
PPT
eclipse.dk - Eclipse RCP Under the Hood
PPT
EclipseCon '08 - BoF - Building a local Eclipse user group
PPT
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...
L0043 - Interfacing to Eclipse Standard Views
L0037 - Basic Eclipse Configuration
L0036 - Creating Views and Editors
L0033 - JFace
L0020 - The Basic RCP Application
L0018 - SWT - The Standard Widget Toolkit
L0016 - The Structure of an Eclipse Plug-in
L0001 - The Terminology of the Eclipse Platform
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
PROSA - Eclipse Is Just What?
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop I (In Danish)
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
ITU - MDD - EMF
ITU - MDD - Eclipse Plug-ins
eclipse.dk - Eclipse RCP Under the Hood
EclipseCon '08 - BoF - Building a local Eclipse user group
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...

Recently uploaded (20)

PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Cell Structure & Organelles in detailed.
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
RMMM.pdf make it easy to upload and study
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Complications of Minimal Access Surgery at WLH
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Institutional Correction lecture only . . .
PPTX
Cell Types and Its function , kingdom of life
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
Abdominal Access Techniques with Prof. Dr. R K Mishra
Cell Structure & Organelles in detailed.
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
RMMM.pdf make it easy to upload and study
Pharmacology of Heart Failure /Pharmacotherapy of CHF
102 student loan defaulters named and shamed – Is someone you know on the list?
Complications of Minimal Access Surgery at WLH
human mycosis Human fungal infections are called human mycosis..pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Microbial disease of the cardiovascular and lymphatic systems
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Week 4 Term 3 Study Techniques revisited.pptx
Final Presentation General Medicine 03-08-2024.pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPH.pptx obstetrics and gynecology in nursing
Institutional Correction lecture only . . .
Cell Types and Its function , kingdom of life
Module 4: Burden of Disease Tutorial Slides S2 2025

ITU - MDD – Model-to-Model Transformations

  • 1. L0082 - 2010-11-18 Redistribution and other use of this material requires written permission from The RCP Company. ITU - MDD – Model-to-Model Transformations This presentation describes the use Model-to-Model transformations (M2M). It focus on the why, what and how. This presentation is developed for MDD 2010 course at ITU, Denmark. Some materials by Artur Boronat, University of Leicester (UK) and Emilio Insfrán, TU Valencia (Spain) with permissions.
  • 2. L0082 - 2010-11-18 2 What is Model-to-Model Transformations  Two kinds of model transformation:  Model-to-Text transformation (M2T)  Model-to-Model transformation (M2M)  A Model-to-Model transformation is the automated creation of m target models from n source models  Each model conforms to a given reference model (which can be the same for several models) M2MM2M M2T M2T
  • 3. L0082 - 2010-11-18 3 Why use Model-to-Model Transformations  Translation  Refactoring  Refinement  Code Generation  Specialization  Migration  Normalization
  • 4. L0082 - 2010-11-18 4 Model-to-Model Transformations Principles
  • 5. L0082 - 2010-11-18 5 M2 M1 relational schema (model) class diagram metamodel specification (CD) relational metamodel specification (RDBS) conforms to conforms to context ForeignKey inv: self.owningTable.columns -> includesAll( self.columns) context AssociationEnd inv: not(self.opposite.oclIsUndefined) implies (self.type=self.opposite.owningClass and self.owningClass=self.opposite.type) inv: (lower = 0 or lower = 1) and (upper = 1 or upper = -1) class diagram model (cd) Example of Model Transformation M2 M1
  • 6. L0082 - 2010-11-18 6 Example of Model Transformation
  • 7. L0082 - 2010-11-18 7 Approaches for Model Transformations  Model-to-model  Model transformations are based on rules. These rules map constructs in the source model to constructs in the target model Meta-model A Meta-model B Model A Model B Transformation Apply Transformation conformsToconformsTo based onbased on input output
  • 8. L0082 - 2010-11-18 8 Some Terms Endogeneous Exogeneous Horizontal vertical M2 M1
  • 9. L0082 - 2010-11-18 9 - 9 - Combining both approaches in an MDE process Application on a concrete use case: UML2 to Java  An M2T solution  A single transformation performing at the same time:  Refactoring (e.g. delete of multiple inheritance)  Mapping (UML2 concepts to Java concepts)  Extraction to a concrete syntax (conforming to the Java grammar)
  • 10. L0082 - 2010-11-18 10 - 10 - Combining both approaches in an MDE process Application on a concrete use case: UML2 to Java  Same case using an M2M+M2T solution
  • 11. L0082 - 2010-11-18 11 - 11 - Combining both approaches in an MDE process Application on a concrete use case: UML2 to Java  Same case using an M2M+M2T solution + new refactoring
  • 12. L0082 - 2010-11-18 12 - 12 - Combining both approaches in an MDE process Application on a concrete use case: UML2 to Java and C#  Same case using an M2M+M2T solution + new mapping
  • 13. L0082 - 2010-11-18 13 - 13 - Combining both approaches in an MDE process Application on a concrete use case: UML2 to Java  Same case using an M2M+M2T solution + new extraction
  • 14. L0082 - 2010-11-18 14 - 14 - Combining both approaches in an MDE process Advantages of such a generic M2M+M2T solution  Modularity  Clearly separate the concerns (refactoring, mapping, extraction to a given syntax, etc)  Extensibility  Easily add new features (additional refactoring, different mapping, other extraction to a textual or graphical syntax, etc)  Reusability  Apply the same feature in different contexts (i.e., the same refactoring for targeting different languages)  Homogeneity  Handle mostly models (extraction is just the final step)  Abstraction  Focus is set only on the concepts (abstract syntax) and not on their various possible representations (concrete syntaxes)
  • 15. L0082 - 2010-11-18 15 Important Success Factors for Model-to-Model Technologies  Ease of use  It is likely not going to be the primary tool of any developer  Requirements on source and target models  Form and format (text, XML, graph, …)  Traceability  Can you trace changes in the input to changes in the final results  Very important for certain industries  Reasoning about the transformation themselves  Termination, Completeness, etc
  • 16. L0082 - 2010-11-18 16 Several Types of Transformation Technologies  Text based model  Using sed, awk, perl, Snobol…  Data often represented as a text files  Tree based model  Using XSLT  Difficulties with models that’s are not pure trees  Data often represented as simple XML files  Graph based model  Using QVT, ATL, XTend, …  Data often represented as XMI files
  • 17. L0082 - 2010-11-18 17 General Purpose Languages  Java, VB, C# (take your favourite poison)  Rules are implemented from scratch  Depending on the form of the model you can have APIs to access the data  Example: JMI or EMF (MOF-compliant Java Interfaces)  No overhead to learn a new language  The programming complexity problem continues
  • 18. L0082 - 2010-11-18 18 Text Manipulation Tools  Unix “pipe-line” tools  sed, awk, perl, ….  Special purpose programming languages  Snobol  Rules are typically based on regular expressions
  • 19. L0082 - 2010-11-18 19 Extensible Stylesheet Language Transformation (XSLT)  XML-based language used for the transformation of XML documents  Part of a W3C family of languages (XSL)  Describes how to format and transform XML files  XSLT, XSL-FO, XPath  Used to model transformation  Where models are in XMI encoding format
  • 20. L0082 - 2010-11-18 20 Extensible Stylesheet Language Transformation (XSLT)  Metamodels are provided as XML schemas (XSD or DTD)  Models are represented as XML documents  XSLT Characteristics  Declarative rather than imperative  Consist of a template rules collection  Each rule specifies what to add to a target fragment  Based on a source fragment and a fixed algorithm  XSLT processor scan the source tree, apply rules and generate the target tree  Syntactical & inefficient for model transformations  XML (XMI) is verbose  Operates on tree structures  More batch than interactive  Parameters passed by value
  • 21. L0082 - 2010-11-18 21 XML Document 1 XMLS Document 1 Valid XSLT Document XSLT Engine Source Schema Fragment Matching Patterns XML Document 2 XMLS Document 2 Valid Target Schema Fragment Insertion Actions Matched Source Fragments Extensible Stylesheet Language Transformation (XSLT)  Transformation process:  Source document matching patterns  XSLT document specifying actions that copy matched elements and attributes from source document and assemble them  Target document matching transformations
  • 22. L0082 - 2010-11-18 22 <model xmlns:uml="http://www.eclipse.org/uml2/1.0.0/UML" xmlns:xmi="http://www.omg.org/XMI"> <package id="pck1" name=“library"> <class id="c1" name="Book"> <association aggregationType="composite" id="c1_ass1" name="chapters" targetClass="c2"/> <attribute id="c1_atr1" name="title" type="dt1"/> </class> <class id="c2" name="Chapter"> <attribute id="c2_atr1" name="nbPages" type="dt2"/> <attribute id="c2_atr2" name="title" type="dt2"/> <attribute id="c2_atr3" name="author" type="dt1"/> <association aggregationType="none" id="c2_ass1" name="book" targetClass="c1"/> </class> </package> </model> Extensible Stylesheet Language Transformation (XSLT)
  • 23. L0082 - 2010-11-18 23 <model xmlns:uml="http://www.eclipse.org/uml2/1.0.0/UML" xmlns:xmi="http://www.omg.org/XMI"> <package id="pck1" name=“library"> <class id="c1" name="Publication"> <attribute id="c1_atr1" name="title" type="dt1"/> <attribute id="c1_atr2" name="nbPages" type="dt2"/> <attribute id="c1_atr3" name="authors" type="dt1"/> </class> <datatype id="dt1" name="String"/> <datatype id="dt2" name="Integer"/> </package> </model> Extensible Stylesheet Language Transformation (XSLT)
  • 24. L0082 - 2010-11-18 24 <?xml version="1.0" encoding="UTF-8"?> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="xml" /> <xsl:template match="library.Book" > <xsl:variable name="title" select="@title" /> <xsl:variable name="authors" select="concat(@chapters.author, ',')"/> <xsl:variable name="nbPages" select="sum(@chapters.nbPages)"/> <xsl:call-template name="createPublication"> <xsl:with-param name="title" select="$title"/> <xsl:with-param name="authors" select="$authors"/> < xsl:with-param name="nbPages" select="$nbPages"/> </xsl:call-template> </xsl:template> </xsl:transform> Extensible Stylesheet Language Transformation (XSLT)
  • 25. L0082 - 2010-11-18 25 Graph Transformations
  • 26. L0082 - 2010-11-18 26 Graph Transformations  Basic Operation:  Match a set of nodes in the source graph  Transform matched data  Output nodes to the target graph  Some basic problems  Graphs are not directed acyclic graphs (DAGs) so there can be multiple references to the same nodes  How to you prevent the rules from matching the same data multiple times  How to handle inheritance for nodes – especially the nodes in the target model
  • 27. L0082 - 2010-11-18 27 Book Chapter nbPages : Integer author : String chapters * ElementWithTitle title : String RHSt : ElementWithTitle LHS The pattern matches all nodes of type ElementWithTitle, considering the inheritance hierarchy Type graph Production rule Inheritance
  • 28. L0082 - 2010-11-18 28 Tree versus Graphs Transformations  XSLT  Operates on tree structures  Data conversion  XPath to traverse documents  XML based commands: transformation definitions tend to be quite verbose, low level of detail  Available in many platforms (libraries)  Graph transformations  Operates on graphs  Models without containments  Graph patterns  Graphical approach: large patterns can be difficult to draw  Higher conceptual level: inheritance, dangling edges, pattern matching  Formal approach: reasoning about termination and confluence, model checking
  • 29. L0082 - 2010-11-18 29 QVT  QVT stands for Query/Views/Transformations  OMG standard language for expressing queries, views, and transformations on MOF models  Three language: Core, Relational and Operational  QVT is standards based language  OMG QVT Request for Proposals (QVT RFP, ad/02-04-10) issued in 2002  Seven initial submissions that converged to a common proposal  Current status (June, 2006): final adopted specification, OMG document ptc/05-11-01  Automatic handling of traceability links
  • 30. L0082 - 2010-11-18 30 Requirements for QVT Language Some requirements formulated in the QVT RFP Mandatory requirements Query language Proposals shall define a language for querying models Transformation language Proposals shall define a language for transformation definitions Abstract syntax The abstract syntax of the QVT languages shall be described as MOF 2.0 metamodel Paradigm The transformation definition language shall be declarative Input and output All the mechanisms defined by proposals shall operate on models instances of MOF 2.0 metamodels Optional requirements Directionality Proposals may support transformation definitions that can be executed in two directions Traceability Proposals may support traceability between source and target model elements Reusability Proposals may support mechanisms for reuse of transformation definitions Model update Proposals may support execution of transformations that update an existing model
  • 31. L0082 - 2010-11-18 31 QVT – Relations and Core Languages  Relations Language  A declarative specification of the relationships between MOF models  Supports complex object pattern matching, and implicitly creates trace classes and their instances to record what occurred during a transformation execution.  Core Language  A small model/language which only supports pattern matching over a flat set of variables by evaluating conditions over those variables against a set of models  It is equally powerful to the Relations language, and because of its relative simplicity, its semantics can be defined more simply, although transformation descriptions are more verbose
  • 32. L0082 - 2010-11-18 32 QVT Relations – When and Where Clauses  when clause: conditions under which the relationship needs to hold. The relation ClassToTable needs to hold only when the PackageToSchema relation holds between the package containing the class and the schema containing the table.  where clause: condition that must be satisfied by all model elements participating in the relation, and it may constrain any of the variables in the relation and its domains.  when and where clauses may contain also any arbitrary OCL expressions relation ClassToTable /* map each persistent class to a table */ { domain uml c:Class { namespace = p:Package {}, kind='Persistent', name=cn } domain rdbms t:Table { schema = s:Schema {}, name=cn, column = cl:Column { name=cn+'_tid', type='NUMBER'}, primaryKey = k:PrimaryKey { name=cn+'_pk', column=cl} } when { PackageToSchema(p, s); } where { AttributeToColumn(c, t); } }
  • 33. L0082 - 2010-11-18 33 Operational QVT  Operational == Procedural  Uses OCL as procedural language  Needed when there are big differences between the input and output models  Very difficult to map multiple source nodes to multiple target nodes in Declarative languages  Likewise difficult to handle shared nodes
  • 34. L0082 - 2010-11-18 34 Operational QVT Example  Flattening UML class hierarchies: given a source UML model transform it to another UML model in which only the leaf classes (classes not extended by other classes) in inheritance hierarchies are kept.  Rules:  Transform only the leaf classes in the source model  Include the inherited attributes and associations  Attributes with the same name override the inherited attributes  Copy the primitive types
  • 35. L0082 - 2010-11-18 35 Operational QVT Example: Input Model
  • 36. L0082 - 2010-11-18 36 Operational QVT Example: Expected Output Model
  • 37. L0082 - 2010-11-18 37 Operational QVT Example: Expected Output Model transformation SimpleUML2FlattenSimpleUML(in source : SimpleUML, out target : SimpleUML); main() { source.objectsOfType(Class)->map leafClass2Class(source); } mapping Class::leafClass2Class(in model : Model) : Class when {not model.allInstances(Generalization)->exists(g | g.general = self)} { name:= self.name; abstract:= self.abstract; attributes:= self.derivedAttributes()->map property2property(self)->asOrderedSet(); } mapping Property::property2property(in ownerClass : Class) : Property { name:= self.name; type:= self.type; owner:= ownerClass; } query Class::derivedAttributes() : OrderedSet(Property){ if self.generalizations->isEmpty() then self.attributes else self.attributes->union( self.generalizations->collect(g | g.general.derivedAttributes()->select(attr | not self.attributes->exists(att | att.name = attr.name) ) )->flatten() )->asOrderedSet() endif }
  • 38. L0082 - 2010-11-18 38 ATL – Atlas Transformation Language  ATL is the ATLAS INRIA & LINA research group answer to the OMG MOF/QVT  mix of declarative and imperative constructs  expression language based on OCL 2.0  supports queries, views and transformations  described by a MOF metamodel and a textual concrete syntax  ATL transformations:  are defined via the corresponding MOF based metamodels  are not bidirectional  ATL has become a reference language for model transformations and it is now part of the Eclipse Modeling Project MetamodelA MetamodelB ModelA ModelB MOF ATL defines M1 M0 M2 ATL Transformation Model Transformation conforms to conforms to
  • 39. L0082 - 2010-11-18 39 ATL Example  Assume we want to translate data from a hierarchical model (Family) to a flat model (Person)
  • 41. L0082 - 2010-11-18 41 ATL Example module Families2Persons; -- @path Families=/Families2Persons/Families.ecore -- @path Persons=/Families2Persons/Persons.ecore create OUT: Persons from IN: Families; rule Member2Male { from s: Families!Member (not s.isFemale()) to t: Persons!Male ( fullName <- s.firstName + ' ' + s.familyName ) } rule Member2Female { from s: Families!Member (s.isFemale()) to t: Persons!Female ( fullName <- s.firstName + ' ' + s.familyName ) }
  • 42. L0082 - 2010-11-18 42 ATL Example helper context Families!Member def: isFemale(): Boolean = if not self.familyMother.oclIsUndefined() then true else if not self.familyDaughter.oclIsUndefined() then true else false endif endif; helper context Families!Member def: familyName: String = if not self.familyFather.oclIsUndefined() then self.familyFather.lastName else if not self.familyMother.oclIsUndefined() then self.familyMother.lastName else if not self.familySon.oclIsUndefined() then self.familySon.lastName else self.familyDaughter.lastName endif endif endif;
  • 43. L0082 - 2010-11-18 43 More Information  “QVT Repository”  http://www.toodoc.com/qvt-pdf.html  Repository with many QVT documents  “MOF QVT Final Adopted Specification”  http://www.omg.org/docs/ptc/05-11-01.pdf  You usual very hard to read OMG model