© 2005-2006 the athena consortium. 6-3b. atlas transformation language (atl) tutorial / exercise,
TRANSCRIPT
© 2005-2006 The ATHENA Consortium.
6-3b. Atlas Transformation Language (ATL)
Tutorial / Exercise
<Presenter>
<Company>, <Country>
<E-mail>
2© 2005-2006 The ATHENA Consortium.
Exercise
• Objective– Hands-on experience with ATL– Develop a PIM4SOA 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
3© 2005-2006 The ATHENA Consortium.
Transformation overview
Ecore
PIM4SOAmeta-model
ATL
PIM4SOA-2-XSD
XSDmeta-model
outputXSDmodelPIM
conforms to conforms to
conforms to
conforms to
conforms to
conforms to
is tranformed into
11© 2005-2006 The ATHENA Consortium.
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
12© 2005-2006 The ATHENA Consortium.
Document2Schema
rule Document2Schema{
from doc : PIM4SOA!Document
to sch : XSD!XSDSchema(
document <- doc.name,
targetNamespace <- 'http://www.w3.org/2001/XMLSchema')
}
13© 2005-2006 The ATHENA Consortium.
Entity2ComplexType
helper context PIM4SOA!Entity def : getAssociations() : PIM4SOA!Entity = PIM4SOA!Association.allInstances() ->select(assoc | assoc.container = self);
rule Entity2ComplexType{
from ent : PIM4SOA!Entity
to ct : XSD!XSDComplexType(
name <- ent.name,
xsd_attribute <- Sequence{ent.attribute},
xsd_element <- ent.getAssociations() )
}
14© 2005-2006 The ATHENA Consortium.
Association2Element and Attribute2Attribute
rule Association2Element{from assoc : PIM4SOA!Association
to el : XSD!XSDElement(name <- assoc.name,type <-assoc.contained)}
rule Attribute2Attribute{from att : PIM4SOA!Attribute
to el : XSD!XSDAttribute(name <- att.name,type <- att.type )}
15© 2005-2006 The ATHENA Consortium.
ItemType2SimpeType
rule ItemType2SimpleType{
from it : PIM4SOA!ItemType(
-- transform only ItemTypes and not Entities
it.oclIsKindOf(PIM4SOA!Entity)= false
)
to st : XSD!XSDSimpleType(
name <- it.name
)
17© 2005-2006 The ATHENA Consortium.
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" targetNamespace="http://www.w3.org/2001/XMLSchema"/> <xsd:XSDSimpleType name="String"/> <xsd:XSDSimpleType name="Integer"/> <xsd:XSDComplexType name="productRecord"> <xsd_attribute name="supplierProductCode" type="/1"/> <xsd_attribute name="buyerProductCode" type="/1"/> <xsd_attribute name="quantity" type="/2"/> <xsd_attribute name="description" type="/1"/> <xsd_attribute name="model" type="/1"/> <xsd_attribute name="productPrice" type="/1"/> <xsd_attribute name="comments" type="/1"/> </xsd:XSDComplexType> <xsd:XSDComplexType name="orderHeader"> <xsd_attribute name="id" type="/2"/> <xsd_attribute name="issuedDate" type="/1"/> </xsd:XSDComplexType> <xsd:XSDComplexType name="productsInfo"> <xsd_element name="productRecords" type="/3"/> <xsd_attribute name="productName" type="/1"/> <xsd_attribute name="productCode" type="/1"/> </xsd:XSDComplexType></xmi:XMI>
18© 2005-2006 The ATHENA Consortium.
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 [email protected]. 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.