ATL The ATLAS Transformation Language. 2 ATL (ATLAS Transformation Language) ATL transformation pattern ATL metamodel Helpers – Operation helpers – Attribute.

Slides:



Advertisements
Similar presentations
Inside an XSLT Processor Michael Kay, ICL 19 May 2000.
Advertisements

Profiles Construction Eclipse ECESIS Project Construction of Complex UML Profiles UPM ETSI Telecomunicación Ciudad Universitaria s/n Madrid 28040,
Semantics Static semantics Dynamic semantics attribute grammars
June 9, 2006 Transforming models with ATL © 2006 ATLAS Nantes Transforming models with ATL The A TLAS Transformation Language Frédéric Jouault ATLAS.
ISO DSDL ISO – Document Schema Definition Languages (DSDL) Martin Bryan Convenor, JTC1/SC18 WG1.
Macro Processor.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
MP IP Strategy Stateye-GUI Provided by Edotronik Munich, May 05, 2006.
Families to Persons © 2007 ATLAS Nantes "Families to Persons" A simple illustration of model-to-model transformation Freddy Allilaire Frédéric Jouault.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
Whole Platform Tesi di Dottorato di: RICCARDO SOLMI Università degli Studi di Bologna Facoltà di scienze matematiche, fisiche e naturali Corso di Dottorato.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
© 2008 IBM Corporation Behavioral Models for Software Development Andrei Kirshin, Dolev Dotan, Alan Hartman January 2008.
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
XML files (with LINQ). Introduction to LINQ ( Language Integrated Query ) C#’s new LINQ capabilities allow you to write query expressions that retrieve.
CH07: Writing the Programs Does not teach you how to program, but point out some software engineering practices that you should should keep in mind as.
Advanced Applications Of Model-to-Model Transformation © 2008 INRIA Advanced Applications Of Model-to-Model Transformation Hugo Bruneliere & Frédéric.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
A First Program Using C#
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
An Approach and Tool for Synchronous Refactoring of UML Diagrams and Models Using Model-to-Model Transformations Hafsteinn Þór Einarsson Helmut Neukirchen.
2.2 A Simple Syntax-Directed Translator Syntax-Directed Translation 2.4 Parsing 2.5 A Translator for Simple Expressions 2.6 Lexical Analysis.
Imperative Programming
MDA and QVT  Tom Gullion, Director of Product Management, Together Products.
Introduction to MDA (Model Driven Architecture) CYT.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Tools for Diagrammatic Specifications Stian Skjerveggen Supervisors: Yngve Lamo, Adrian Rutle, Uwe Egbert Wolter.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
What is MOF? The Meta Object Facility (MOF) specification provides a set of CORBA interfaces that can be used to define and manipulate a set of interoperable.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Lesson 3 CDT301 – Compiler Theory, Spring 2011 Teacher: Linus Källberg.
FlexElink Winter presentation 26 February 2002 Flexible linking (and formatting) management software Hector Sanchez Universitat Jaume I Ing. Informatica.
Declaratively Producing Data Mash-ups Sudarshan Murthy 1, David Maier 2 1 Applied Research, Wipro Technologies 2 Department of Computer Science, Portland.
An ATL Example © 2005 ATLAS Nantes An ATL Example The BibTeXML to DocBook Transformation ATLAS group (INRIA & LINA), University of Nantes, France.
Visual Basic Programming
1 Innovative Solutions For Mission Critical Systems Using EMF Annotations to Drive Program Behavior February 19, 2014.
Chapter 10 Function Block Diagram
ModelPedia Model Driven Engineering Graphical User Interfaces for Web 2.0 Sites Centro de Informática – CIn/UFPe ORCAS Group Eclipse GMF Fábio M. Pereira.
Sheet 1 DocEng’03, Grenoble, November 2003 Model Driven Architecture based XML Processing Ivan Kurtev, Klaas van den Berg University of Twente, the Netherlands.
Python Functions.
1 Typing XQuery WANG Zhen (Selina) Something about the Internship Group Name: PROTHEO, Inria, France Research: Rewriting and strategies, Constraints,
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET.
ModTransf A Simple Model to Model Transformation Engine Cédric Dumoulin.
Oracle Data Integrator User Functions, Variables and Advanced Mappings
Introduction To Model-to-Model Transformation © 2008 INRIA Introduction To Model-to-Model Transformation Hugo Bruneliere & Frédéric Jouault INRIA.
XP 1 XSLT II Robin Burke ECT 360. XP 2 Outline Conditionals Numbering Functions and operators Variables and parameters Named and recursive templates.
Deriving Relation Keys from XML Keys by Qing Wang, Hongwei Wu, Jianchang Xiao, Aoying Zhou, Junmei Zhou Reviewed by Chris Ying Zhu, Cong Wang, Max Wang,
Based on material developed in ATHENA (IST ), INTEROP (IST ) and MODELWARE (IST ) 6-1b. Atlas Transformation Language (ATL) with RSM.
XP 1 XSLT II Robin Burke ECT 360. XP 2 Homework #4 Forgot we hadn't covered "choose" becomes extra credit My books.xml didn't include descriptions.
Hyperion Artifact Life Cycle Management Agenda  Overview  Demo  Tips & Tricks  Takeaways  Queries.
Ontologies Reasoning Components Agents Simulations An Overview of Model-Driven Engineering and Architecture Jacques Robin.
AUTOMATIC GENERATION OF MODEL TRAVERSALS FROM METAMODEL DEFINITIONS Authors: Tomaž Lukman, Marjan Mernik, Zekai Demirezen, Barrett Bryant, Jeff Gray ACM.
Generating ADL Descriptions ADL Module for Together 6.x Massimo Marino Lawrence Berkeley National Laboratory.
1 Budapest University of Technology and Economics Department of Measurement and Information Systems Budapest University of Technology and Economics Fault.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
LECTURE 10 Semantic Analysis. REVIEW So far, we’ve covered the following: Compilation methods: compilation vs. interpretation. The overall compilation.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Product Training Program
Business rules.
A Simple Syntax-Directed Translator
Towards Automatic Model Synchronization from Model Transformation
Lecture 15 (Notes by P. N. Hilfinger and R. Bodik)
SPL – PS1 Introduction to C++.
Software Architecture & Design
Presentation transcript:

