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 |
Juan Pedro Silva 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>
cO : MMA!Entity (cO.name='Cliente' or cO.name='Nombre'),<br>
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>
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 |
Frédéric Jouault 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 #95898 is a reply to message #95884] |
Fri, 21 November 2008 09:32 |
Juan Pedro Silva 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
>
|
|
|
Goto Forum:
Current Time: Mon Apr 29 17:37:09 GMT 2024
Powered by FUDForum. Page generated in 0.04541 seconds
|