6 3 b Atlas Transformation Language ATL Tutorial
6 -3 b. Atlas Transformation Language (ATL) Tutorial / Exercise <Presenter> <Company>, <Country> <E-mail> © 2005 -2006 The ATHENA Consortium.
Exercise • Objective – Hands-on experience with ATL – Develop a PIM 4 SOA information to XSD model transformation • References – The Atlas Transformation Language Home Page • http: //www. sciences. univ-nantes. fr/lina/atl – ATL in Eclipse • http: //www. eclipse. org/gmt/atl/ • Technical requirements – Eclipse 3. 2 – EMF 2. 2. 0 – ATL needs: • antlr-2. 7. 5 • mdr-standalone © 2005 -2006 The ATHENA Consortium. 2
Transformation overview Ecore conforms to PIM 4 SOA meta-model ATL conforms to model. PIM © 2005 -2006 The ATHENA Consortium. PIM 4 SOA-2 -XSD is tranformed into XSD meta-model conforms to output. XSD 3
PIM 4 SOA metamodel © 2005 -2006 The ATHENA Consortium. 4
Simple XSD metamodel © 2005 -2006 The ATHENA Consortium. 5
The mapping mapped to mapped to © 2005 -2006 The ATHENA Consortium. 6
The input model © 2005 -2006 The ATHENA Consortium. 7
Create an ATL project © 2005 -2006 The ATHENA Consortium. 8
Models and metamodels © 2005 -2006 The ATHENA Consortium. 9
Create an ATL file © 2005 -2006 The ATHENA Consortium. 10
ATL rules and helpers • Two kind of rules – Matched rules: • Declarative transormation • Specify source and target • Specify the way to generate target – Called rules: • Imperative transformation • Seen as some kind of helpers • Helpers – Viewed as equivalent to Java methods – Factorized code called from different points in transformation © 2005 -2006 The ATHENA Consortium. 11
Document 2 Schema rule Document 2 Schema{ from doc : PIM 4 SOA!Document to sch : XSD!XSDSchema( document <- doc. name, target. Namespace <- 'http: //www. w 3. org/2001/XMLSchema') } © 2005 -2006 The ATHENA Consortium. 12
Entity 2 Complex. Type helper context PIM 4 SOA!Entity def : get. Associations() : PIM 4 SOA!Entity = PIM 4 SOA!Association. all. Instances() ->select(assoc | assoc. container = self); rule Entity 2 Complex. Type{ from ent : PIM 4 SOA!Entity to ct : XSD!XSDComplex. Type( name <- ent. name, xsd_attribute <- Sequence{ent. attribute}, xsd_element <- ent. get. Associations() ) } © 2005 -2006 The ATHENA Consortium. 13
Association 2 Element and Attribute 2 Attribute rule Association 2 Element{ from assoc : PIM 4 SOA!Association to el : XSD!XSDElement( name <- assoc. name, type <-assoc. contained) } rule Attribute 2 Attribute{ from att : PIM 4 SOA!Attribute to el : XSD!XSDAttribute( name <- att. name, type <- att. type ) } © 2005 -2006 The ATHENA Consortium. 14
Item. Type 2 Simpe. Type rule Item. Type 2 Simple. Type{ from it : PIM 4 SOA!Item. Type( -- transform only Item. Types and not Entities it. ocl. Is. Kind. Of(PIM 4 SOA!Entity)= false ) to st : XSD!XSDSimple. Type( name <- it. name ) © 2005 -2006 The ATHENA Consortium. 15
Run the file © 2005 -2006 The ATHENA Consortium. 16
The result <? xml version="1. 0" encoding="ISO-8859 -1"? > <xmi: XMI xmi: version="2. 0" xmlns: xmi="http: //www. omg. org/XMI" xmlns: xsd="http: ///xsd"> <xsd: XSDSchema document="Order" target. Namespace="http: //www. w 3. org/2001/XMLSchema"/> <xsd: XSDSimple. Type name="String"/> <xsd: XSDSimple. Type name="Integer"/> <xsd: XSDComplex. Type name="product. Record"> <xsd_attribute name="supplier. Product. Code" type="/1"/> <xsd_attribute name="buyer. Product. Code" type="/1"/> <xsd_attribute name="quantity" type="/2"/> <xsd_attribute name="description" type="/1"/> <xsd_attribute name="model" type="/1"/> <xsd_attribute name="product. Price" type="/1"/> <xsd_attribute name="comments" type="/1"/> </xsd: XSDComplex. Type> <xsd: XSDComplex. Type name="order. Header"> <xsd_attribute name="id" type="/2"/> <xsd_attribute name="issued. Date" type="/1"/> </xsd: XSDComplex. Type> <xsd: XSDComplex. Type name="products. Info"> <xsd_element name="product. Records" type="/3"/> <xsd_attribute name="product. Name" type="/1"/> <xsd_attribute name="product. Code" type="/1"/> </xsd: XSDComplex. Type> </xmi: XMI> © 2005 -2006 The ATHENA Consortium. 17
This course has been developed under the funding of the EC with the support of the EC ATHENA-IP Project. Disclaimer and Copyright Notice: Permission is granted without fee for personal or educational (non-profit) use, previous notification is needed. For notification purposes, please, address to the ATHENA Training Programme Chair at rg@uninova. pt. In other cases please, contact at the same e-mail address for use conditions. Some of the figures presented in this course are freely inspired by others reported in referenced works/sources. For such figures copyright and all rights therein are maintained by the original authors or by other copyright holders. It is understood that all persons copying these figures will adhere to the terms and constraints invoked by each copyright holder. © 2005 -2006 The ATHENA Consortium. 18
- Slides: 18