question to modelmodification with ATL [message #86084] |
Tue, 08 July 2008 09:11  |
Eclipse User |
|
|
|
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 17:00  |
Eclipse User |
|
|
|
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>
>
|
|
|
Powered by
FUDForum. Page generated in 0.50070 seconds