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 03:44 Go to next message
Wilbert Alberts is currently offline Wilbert Alberts
Messages: 91
Registered: June 2010
Member
Hi,

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.

Re: [Acceleo3] for loop over collection [message #656985 is a reply to message #656973] Tue, 01 March 2011 04:30 Go to previous message
Stephane Begaudeau is currently offline Stephane Begaudeau
Messages: 406
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: http://wiki.eclipse.org/Acceleo
Blogs: http://stephanebegaudeau.tumblr.com & http://sbegaudeau.tumblr.com



Previous Topic:[Acceleo3] Polymorphism in queries?
Next Topic:executeworkflow leading to out of memory error
Goto Forum:
  


Current Time: Thu Aug 28 03:17:25 EDT 2014

Powered by FUDForum. Page generated in 0.01859 seconds