Display elements associated to a Req

Hello everyone,
I try to list all the elements that are bounded to a requirement with an Incoming relation (I use the requirement VP) with M2Do.
So, starting from the requirement REQ, my command is :
{m:for relation | REQ.ownedRelations->filter(CapellaRequirements::CapellaIncomingRelation)}
I then wanted to display the name of the targeted elements with the simple command {relation.target.name}, but as the type of the ‘target’ element is Abstract Element, it does not have a ‘name’ attribute.
I then tried to ‘force’ the typing with a filter :
{relation.taget->filter( relation.target.eClass()).name} , but the validation file display the following error :
Expression “relation.target- >filter(relation.target.eClass()).name” is invalid: missing expression
What those this error means ? How do you think will be the good way to get the name of the elements targeted by the Incoming relation ?

There is a space between the “-” and the “>” in the error message check that your expression is “->” and not “- >”.
But the service you want to use is relation.target.oclAsType(pkg::Class) where pkg::Class is the type you are expecting that hold the name feature. It’s a kind of cast it only help the AQL validation. At runtime it does nothing and your expression will fail to evaluate if the relation.target object doesn’t have a feature name.

Hello Yvan, thank you for your help.
The problem is that I do not know in advance what will be the type of the element (As a Requirement can be linked to almost every element of the model).
That is why I tried the ‘target.eClass()’ trick. It works fine when, for instance, I filter with ‘ctx::SystemFunction’

You should probably look for a common super type that hold the feature name. Or maybe ask for the
label of that EObject.
This service was introduced recently, M2Doc 3.0.0 or above.

Hello Julien,
I am using Capella and M2Doc also to document traceability between architecture and requirements. I am happy about your question, as the command/query you use made my day. But in general:
Where can I find a basic instruction about query/aql commands? Or a view of the datamodel of M2Doc in order to build up the right aql querries?

E.g. I couldn’t find a working query between architecture and requirements (RE VP) until I found your command ‘ownedRelations’ - I can not find the notation ‘Owned relation’ used inside capella,

Hello Florian,

This answer come a few month after your question but better late than never :slight_smile:
I am actually not a M2Doc expert but I mostly use the Interpreter to help me wth Aql queries. (How to query my capella model)


In the next version of M2Doc (3.2.0) and above, you will be able to use the M2Doc interpreter view. It’s an interpreter that will execute in the context of a given .genconf file. It has all the M2Doc services and your own services registred as in your template and it also provide a rendering similar to the generated document (images, tables, style, …).

Copyright © Eclipse Capella, the Eclipse Capella logo, Eclipse and the Eclipse logo are Trademarks of The Eclipse Foundation.