[Acceleo] Cast between two metamodels [message #529628] |
Mon, 26 April 2010 11:11  |
Eclipse User |
|
|
|
Hi everyone
I'm trying to generate code from two metamodels, MA and MB.
The problem I'm facing is the following:
I have a class B in MB, which inherits from class A in MA.
I'd like to access some attributes in B, while I'm browsing classes A and B, like a basic Cast in java
Unfortunately, oclAsType() method works fine while I'm using classes from the same Metamodel, not if I want to use it with A and B like :
a.oclAsType(B), I get "Unrecognized variable: (B)" in
[template public write(a : A)]
[for (n : Node | a.children)]
[if (n.oclIsKindOf(Attribute))]
[n.oclAsType(B).write()/]
[/if]
[/for]
[/template]
Is there another way I'm not aware of to do this? maybe not using OCL ?
Regards
Nicolas
|
|
|
|
|
Re: [Solved] [Acceleo] Cast between two metamodels [message #529832 is a reply to message #529799] |
Tue, 27 April 2010 08:03  |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------040806090006080500040407
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Nicolas,
It is a common syntax in OCL ... but I doubt many people know all of the
different things we can do with OCL :p.
Laurent Goubet
Obeo
Nicolas Guyomar wrote:
> Hi Laurent,
>
> Thank you for your quick answer
>
> The solution you proposed works perfectly, I assume this syntax is
> pretty common in OCL .. shame on me
>
> Thank you again
>
> Nicolas
>
>
--------------040806090006080500040407
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------040806090006080500040407--
|
|
|
Powered by
FUDForum. Page generated in 0.07245 seconds