Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Conditions on all source elements of multiple source pattern
[ATL] Conditions on all source elements of multiple source pattern [message #95850] Thu, 20 November 2008 22:22 Go to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080407080302030207080804
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hello everybody.
Please forgive me if I'm asking something silly, as I couldn't find any
documentation on the multiple source pattern (as I see it's called).
My question is, are conditions only allowed for the last source element?.
A quick example:
I'm trying to write

from
cO : MMA!Entity (cO.name='Cliente' or cO.name='Nombre'),
sdr : MMB!Resource (sdr.name='StaticDataResource')
to...

but I get a "no viable alternative at input ',' " compile error.
If I delete the (cO.name='Cliente' or cO.name='Nombre') condition, it
goes away.
I guess is not the condition itself, as I have this in more rules.

Is there a reason for this?, or is only that it hasn't been implemented
yet?.
Thank you all and best regards,
Juan Pedro



--------------080407080302030207080804
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hello everybody.<br>
Please forgive me if I'm asking something silly, as I couldn't find any
documentation on the multiple source pattern (as I see it's called).<br>
My question is, are conditions only allowed for the last source
element?.<br>
A quick example:<br>
I'm trying to write<br>
<br>
<font color="#3333ff">from <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; cO : MMA!Entity (cO.name='Cliente' or cO.name='Nombre'),<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sdr : MMB!Resource (sdr.name='StaticDataResource')<br>
to...</font><br>
<br>
but I get a "no viable alternative at input ',' " compile error.<br>
If I delete the <font color="#3333ff">(cO.name='Cliente' or
cO.name='Nombre') <font color="#000000">condition, it goes away.<br>
I guess is not the condition itself, as I have this in more rules.<br>
<br>
Is there a reason for this?, or is only that it hasn't been implemented
yet?.<br>
Thank you all and best regards,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Juan Pedro<br>
<br>
<br>
</font></font>
</body>
</html>

--------------080407080302030207080804--
Re: [ATL] Conditions on all source elements of multiple source pattern [message #95869 is a reply to message #95850] Fri, 21 November 2008 08:46 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

A source pattern is composed of 1 to many source pattern elements (name
+ type from a source metamodel + optional model specification) plus
*one* filter/guard/condition.

Here is how you could write your source pattern:

from
cO : MMA!Entity,
sdr : MMB!Resource (
(cO.name='Cliente' or cO.name='Nombre') and
(sdr.name='StaticDataResource')
)

Note that you may also have conditions that use several source elements.
For instance, you could have (of course, this depends on the
metamodels): cO.resourceName = sdr.name
When you have such a condition, you are basically resolving a "reference
by name".


Regards,

Frédéric Jouault


Juan Pedro Silva a écrit :
> Hello everybody.
> Please forgive me if I'm asking something silly, as I couldn't find any
> documentation on the multiple source pattern (as I see it's called).
> My question is, are conditions only allowed for the last source element?.
> A quick example:
> I'm trying to write
>
> from
> cO : MMA!Entity (cO.name='Cliente' or cO.name='Nombre'),
> sdr : MMB!Resource (sdr.name='StaticDataResource')
> to...
>
> but I get a "no viable alternative at input ',' " compile error.
> If I delete the (cO.name='Cliente' or cO.name='Nombre') condition, it
> goes away.
> I guess is not the condition itself, as I have this in more rules.
>
> Is there a reason for this?, or is only that it hasn't been implemented
> yet?.
> Thank you all and best regards,
> Juan Pedro
>
>
Re: [ATL] Conditions on all source elements of multiple source pattern [message #95884 is a reply to message #95850] Fri, 21 November 2008 08:53 Go to previous messageGo to next message
Max Bureck is currently offline Max BureckFriend
Messages: 72
Registered: July 2009
Member
Hello,

As written in the syntax-definition
(http://wiki.eclipse.org/M2M/ATL/Syntax), the conditions have to be
defined after the definition of the in-pattern elements.

So it has to look like this:

from
cO : MMA!Entity,
sdr : MMB!Resource ( (cO.name='Cliente' or cO.name='Nombre') and
(sdr.name='StaticDataResource') )
to
t : ....

I hope you know that matched rules with multiple input elements are tricky
to invoke. You have to write it like that:

someproperty <- thisModule.resolveTemp(Tuple{cO=someEnt,sdr=someRes},'t'))

Greetings,
Max
Re: [ATL] Conditions on all source elements of multiple source pattern [message #95898 is a reply to message #95884] Fri, 21 November 2008 09:32 Go to previous message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
Frederic, Max, thank for your help.
I'll give it a try.
Regards,
Juan Pedro

Max Bureck escribió:
> Hello,
>
> As written in the syntax-definition
> (http://wiki.eclipse.org/M2M/ATL/Syntax), the conditions have to be
> defined after the definition of the in-pattern elements.
>
> So it has to look like this:
>
> from
> cO : MMA!Entity,
> sdr : MMB!Resource ( (cO.name='Cliente' or cO.name='Nombre') and
> (sdr.name='StaticDataResource') )
> to
> t : ....
>
> I hope you know that matched rules with multiple input elements are
> tricky to invoke. You have to write it like that:
>
> someproperty <-
> thisModule.resolveTemp(Tuple{cO=someEnt,sdr=someRes},'t'))
>
> Greetings,
> Max
>
Previous Topic:[QVTO] Unspecified upper bound (-2)
Next Topic:[ATL] Dealing with imported elements for the output model
Goto Forum:
  


Current Time: Tue Apr 16 06:19:49 GMT 2024

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

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

Back to the top