ATL The ATLAS Transformation Language

2 ATL (ATLAS Transformation Language) ATL transformation pattern ATL metamodel Helpers – Operation helpers – Attribute helpers Transformation rules – Matched rules (Declarative rules) – Imperative features ATL tools – Execution engine – IDE

3 Model transformation By definition, a model transformation is the automatic creation of target models from source models. Model transformation is not only about M1 to M1 transformations: – M1 to M2: promotion, – M2 to M1: demotion, – M3 to M1, M3 to M2, etc.

4 ATL transformation pattern MOF MMa MMb Ma Mb MMa2MMb.atl ATL MMa is the source metamodel Ma is the source model Mb is the target model MMB is the target metamodel

5 ATL overview Unidirectional transformation Source models and target models are distinct. Source models cannot be modified, only navigated. Target models cannot be navigated. The language is a declarative-imperative hybrid: – There are imperative or called rules. – There are declarative or matched rules. An imperative/called rule is basically a procedure. A declarative/matched rule specifies: – a source pattern to be matched in the source models, – a target pattern to be created in the target model for each match.

6 ATL metamodel

7 ATL helpers The term helper comes from the OCL specification Can only be specified on an OCL type or a source type (coming from a source metamodel) Are specified in OCL Have a name, a context and a type Can be recursively defined

8 ATL helpers Operation helpers – Purpose : to perform navigation over source models – Can be used to specify operations in the context of a model element or a module – Can have input parameters Attribute helpers – Can be considered as a means to decorate source models before transformation execution – Are used to associate read-only named values to source model elements. – Cannot have input parameters, their values are specified by an OCL expression. – Can be associated to a transformation and are not always attached to a metamodel – Can be initialized in a pass performed before running the rest of the transformation but can also be lazily evaluated when the helper value is read for the first time x

