Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Access to keys in EMap member of model element(Access to keys in EMap member of model element)
Access to keys in EMap member of model element [message #1780744] Fri, 26 January 2018 14:53 Go to next message
Bruce Trask is currently offline Bruce TraskFriend
Messages: 58
Registered: July 2009

I used the steps from
to create a map in one of my model elements. It ends up generating an EMap.

My question is how to access that and the keys and values of its elements via the OCL or from the .mtl file in Acceleo.

In the OCL Interpreter view I enter // nameToPackageName is the map

as the expression

and I get back


which is what the map contains (two key value pairs)

If I do>asSequence()
I get the same result.

What I am trying to do is iterate through the map to get the individual keys and values.
->at() does not seem to do the trick with the Map.

I was hoping for something like ->get(key) but that does not appear to exist.

I could not find anything with regard to working with Maps in aql or OCL.


[Updated on: Fri, 26 January 2018 14:56]

Report message to a moderator

Re: Access to keys in EMap member of model element [message #1780757 is a reply to message #1780744] Fri, 26 January 2018 16:35 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7635
Registered: July 2009
Senior Member

(The new Pivot-based OCL adds a Map class to the OCL Standard Library; it has an at() operation. Unfortunately Acceleo has not migrated to exploit the new Pivot OCL.)

I have tried occasionally to exploit EMap without success. You may see my most recent attempt in

Since EMap is actually a linear list, you won't see the speedups for large Maps that you might expect, but for small maps the list can be faster...

If you really want a good Map I suggest you hand code the map in your * with friendly accessor methods.


Ed Willink

Previous Topic:Mulitple input models to Acceleo
Next Topic:Traceability
Goto Forum:

Current Time: Fri Dec 01 14:05:17 GMT 2023

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

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

Back to the top