Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » basic ATL transformation tutorial(problems with basic atl implementation)
icon9.gif  basic ATL transformation tutorial [message #988531] Fri, 30 November 2012 11:38 Go to next message
Mathias Colpaert is currently offline Mathias ColpaertFriend
Messages: 13
Registered: November 2012
Junior Member
Hi,
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..
Re: basic ATL transformation tutorial [message #988596 is a reply to message #988531] Fri, 30 November 2012 15:59 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
Hi,

I've checked/tested the sources of this example (cf. http://www.eclipse.org/m2m/atl/atlTransformations/#Families2Persons) with Eclipse Modeling Juno, and it seems to work well.
Probably there were some mistakes in your case when creating the different metamodels and models.

Best regards,

Hugo


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: basic ATL transformation tutorial [message #989032 is a reply to message #988596] Tue, 04 December 2012 11:02 Go to previous message
Mathias Colpaert is currently offline Mathias ColpaertFriend
Messages: 13
Registered: November 2012
Junior Member
Hello,

Thanks for the reply. Directly downloading the source code does indeed work. So I still haven't found the mistake in the example, but I will work from this then.

Regards,
Mathias
Previous Topic:Can I divide my script in different files?
Next Topic:NoSuchElementException when appending refining trace to sequence
Goto Forum:
  


Current Time: Thu Apr 18 03:32:42 GMT 2024

Powered by FUDForum. Page generated in 0.01518 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top