I am having some troubles trying to run ATL for the first time. I am following the basic atl tutorial.
I have created 2 metamodels (.ecore), an input model (.xmi) and an ATL transformation.
I would like to include them in this post, but somehow this is not possible. Also I cannot include images or links. I have posted the code below, and replaced all the internet links by "xxx-".
The ATL file:
-- @path Families=/FamiliesToPersons/Families.ecore
-- @path Persons=/FamiliesToPersons/Persons.ecore
module FamiliesToPersons;
create OUT : Persons from IN : Families;
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;
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)
}
The sample file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="xxx-omg.org/XMI" xmlns="Families">
<Family lastName="March">
<father firstName="Jack"/>
<mother firstName="Linsy"/>
<sons firstName="Brandon"/>
<sons firstName="David"/>
<daughters firstName="Brenda"/>
</Family>
<Family lastName="Colpaert">
<father firstName="Donald"/>
<mother firstName="Angeline"/>
<sons firstName="Robin"/>
<sons firstName="Jeroen"/>
<sons firstName="Mathias"/>
<daughters firstName="Steffie"/>
</Family>
</xmi:XMI>
The target meta-model (Persons.ecore):
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="xxx-omg.org/XMI" xmlns:xsi="xxx-w3.org/2001/XMLSchema-instance"
xmlns:ecore="xxx-eclipse.org/emf/2002/Ecore" name="Persons">
<eClassifiers xsi:type="ecore:EClass" name="Person" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="fullName" lowerBound="1"
eType="ecore:EDataType xxx-eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Male" eSuperTypes="#//Person"/>
<eClassifiers xsi:type="ecore:EClass" name="Female" eSuperTypes="#//Person"/>
</ecore:EPackage>
The source meta-model (Families.ecore)
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="xxx-omg.org/XMI" xmlns:xsi="xxx-w3.org/2001/XMLSchema-instance"
xmlns:ecore="xxx-eclipse.org/emf/2002/Ecore" name="Families">
<eClassifiers xsi:type="ecore:EClass" name="Family">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="lastName" lowerBound="1"
eType="ecore:EDataType xxx-eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="father" lowerBound="1"
eType="#//Member" eOpposite="#//Member/familyFather"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="mother" lowerBound="1"
eType="#//Member" eOpposite="#//Member/familyMother"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="sons" upperBound="-1" eType="#//Member"
eOpposite="#//Member/familySon"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="daughters" upperBound="-1"
eType="#//Member" eOpposite="#//Member/familyDaughter"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Member">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="firstName" lowerBound="1"
eType="ecore:EDataType xxx-eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="familyFather" eType="#//Family"
eOpposite="#//Family/father"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="familyMother" eType="#//Family"
eOpposite="#//Family/mother"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="familySon" eType="#//Family"
eOpposite="#//Family/sons"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="familyDaughter" eType="#//Family"
eOpposite="#//Family/daughters"/>
</eClassifiers>
</ecore:EPackage>
After setting all the configurations right, running the transformation does not give me an error, the output file is correctly generated, but its EMPTY? it looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="xxx-omg.org/XMI"/>
So no data is inserted..
Any help would be greatly appreciated!
PS: I run windows 8 with eclipse Juno and ATL plugin installed..]]>