Requirements M2DOC

I try to extract the requirements allocated in Logical Function with this code but it is not working
{m:for function| sel.eAllContents(la::LogicalFunction)}
{m:for req|function.requirement}
thanks for help
Kind regard,

It seems you have a typo ligne 1:
sel instead of

Are you using the native Capella Requirements, or the Requirement add-on for Capella ?
(Those are two different kind of requirements, thus M2Doc queries will be different)

Hello all,
Samuel thank you, but i have issue in how extract allocated requirements “line 3”.
actuality i am using the native Capella Requirements.

In this case, you should replace

thank you very much Aurélien,it’s working now.

I reopen this topic, because I have an issue trying to use M2Doc the same way as you are.
The query {m: for req|actor.appliedRequirements}
( actor as been defined wih the query {m:for actor | self.containedOperationalAnalysis.ownedEntityPkg.eContents() }
raise the issue :
Invalid for statement: EClassifier=ElementExtension is not registered in the current environmentInvalid for statement: Feature appliedRequirements not found in EClass AbstractConstraintInvalid for statement: The iteration variable types must be collections ([Sequence(EClassifier=Requirement), Nothing(Feature appliedRequirements not found in EClass AbstractConstraint)]).
I don’t really understand what the problem is here. The command { m: } gives me the names of my requirements attached.
I think I don’t really how the requirements are stored, hence the "collection"issue.
Have you ever faced such an error ? And in that case, how did you manage it ?

Can you try to replace your query to define actor by the following one:
{m:for actor | self.containedOperationalAnalysis.ownedEntityPkg.ownedEntiti es }
AQL try to check if the relation you try to navigate is indeed defined on the type of model element you are currently working from the definition of your queries.
The method eContents is defined to return some “eObject” (generic EMF object).
The method appliedRequirements is not defined on “eObject” but is defined on the type “CapellaElement” (which is a specialization of the “eObject” defined with Capella)
This is why you get an error with M2Doc (even if when you apply eContents on the EntityPackage of the Operational Analysis you will at the end get some “CapellaElement”…).
The interpreter view does not raises errors on types and always try to evaluate the expression.
However, the query “ownedEntities” is defined to return some “Entity” which are a specialization of the type “CapellaElement”.
Thus, M2Doc will know for sure that the relation appliedRequirements is defined on all the actor.
If you want to use generic queries in M2Doc (such as eContents), you need to apply a filter afterward in order to be sure that you get the right type of element.
For example, the following query shall also work:
{m:for actor | self.containedOperationalAnalysis.ownedEntityPkg.eContents() - >filter(capellacore::CapellaElement) }

1 Like

Thank you Aurelien, your solution worked perfectly !
I didn’t thought about the differences between M2Doc and the Sirius interpreter, I guess that in the future I will be more cautious with the use of this one.

Thank you very much for this explanation! It clarifies a lot and will be a great time saver for my templating work.


I reopen this topic. I’m trying to use M2Doc to extract requirements that have been implemented in the Capella Model using the Requirement Viewpoint.

I’m trying to use:
{m:for req | self.eAllContents(Requirements:Requirement)}
{m:req} "Here I tried, req.description, req.ReqIFText,… req.ReqIFName

I also tried the solutions posted above, but my requirements are not placed at Operational Analysis nor System Analysis, they depend directly from the .aird file.

Any advice? Should I move the requirements at the Operational or System Analysis? Thanks!


You have a typo:


should be:


You will also probably need to add the nsURI of the requirement metamodel to your template using the template property wizard.
As mentioned above there are two ways for adding requirements, here I suppose that you are using the requirements addon.


I had a mistake when posting this but I’ve been using without success:
Requirements:: Requirement

I also have the nsURI:

  1. htttp://
  2. htttp://

What could I try?

Can you try to check the type of the requirement you are trying to access by selecting it in the project explorer (the tree on the left) and in the interpreter try the following query:

self.eClass() + '::' + self.eClass().name

Don’t forget to prefix the query with aql: if you are using the Sirius interpreter.
This expression will given you the type to use in your eAllContents() call.
If you are selecting the element from a diagram you can use: + '::' +

You might need to add the nsURI of the EPackage if it’s not already in your template.

It’s strange because I followed your instructions and they appear as Requirements::Requirement type, but when I try to call them from self.eAllContents(Requirements::Requirement) they don’t appear.

I don’t know why is this happening.


Do you have an error message ? Did you import all the needed nsURIs using the template property wizard ?