9 ATL operation helper - example helper context XML!Element def: getChildren(type : OclType, name : String) : Sequence(XML!Node) = self.children->select(e | e.oclIsKindOf(type) )->select(e | e.name = name ); A simple XML metamodel type can be: XML!Element XML!Attribute XML!Text Calling this operation with getChildren(XML!Element,’interface’) gives a sequence containing interface elements

10 ATL attribute helper - example helper context SimpleClass!Class def : allAttributes : Sequence(SimpleClass!Attribute) = self.attrs->union( if not self.parent.oclIsUndefined() then self.parent.allAttributes->select(attr | not self.attrs->exists(at | at.name = attr.name) ) else Sequence {} endif )->flatten(); SimpleClass metamodel allAttributes is recursively called

11 Matched rules (declarative rules) Source pattern The source pattern is composed of: – Source types coming from the source metamodels, – A guard (Boolean expression in OCL) used to filter matches. A source pattern is evaluated to a set of matches in source models A match corresponds to a set of elements coming from the source models that: – Are of the types specified in the source pattern (one element for each type), – Verify the guard.

12 Matched rules Target pattern The target pattern is composed of: – A set of target types coming from the target metamodels – For each element of this set, a set of bindings (identified by the symbol <-). – A binding specifies the initialization of a feature of a target element using an expression whose value is used to initialize the feature. For each match, the target pattern is applied: – Elements are created in the target models (one for each type of the target pattern), – Target elements are initialized by executing the bindings: First evaluating their value, Then assigning this value to the corresponding property.

13 Types of matched rules There exist three types of matched rules : – Standard rules are applied once for every match that can be found in source models – Lazy rules are triggered by other rules. They are applied on a match as many times as it is referred to by other rules. A lazy rule may be applied multiple times on a single match, each time producing a new set of target elements – Unique lazy rules are also triggered by other rules. They are applied only once for a given match. If a unique lazy rule is triggered later on the same match the already created target elements are used

14 Matched standard rules - example rule PersistentClass2Table{ from c : SimpleClass!Class ( c.is_persistent and c.parent.oclIsUndefined() ) to t : SimpleRDBMS!Table ( name <- c.name ) } Source pattern Target pattern

15 Matched lazy rules - example lazy rule R1 { from s : Element to t : Element ( value <- [R2.t]s ) }

16 Matched uniquely lazy rules - example unique lazy rule Feature2Column { from trace : Sequence(OclAny) to col : SimpleRDBMS!Column ( name iterate(e; acc : String = '' | acc + if acc = '' then '' else '_' endif + f.name), type last().type ) }

17 Execution order The order in which rules are matched and applied is not specified The order in which bindings are applied is not specified The execution of declarative rules can however be kept deterministic: – The execution of a rule cannot change source models: it cannot change the set of matches – Target elements are not navigable: the execution of a binding cannot change the value of another

18 Execution order Lazy rules may lead to executions that do not terminate – Transformations run in a cycle – Recursive references are present lazy rule R1 { from s : Element to t : Element ( value <- [R2.t]s ) } lazy rule R2 { from s : Element to t : Element ( value <- [R1.t]s ) }

19 Called rules (imperative rules) Are basically a procedure Are invoked by its name and may take arguments. Its implementation can be native or specified in ATL (e.g. as a target pattern without source pattern since no match is needed). Can lead to executions that do not terminate due to their imperative nature Called rules and action block helper def: id : Integer = 0; rule getId() { -- : Integer do { thisModule.id <- thisModule.id + 1; -- increment id thisModule.id; -- returns id } Hybrid rules (matched rule with action block) rule Test { from s : S!Test to t : T!Test do { t.id <- thisModule.getId(); }

20 ATL classification

21 ATL summary

22 Implementation of ATL The ATL execution engine is based on a Virtual Machine (VM). The VM executes bytecode. There is a compiler from ATL code to bytecode. The Virtual Machine can handle models that are: – Stored in Eclipse EMF, – Or stored in Netbeans MDR.

23 ATL engine algorithm - executing rules -- START OF ALGORITHM: execute called rule marked as entrypoint -- This results in a traditional imperative control flow. -- Match standard matched rules: ForEach standard rule R { ForEach candidate pattern C of R { -- a candidate pattern is a set of elements matching the -- types of the source pattern of a rule evaluate the guard of R on C If guard is true Then create target elements in target pattern of R create TraceLink for R, C, and target elements Else discard C EndIf } -- Apply standard matched rules: ForEach TraceLink T { R = the rule associated to T C = the matched source pattern of T P = the created target pattern of T -- Initialize elements in the target pattern: ForEach target element E of P { -- Initialize each feature of E: ForEach binding B declared for E { expression = initialization expression of B value = evaluate expression in the context of C featureValue = resolve value set featureValue to corresponding feature of B } execute action block of R in the context of C and T -- imperative blocks can perform any navigation in C or T and -- any action on T -- it is the programmer's responsibility to perform valid -- operations } execute called rule marked as endpoint -- We have again an imperative control flow. -- END OF ALGORITHM This algorithm does not suppose an order in  Rule matching  Creation of target elements for a match  Initialization of target elements for a TraceLink  Initialization of target element’s features. Action block (if present) must, however, be executed after having applied the declarative part of the rule. The imperative parts of the algorithm are not completely supported yet.

24 The ATL Virtual Machine Architecture ATL Virtual Machine EMF (Eclipse Modeling Framework) MDR (Netbeans MetaData Repository) Etc. ATL Compiler ATL programs

25 ATL Development Tools: perspective, editor and outline

26 ATL Development Tools: launch configuration

27 ATL Development Tools: source-level debugger

Book to Publication transformation

29 Book to Publication transformation Metamodel Book – Contains an ordered set of Chapters. – Chapters hold the information of the number of pages of Chapters, the authors. The metamodel Publication – Contains a class Publication with a title and the total number of pages. Transformation requirements – All chapters of a Book have to be visited to calculate the sum of all pages authors of all chapters

30 Book to Publication transformation CD of a Book metamodelCD of a Publication metamodel CD = Class Diagram +title : String +nbPages : Integer +author : String Chapter +title : String Book *+chapters {ordered} +book +title : String +nbPages : Integer +author : String Publication

31 A Book metamodel in KM3 package Book { class Book { attribute title : String; reference chapters[*] ordered container : Chapter oppositeOf book } class Chapter { attribute title : String; attribute nbPages : Integer; attribute author : String; reference book : Book oppositeOf chapters; } package PrimitiveTypes { datatype Integer; datatype String; datatype Boolean; } The Book.km3 file

32 A Publication metamodel in KM3 package Publication { class Publication { attribute title: String; attribute authors: String; attribute nbPages: Integer; } package PrimitiveTypes { datatype Integer; datatype String; datatype Boolean; } To obtain both metamodels in XMI format (.ecore extension in the ATL environment) they must be injected using the injector - KM3 file to KM3 Ecore metamodel The Publication.km3 file

33 A Book2Publication transformation module Book2Publication; create OUT : Publication from IN : Book; rule Book2Publication { from b : Book!Book ( b.getSumPages() > 2 -- only Books with more than 2 pages are publications ) to out : Publication!Publication ( title <- b.title, authors <- b.getAuthors(), nbPages <- b.getSumPages() ) } +title : String +nbPages : Integer +author : String Chapter +title : String Book *+chapters {ordered} +book +title : String +nbPages : Integer +author : String Publication The Book2Publication.atl file 1/3

34 A Book2Publication transformation -- getSumPages does the same as getNbPages, -- but it uses the OCL sum operation helper context Book!Book def : getSumPages() : Integer = self.chapters->collect(f | f.nbPages).sum() ; -- getNbPages collects all nbPages of all chapters -- and calculates the sum helper context Book!Book def : getNbPages() : Integer = self.chapters->collect(f | f.nbPages)-> iterate(pages; acc : Integer = 0 | acc + pages) ; +title : String +nbPages : Integer +author : String Chapter +title : String Book *+chapters {ordered} +book The Book2Publication.atl file 2/3

35 A Book2Publication transformation -- getAuthors collects all Autors of a Book -- the asSet operation removes all duplicates helper context Book!Book def : getAuthors() : String = self.chapters->collect(e | e.author)->asSet()-> iterate(authorName; acc : String = '' | acc + if acc = '' then authorName else ' and ' + authorName endif) ; +title : String +nbPages : Integer +author : String Chapter +title : String Book *+chapters {ordered} +book The Book2Publication.atl file 3/3

36 Global view Until here, we have : – The Book and Publication metamodels – The Book2Publication transformation

37 Global view M1 M2 M3 KM3 grammar EBNFME/EMF ANTLREcore ATL grammar ATL metamodel Book2Publ.atl Book2Publ model ATL file to ATL model Public.km3 Book metamdel Book.km3 A KM3 file to KM3 Ecore metamodel Public metamodel

38 Global view Now, we need to wonder how to define the source model. For this there exist several solutions, for instance 1. To write an XMI document. ATL transformations use as input XMI documents and generate as output XMI documents. That means that models in ATL are materialized as XMI documents. 2. To write an XML document, inject it using the XML file to XML model (Ecore) and to make a very simple transformation XML to Book. The second solution is used frequently in the ATL world. We adopt this solution in the rest of this example.

39 Global view – XML as input and XML2Book transformation M1 M2 M3 XML schema An XML schema XML metamodel inputMod.xml inputMod- XML.ecore XML file to XML model (Ecore) XMLME/EMF ATL metamodel XML2Book model EcoreANTLR ATL grammar XML2Book.atl EBNF ATL file to ATL model It is generated automatically when an.atl file is saved

40 The input example in XML +title : String +nbPages : Integer +author : String Chapter +title : String Book *+chapters {ordered} +book Book metamodel XML metamodel The inputModelXML.xml file

41 A XML metamodel in KM3 package XML { abstract class Node { attribute startLine[0-1] : Integer; attribute startColumn[0-1] : Integer; attribute endLine[0-1] : Integer; attribute endColumn[0-1] : Integer; attribute name : String; attribute value : String; reference parent[0-1] : Element oppositeOf children; } class Attribute extends Node {} class Text extends Node {} class Element extends Node { reference children[*] ordered container : Node oppositeOf parent; } class Root extends Element {} } package PrimitiveTypes { datatype Boolean; datatype Integer; datatype String; }

42 A XML2Book transformation module XML2Book; create OUT : Book from IN : XML; helper context XML!Element def: getAttrVal(name : String) : String = self.children->select(c | c.oclIsKindOf(XML!Attribute) and c.name = name)->first().value; rule Book { from e : XML!Element ( e.name = 'book' ) to b : Book!Book ( title <- e.getAttrVal('title'), chapters select(c | c.oclIsKindOf(XML!Element))->asSequence() ) } rule Chapter { from e : XML!Element ( e.name = 'chapter' ) to c : Book!Chapter ( title <- e.getAttrVal('title'), nbPages <- e.getAttrVal('nbPages').toInteger(), author <- e.getAttrVal('author') )} +title : String +nbPages : Integer +author : String Chapter +title : String Book *+chapters {ordered} +book

43 Launch configuration – transformation file

44 Launch configuration – model and metamodel files

45 The generated file – a Book model

46 Global view M1 M2 M3 XML metamodel inputMod- XML.ecore ME/EMF ATL metamodel XML2Book model Ecore As a last step, we have to execute our Book2Publication transformation! Book metamodel Public metamodel Book2Publ model inputMod- Book.ecore outputMod- Public.ecore

47 Launch configuration – transformation file

48 Launch configuration – model and metamodel files

49 The generated file – a Publication model

50 Bibliography GMT Home page. ATL at GMT Home Page. – ATL presentation sheet: Short presentation of ATL project. – ATL Starter's Guide: Working draft of the ATL Starter's Guide. – ATL User Manual: Working draft of the ATL User Manual. – Specification of the ATL Virtual Machine: Working draft of the specification of the ATL Virtual Machine. – ATL Transformation Description Template: Working draft of the transformation description template. ATL home page.