Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Wrapping sourcemodelelements
[ATL] Wrapping sourcemodelelements [message #77942] Mon, 31 March 2008 01:18 Go to next message
Stefan Schulze is currently offline Stefan SchulzeFriend
Messages: 70
Registered: July 2009
Member
Hi...

I try to wrap elements of a sourcemetamodel into elements of the
targetmetamodel, but the output-model is quite empty.

Can anybody help me?

Here is a minimized example:

VVVVVV source.ecore: VVVVVVV
<ecore:EPackage 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" name="class"
nsURI="http://atltest/src" nsPrefix="src">
<eClassifiers xsi:type="ecore:EClass" name="Class">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ClassCollection">
<eStructuralFeatures xsi:type="ecore:EReference" name="classes"
upperBound="-1"
eType="#//Class" containment="true"/>
</eClassifiers>
</ecore:EPackage>
^^^^^^^^^^^^^^^^^^^^^^

VVVVVV target.ecore: VVVVVVV
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage 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" name="target"
nsURI="http://atltest/trg" nsPrefix="target">
<eClassifiers xsi:type="ecore:EClass" name="Wrapper">
<eStructuralFeatures xsi:type="ecore:EReference" name="wrapped"
lowerBound="1"
eType="ecore:EClass ../source/Source.ecore#//Class"
containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="WrapperCollection">
<eStructuralFeatures xsi:type="ecore:EReference" name="wrapper"
eType="#//Wrapper"
containment="true"/>
</eClassifiers>
</ecore:EPackage>
^^^^^^^^^^^^^^^^^^^^^^

VVVVVV sourceInstance.xmi VVVVVVVV
<?xml version="1.0" encoding="ASCII"?>
<src:ClassCollection xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:src="http://atltest/src" xsi:schemaLocation="http://atltest/src
Source.ecore">
<classes name="C1"/>
<classes name="C2"/>
</src:ClassCollection>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

VVVVVV WrapperTrafo.atl VVVVVVV
module WrapperTrafo;
create Trg : TrgMM from Src : SrcMM;

rule Wrap {
from
c : SrcMM!Class
to
w : TrgMM!Wrapper (
wrapped <- c
)
}

rule Coll {
from
cc : SrcMM!ClassCollection
to
wc : TrgMM!WrapperCollection (
wrapper <- cc.classes
)
}
^^^^^^^^^^^^^^^^^^^^^^^^

VVVVVVV TargetInstance.xmi VVVVVVVV
<?xml version="1.0" encoding="ISO-8859-1"?>
<target:WrapperCollection xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:target="http://atltest/trg"/>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Re: [ATL] Wrapping sourcemodelelements [message #77960 is a reply to message #77942] Mon, 31 March 2008 07:52 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 297
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090303040009090302070500
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi

Stefan Schulze a
Re: [ATL] Wrapping sourcemodelelements [message #77977 is a reply to message #77960] Mon, 31 March 2008 11:07 Go to previous messageGo to next message
Stefan Schulze is currently offline Stefan SchulzeFriend
Messages: 70
Registered: July 2009
Member
"William Piers" <william.piers@obeo.fr> schrieb im Newsbeitrag
news:fsq58d$ll4$1@build.eclipse.org...
> In your target metamodel, wrapper has the "Wrapper" type. But cc.classes
> gives you a list of classes. You can't set the wrapper feature with a
> list, a single value is required.

Thank you for the hint. I made mistake in the target metamodel.
WrapperCollection#wrapper should be 0..*.
I fixed this and the transformation creates the WrapperCollection containing
two wrapper. But these wrappers don't refer to any class.

I don't get any message on the console and according to the debugger,
"wrapped <- c" evaluates to the same object for both created wrappers.

Stefan
Re: [ATL] Wrapping sourcemodelelements [message #78007 is a reply to message #77977] Mon, 31 March 2008 14:28 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 297
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090603000801070509000906
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

In your Target metamodel, the "wrapped" feature is a containment
(containment="true")... and the Class object (as any EObject) can't be
contained into both a ClassCollection and a Wrapper. That's why the
"wrapped" reference is empty.

Regards,

William

Stefan Schulze a
Re: [ATL] Wrapping sourcemodelelements [message #78037 is a reply to message #78007] Mon, 31 March 2008 17:39 Go to previous messageGo to next message
Stefan Schulze is currently offline Stefan SchulzeFriend
Messages: 70
Registered: July 2009
Member
"William Piers" <william.piers@obeo.fr> schrieb im Newsbeitrag
news:fsqseu$483$1@build.eclipse.org...
> In your Target metamodel, the "wrapped" feature is a containment
> (containment="true")... and the Class object (as any EObject) can't be
> contained into both a ClassCollection and a Wrapper. That's why the
> "wrapped" reference is empty.

Hi William,

I modeled it to be a containment, because the old container,
ClassCollection, doesn't exist in the targetmetamodel. So there would be no
container.

I changed "wrapped" to be no containment, but this results in
<target:WrapperCollection xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:target="http://atltest/trg">
<wrapper wrapped="//@wrapper.0"/>
<wrapper wrapped="//@wrapper.1"/>
</target:WrapperCollection>

I think it tries to set "wrapped" to the wrapper-objects, because the
assignment uses the equivalent transformed element for the assignment. But
this is not metamodel-compliant - the type of "wrapped" is "Class" but not
"Wrapper".

Stefan
Re: [ATL] Wrapping sourcemodelelements [message #78053 is a reply to message #78037] Tue, 01 April 2008 08:27 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 297
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010206000109030903020603
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hello,

Stefan Schulze a
Re: [ATL] Wrapping sourcemodelelements [message #78070 is a reply to message #78053] Tue, 01 April 2008 14:55 Go to previous messageGo to next message
Stefan Schulze is currently offline Stefan SchulzeFriend
Messages: 70
Registered: July 2009
Member
Hi William,

"William Piers" <william.piers@obeo.fr> schrieb im Newsbeitrag
news:fssrli$lkv$1@build.eclipse.org...
> If you want the input classes to be contained into the target model, you
> need to copy them in it :
>
> rule Wrap {
> from
> c : SrcMM!Class
> to
> w : TrgMM!Wrapper (
> wrapped <- cl
> ),
> cl : TrgMM!Class (
> name <- c.name
> )
> }

With this transformation I get an error, that my target metamodel doesn't
contain the type "Class".
At this point the target metamodel contains an inter-model reference
(eType="ecore:EClass ../source/Source.ecore#//Class").
Is it possible with ATL to handle inter-model references in the target
metamodel?

The target model, I'm expecting is something like this:
<?xml version="1.0" encoding="ASCII"?>
<target:WrapperCollection xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:target="http://atltest/trg" xsi:schemaLocation="http://atltest/trg
target.ecore">
<wrapper>
<wrapped href="../source/SourceInstance.xmi#//@classes.0"/>
</wrapper>
<wrapper>
<wrapped href="../source/SourceInstance.xmi#//@classes.1"/>
</wrapper>
</target:WrapperCollection>

Stefan
Re: [ATL] Wrapping sourcemodelelements [message #78099 is a reply to message #78070] Tue, 01 April 2008 15:47 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 297
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020603010309020802000802
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi,

Stefan Schulze a
Re: [ATL] Wrapping sourcemodelelements [message #78131 is a reply to message #78099] Wed, 02 April 2008 02:01 Go to previous message
Stefan Schulze is currently offline Stefan SchulzeFriend
Messages: 70
Registered: July 2009
Member
Hi William,

thank you very much. Setting "wrapped" to non-containment and using the
refSetValue in the imperative section works exactly as expected!

Bye,
Stefan
Previous Topic:Set the path for UML source model
Next Topic:[ATL] Using generated EFactory for target metamodel
Goto Forum:
  


Current Time: Sun Aug 25 20:03:37 GMT 2019

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

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

Back to the top