Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Transform to unknown target element
[ATL] Transform to unknown target element [message #797529] Mon, 13 February 2012 15:45 Go to next message
MinhTu TonThat is currently offline MinhTu TonThatFriend
Messages: 38
Registered: February 2012
Member
Hello everyone,
I have a question about ATL. Hope you can help me.
I'm facing a problem about how to transform to an element without knowing in advance its existence in the metamodel. Say I have a class A, I want to check whether there's a class named "A1" inherited from A and if yes, transform a given value to A1. Any help will be appreciated.
Re: [ATL] Transform to unknown target element [message #798175 is a reply to message #797529] Tue, 14 February 2012 10:51 Go to previous messageGo to next message
MinhTu TonThat is currently offline MinhTu TonThatFriend
Messages: 38
Registered: February 2012
Member
Hello again,
Could anyone help me on this problem? To be more specific, I'll give an example like this. I want to transform MM1!A to MM2!B. In MM2 I have many classes inheriting from B (B1, B2, ...). In MM1!A I have an attribute typed String like "inheritingClass:String". Now within the transformation rule, basing on the inheritingClass attribute form MM1!A (its value could be 'B1', 'B2', ...), is there any way to determine the subclass form B to which I will transform A's values?
Best regards.
Re: [ATL] Transform to unknown target element [message #798328 is a reply to message #798175] Tue, 14 February 2012 14:47 Go to previous messageGo to next message
Zheng Cheng is currently offline Zheng ChengFriend
Messages: 15
Registered: February 2012
Junior Member
If my interpretation is correct, you can put conditions on the input and have multiple rules for the same src model, e.g.
rule A2B1{
    from
       in : MM1!A (in.inheritingClass = 'B1')
    to 
       out : MM2!B1
}

rule A2B2{
    from
       in : MM1!A (in.inheritingClass = 'B2')
    to 
       out : MM2!B2
}

[Updated on: Tue, 14 February 2012 14:48]

Report message to a moderator

Re: [ATL] Transform to unknown target element [message #798343 is a reply to message #798328] Tue, 14 February 2012 15:05 Go to previous messageGo to next message
MinhTu TonThat is currently offline MinhTu TonThatFriend
Messages: 38
Registered: February 2012
Member
Hi Zheng,
Firstly, thank you for your answer. In fact, my problem is we don't know the value of inheritingClass attribute before writing the rule. I mean, is there a similar approach like this snippet of code:
for all subclasses of B
if there exists a subclass whose type name is equal to A.inheritingClass
then transform A's value to that subclass's value
.
Regards.
Re: [ATL] Transform to unknown target element [message #800652 is a reply to message #798343] Fri, 17 February 2012 10:11 Go to previous messageGo to next message
MinhTu TonThat is currently offline MinhTu TonThatFriend
Messages: 38
Registered: February 2012
Member
Because my question is still not answered yet, I reparaphrase it to this question: Is it possible to reason about the existence of the elements of the meta-model in an ATL rule during the rule creation? Is it feasible to write a kind of code with the following philosophy:
If there exists an element named A in the target metamodel then transform a given value to it, else do nothing?
Regards.
Re: [ATL] Transform to unknown target element [message #800996 is a reply to message #800652] Fri, 17 February 2012 19:55 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 147
Registered: July 2009
Senior Member
On 17/02/12 11:11, Capi Tali wrote:
> Because my question is still not answered yet, I reparaphrase it to this
> question: Is it possible to reason about the existence of the elements of the
> meta-model in an ATL rule during the rule creation? Is it feasible to write a
> kind of code with the following philosophy:
> If there exists an element named A in the target metamodel then transform a
> given value to it, else do nothing?
> Regards.

First of all: this goes against the philosophy of MDE and model
transformation. Models are first-order, and transformations should not reflect
on the metamodels but just use them.

The way around this first-order limitation, is to use a second transformation:
a higher-order transformation. This second transformation will generate your
first-order transformation, made to measure for your specific metamodel.

See also:
http://www.eclipse.org/m2m/atl/atlTransformations/#KM32ATLCopier
http://jordicabot.com/papers/ICMT10a.pdf

If the expected variation of output metamodels is bounded and small enough,
you can manually create one model transformation for each output metamodel as
well.

Regards,
Dennis
Re: [ATL] Transform to unknown target element [message #801313 is a reply to message #800996] Sat, 18 February 2012 07:02 Go to previous message
MinhTu TonThat is currently offline MinhTu TonThatFriend
Messages: 38
Registered: February 2012
Member
Thank for your reply, Dennis. I think using the HOT to create appropriate transformation rules according to each meta-model fits me well Very Happy
Previous Topic:[ATL]Guard condition at target element in matched rule
Next Topic:[ATL] Compiling ATL files to ASM in build system
Goto Forum:
  


Current Time: Thu Apr 25 17:22:14 GMT 2024

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

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

Back to the top