Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forums[Acceleo3] for loop over collection
https://www.eclipse.org/forums/index.php/mv/msg/205344/656973/#msg_656973
According to the MOF Model to Text Transformation
Language, v1.0 standard, I should be able to avoid writing a for loop by invoking a template on a collection.
So assume I defined:
[template genFoo(p: Foo)]
foo
[/template]
and suppose that 's' represents a collection of Foo. Then,
[genFoo(s)/]
should result in invocation of genFoo for each element of 's' if I'm right.
It seems to me that this is not (yet) implemented in Acceleo or am I doing something wrong?
Greetings,
Wilbert
PS: from the standard:
8.1.10 TemplateInvocation
A template invocation specifies one or more invocations of a template. An argument of a template invocation is specified
by an expression that could evaluate either to a single value or a set of values. The rules for determining which template
to invoke and how many times are as follows:
The types of arguments should match the types of the corresponding parameters. An argument type matches the parameter type when the latter is either the same type or a super type. If the argument is a set and the parameter is a singleton, then the template is invoked for each member of the set.
]]>Wilbert Alberts2011-03-01T08:44:10-00:00Re: [Acceleo3] for loop over collection
https://www.eclipse.org/forums/index.php/mv/msg/205344/656985/#msg_656985
In your case, you should use this syntax: [s.genFoo()/].
The syntax "[genFoo(s)/]" is not supported for a collection if the template/query does not apply to a collection.