Hello, I am trying to use M2Doc to generate documentation with the requirements addon. I want to show the requirements linked to a function. This is my M2Doc template Call:
m:for req |f.eAllContents().target->filter(Requirements::Requirement)
This aql works fine in the sirius interpreter but it does not work in the M2Doc. It tells me “Empty collection: Feature target not found in…” and all the EClass. I assume it is because i am lacking some nsURI but i already have these ones:
I found some people asking similar questions on other posts but I couldn’t make it work. Do you have any idea to make it work?
When you are selecting an element on a diagram you select the graphical representation of this element on the diagram (DDiagramElement), and to get the semantic element itself you need to do a
.target. In M2Doc you are probably already on the semantic element and don’t need the
In this case the eAllContents() call navigate the structure of the diagram and not the structure of the semantic model. So depending on what diagram you are using it might not be equivalent to the following expression:
Note that using the type for filtering in the
eAllContents() call is more optimized since AQL is able to prune parts of the model using the metamodel structure.
I already tried that, it gives me this error message:
Empty collection: Nothing will be left after calling eAllContents: EClassifier=LogicalFunction can’t contain EClassifierLiteral=Requirement direclty or indirectly
With the .target it works in the interpreter, showing me the req linked to the functions.
I know it can get tedious, but try to get to it step by step, so instead of trying to go from the top “f” to the end (requirements), try to decompose it,
test every step in the interpreter (both), then try to charge the doc , and compare until you find which step is not working.
What a lot of people don’t know is that sometimes the interpreter can show you a result that seems to be ONE element when it is in fact a sequence, it can break the M2DOC generation sometimes…
You probably need to add the nsURIs of requirements metamodels to your template. You can use the template properties wizard. This will register the metamodel structures in your template.
I added all the nsURIs that i showed above, do you know which other nsURI is necessary?
Something is probably not working with AQL. As a workaround, you can use: