Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » question to modelmodification with ATL
question to modelmodification with ATL [message #86084] Tue, 08 July 2008 13:11 Go to next message
Eclipse UserFriend
Originally posted by: musich.gmx.de

I'm trying do a Modelmodification with ATL, but I do not know how can I
insert a new instance of input model element to output model.
Can Anyone help me?

for example:
my metamodel is the following:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
<ecore:EPackage name="Author">
<eClassifiers xsi:type="ecore:EClass" name="Author">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
ordered="false" unique="false" lowerBound="1" eType="/1/String"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="surname"
ordered="false" unique="false" lowerBound="1" eType="/1/String"/>
</eClassifiers>
</ecore:EPackage>
<ecore:EPackage name="PrimitiveTypes">
<eClassifiers xsi:type="ecore:EDataType" name="String"/>
</ecore:EPackage>
</xmi:XMI>

my inputmodel:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns="Author">
<Author name="David" surname="Touzet"/>
<Author name="tobias" surname="zimmerman"/>
</xmi:XMI>


how can I get this outputmodel ?

<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns="Author">
<Author name="David" surname="Touzet"/>
<Author name="Tobias" surname="zimmerman"/>
<Author name="Tomas" surname="Hering"/>
</xmi:XMI>
Re: question to modelmodification with ATL [message #86471 is a reply to message #86084] Sat, 12 July 2008 21:00 Go to previous message
Max Bureck is currently offline Max BureckFriend
Messages: 72
Registered: July 2009
Member
for this simple example it can look like this:

module Author2Copy; -- Module Template
create OUT : MM from IN : MM;

unique lazy rule NewOne{
from n : String,
s : String
to t : MM!Author(name<-n, surname<-s)
}

rule Copy{
from s : MM!Author
to t : MM!Author( name<-s.name, surname<-s.surname)
do{
thisModule.NewOne('Tomas','Hering');
}
}

This is not a very elegant solution, but it works.

Greetings,
Max

musich schrieb:
> I'm trying do a Modelmodification with ATL, but I do not know how can I
> insert a new instance of input model element to output model.
> Can Anyone help me?
>
> for example:
> my metamodel is the following:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
> <ecore:EPackage name="Author">
> <eClassifiers xsi:type="ecore:EClass" name="Author">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> ordered="false" unique="false" lowerBound="1" eType="/1/String"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="surname"
> ordered="false" unique="false" lowerBound="1" eType="/1/String"/>
> </eClassifiers>
> </ecore:EPackage>
> <ecore:EPackage name="PrimitiveTypes">
> <eClassifiers xsi:type="ecore:EDataType" name="String"/>
> </ecore:EPackage>
> </xmi:XMI>
>
> my inputmodel:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xmi:XMI xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI" xmlns="Author">
> <Author name="David" surname="Touzet"/>
> <Author name="tobias" surname="zimmerman"/>
> </xmi:XMI>
>
>
> how can I get this outputmodel ?
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xmi:XMI xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI" xmlns="Author">
> <Author name="David" surname="Touzet"/>
> <Author name="Tobias" surname="zimmerman"/>
> <Author name="Tomas" surname="Hering"/>
> </xmi:XMI>
>
Previous Topic:[ATL] Iterative expression
Next Topic:[TCS] map file extensions to models
Goto Forum:
  


Current Time: Fri Apr 26 02:42:14 GMT 2024

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

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

Back to the top