Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] How to discard source elements or translate them to 'nothing'?
[ATL] How to discard source elements or translate them to 'nothing'? [message #514049] Fri, 12 February 2010 09:56 Go to next message
Dennis Hendriks is currently offline Dennis HendriksFriend
Messages: 66
Registered: January 2010
Location: Eindhoven, The Netherland...
Member
Hello all,

In my ATL transformation I use matched rules for all source elements. I assign source element features to target element features, which are automatically matched by matched rules by ATL. However, some source element features (references to other source elements) are to be discarded. I simply don't assign them to target element features. However, since they are source elements, ATL automatically matches them using the matched rules, and generates target elements that end up in the root of the output. This is valid ATL behavior, but I need a way to exclude those elements from the output.

I don't think it is possible to remove such elements after they are created (within the same ATL transformation), so I need a way to make sure they are not created in the first place. Is there a way to inform ATL that certain elements from the input should be discarded (not matched by matched rules)?

I tried manually translating them to nothing (so that they are already matched, but there is no output, or they are matched and the output is something like an empty string that I add to some other feature to get rid of it), but couldn't figure out how to do that using lazy rules, called rules, or something like that...

Does anyone know a way to do this in ATL? Any help would be greatly appreciated!

Dennis
Re: [ATL] How to discard source elements or translate them to 'nothing'? [message #514052 is a reply to message #514049] Fri, 12 February 2010 10:14 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
You can specify a filter on each rule to indicate which elements should be transformed or not.

from s : XX!YY (filter here)
Re: [ATL] How to discard source elements or translate them to 'nothing'? [message #514056 is a reply to message #514052] Fri, 12 February 2010 10:32 Go to previous messageGo to next message
Dennis Hendriks is currently offline Dennis HendriksFriend
Messages: 66
Registered: January 2010
Location: Eindhoven, The Netherland...
Member
Sylvain EVEILLARD wrote on Fri, 12 February 2010 11:14
You can specify a filter on each rule to indicate which elements should be transformed or not.

from s : XX!YY (filter here)


Yes, obviously. But this would be a complicated constraint to specify. Is there no other way to do this?
Re: [ATL] How to discard source elements or translate them to 'nothing'? [message #514066 is a reply to message #514049] Fri, 12 February 2010 10:56 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
One way or the other you'll have to specify somewhere which elements you want to transform...
Re: [ATL] How to discard source elements or translate them to 'nothing'? [message #514082 is a reply to message #514066] Fri, 12 February 2010 11:34 Go to previous messageGo to next message
Dennis Hendriks is currently offline Dennis HendriksFriend
Messages: 66
Registered: January 2010
Location: Eindhoven, The Netherland...
Member
Sylvain EVEILLARD wrote on Fri, 12 February 2010 11:56
One way or the other you'll have to specify somewhere which elements you want to transform...


Yes, but I was wondering if there is a way to specify the elements you DON'T want to transform, instead of specifying the elements you DO want to transform.
Re: [ATL] How to discard source elements or translate them to 'nothing'? [message #514096 is a reply to message #514049] Fri, 12 February 2010 12:39 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
That's basically the same.

Make a Sequence of the elements you don't want to transform (seq) and you can use thisModule.seq->excludes(s) as filter.
Re: [ATL] How to discard source elements or translate them to 'nothing'? [message #514105 is a reply to message #514096] Fri, 12 February 2010 13:03 Go to previous messageGo to next message
Dennis Hendriks is currently offline Dennis HendriksFriend
Messages: 66
Registered: January 2010
Location: Eindhoven, The Netherland...
Member
OK, I'll try that. Thanks!
Re: [ATL] How to discard source elements or translate them to 'nothing'? [message #515266 is a reply to message #514049] Thu, 18 February 2010 10:17 Go to previous messageGo to next message
RJ is currently offline RJFriend
Messages: 19
Registered: October 2009
Location: Eindhoven, The Netherland...
Junior Member
is it way too trivial to just define a filter for the elements you don't want, and then go

from s : XX!YY (not (filter))


? That would do what you want, right?

[Updated on: Thu, 18 February 2010 10:45]

Report message to a moderator

Re: [ATL] How to discard source elements or translate them to 'nothing'? [message #515272 is a reply to message #515266] Thu, 18 February 2010 10:32 Go to previous messageGo to next message
Dennis Hendriks is currently offline Dennis HendriksFriend
Messages: 66
Registered: January 2010
Location: Eindhoven, The Netherland...
Member
Let me rephrase my problem:

a rule like :
{{{
rule RULE1 {
from s : XX!YY
to ...
}
}}}

is required to copy all XX!YY instances, except for a few instances.

Then I have another rule:
{{{
rule SOMERULE {
from s : XX!ZZ
to t : AA!BB(
a <- s.a,
b <- s.b,
...
y <- Sequence{})
}
}}}

where the instances of XX!YY are not assigned to t.y. So, almost all XX!YY instances must be matched by the top level rule, except the XX!YY instances from SOMERULE s.y, which are discarded and not added to t.y. I would like to specify that they should not be translated, in the SOMERULE rule. Instead, I could come up with a filter to apply to the RULE1 rule, but it would be complicated, and I would rather have it localized to the SOMERULE rule.

My question is whether it is possible using some kind of lazy rule, or whatever, to translate the XX!YY instances of s.y such that they are already translated and are no longer matched by the RULE1 rule, as ATL no longer tries to match them (they are already matched)?

Hope this makes the question clearer?

Dennis
Re: [ATL] How to discard source elements or translate them to 'nothing'? [message #515279 is a reply to message #515272] Thu, 18 February 2010 10:47 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHEFriend
Messages: 129
Registered: July 2009
Senior Member
D. Hendriks (Dennis) a écrit :
> Let me rephrase my problem:
>
> a rule like :
> {{{
> rule RULE1 {
> from s : XX!YY
> to ...
> }
> }}}
>
> is required to copy all XX!YY instances, except for a few instances.
>
> Then I have another rule:
> {{{
> rule SOMERULE {
> from s : XX!ZZ
> to t : AA!BB(
> a <- s.a,
> b <- s.b,
> ...
> y <- Sequence{})
> }
> }}}
>
> where the instances of XX!YY are not assigned to t.y. So, almost all
> XX!YY instances must be matched by the top level rule, except the XX!YY
> instances from SOMERULE s.y, which are discarded and not added to t.y. I
> would like to specify that they should not be translated, in the
> SOMERULE rule. Instead, I could come up with a filter to apply to the
> RULE1 rule, but it would be complicated, and I would rather have it
> localized to the SOMERULE rule.
>
> My question is whether it is possible using some kind of lazy rule, or
> whatever, to translate the XX!YY instances of s.y such that they are
> already translated and are no longer matched by the RULE1 rule, as ATL
> no longer tries to match them (they are already matched)?
>
> Hope this makes the question clearer?
>
> Dennis

You should try to define your need on a white board using mathematical
sets (areas) to see which filters (boolean expressions) go with each rule.
--
Cordialement

Vincent MAHÉ

Ingénieur plate-forme - Cesar/Artemisia - Équipe Espresso
IRISA-INRIA, Campus de Beaulieu, 35042 Rennes cedex, France
Tél: +33 (0) 2 99 84 71 00, Fax: +33 (0) 2 99 84 71 71
Re: [ATL] How to discard source elements or translate them to 'nothing'? [message #515281 is a reply to message #514049] Thu, 18 February 2010 10:59 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
I would do :

helper context XX!ZZ def : filter : Boolean =
filter rule here
;

helper def : allSY : Sequence(XX!YY) =
XX!ZZ.allInstances()
->select(e | e.filter)
->collect(e | e.y)
->flatten()
;

helper context XX!YY def : filter : Boolean =
thisModule.allSY
->excludes(self)
;

and add s.filter as filter to both rules.
Re: [ATL] How to discard source elements or translate them to 'nothing'? [message #515893 is a reply to message #515281] Mon, 22 February 2010 07:13 Go to previous message
Dennis Hendriks is currently offline Dennis HendriksFriend
Messages: 66
Registered: January 2010
Location: Eindhoven, The Netherland...
Member
Thanks, I guess that'll do.
Previous Topic:CFP: 2nd International Workshop on Model Transformation with ATL (MtATL 2010)
Next Topic:ATL
Goto Forum:
  


Current Time: Fri Aug 23 02:18:16 GMT 2019

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

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

Back to the top