Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo3] for loop over collection
[Acceleo3] for loop over collection [message #656973] Tue, 01 March 2011 08:44 Go to next message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 209
Registered: June 2010
Senior Member

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)]

and suppose that 's' represents a collection of Foo. Then,


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?


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.

Re: [Acceleo3] for loop over collection [message #656985 is a reply to message #656973] Tue, 01 March 2011 09:30 Go to previous message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi Wilbert,

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.

Stephane Begaudeau, Obeo

Twitter: @sbegaudeau
Acceleo wiki:
Blogs: &
Previous Topic:[Acceleo3] Polymorphism in queries?
Next Topic:executeworkflow leading to out of memory error
Goto Forum:

Current Time: Fri Dec 01 04:29:05 GMT 2023

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

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

Back to the top