|
|
Re: [Acceleo] How to traduct s.Fields ->collect(field|field.name='toto').notEmpty() [message #632746 is a reply to message #632631] |
Thu, 14 October 2010 07:02 |
|
This is a multi-part message in MIME format.
--------------040701010005030008010105
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi,
This is an OCL question rather than an Acceleo one.
"know if a collection contains a specific element" is not made through
"collect" in OCL ... and I am surprised your function works at all with ATL.
- s.Fields <= retrieve all fiels contained by "s"
- s.Fields->collect(field|field.name='toto') <= if a field's name is
"toto", add "true" to the collection, otherwise add "false" to it. If
you have fields named "tata", "toto", "titi", you then get a collection
containing "false", "true", "false" (the result of "field.name='toto'".
This is true in both ATL and Acceleo as it is basic OCL.
- s.Fields->collect(field|field.name='toto').notEmpty() <= returns true
if "s" contains at least one field, false otherwise, whatever the result
of "collect" as it does not alter the collection size.
"Testing if a collection contains a specific element" is done with
"exists", not "collect". You need to use :
- s.Fields->exists(field.name='toto')
where "exists(expression)" means "return true if at least one of the
elements in the collection validates 'expression'".
See also the OCL documentation we provide with Acceleo :
http://help.eclipse.org/helios/topic/org.eclipse.acceleo.doc /doc/html/ocl_operation_reference.html
..
Laurent Goubet
Obeo
poltrox wrote:
> Hi,
>
> I don't undurstand how to know if a collection contains a specifics
> elements.
>
> I want to traduct this ATL fonction in Acceleo :
> s.Fields ->collect(field|field.name='toto').notEmpty()
>
> Thanks
--------------040701010005030008010105
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=
--------------040701010005030008010105--
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03116 seconds