Requirements M2DOC

Hello,
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:function.name}
{m:for req|function.requirement}
{m:req.name}
{m:endfor}
{m:endfor}
thanks for help
Kind regard,

Hi,
It seems you have a typo ligne 1:
sel instead of
self.
Samuel

Hello,
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.

Hello,
In this case, you should replace
by

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

Hello,
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: actor.appliedRequirements.name } 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 ?
Regards,

Hello,
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) }
Regards,

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.
Regards,

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