Problems accessing fields

I am a newbie using Capella & M2DOC to generate of Doc export using templates and all the stuff.
Thanks to the mass of examples I was able to do my first steps with the tool,
but I am facing several problems that I am not able to solve after several (lot’s) hours of work.
I want to export in the Word file several Pictures from the Logical Architecture
Inspire by examples given on this topic I started like that :

{ m:for k | self.eAllContents()}
{ m:for rep | k.representationByDescriptionName(‘Logical Data Flow Blank’)}
{ m:if’[Overview]’)> O}
{ }
{ m:rep.aslmage().fit(500,400)}
{ }
{ m:endif }
{ m:endfor }
{m:endfor }

it works … allmost … I select only file containing [Overview] in the title


  1. I have a strange warning …

{ m:for rep | k.representationByDescriptionName(‘Logical Data Flow Blank’) <–EClassifier=ElementExtension is not registered in the current environment}

I hardly understand it

  1. I whould like to select on a more suitable element like aql:self.visibleInDoc

  2. I would like to add the picture description text but I was not able to have the k.description working : Invalid query statement: Feature description not found in EClass DRepresentation

I cannot find the methodes and properties associate to this EClass DRepresentation !!! How can I find it

Thank in advance and sorry for these clumsy first step in the tool …


Hi Pierre,

The collection self.eAllContents() can contains element of type ElementExtension which are the top level element to create extensions to the Capella model. You can avoid this warning by adding the following nsURI to your template: (might be a different version)
This way M2Doc will have the type definition of ElementExtension.

The EStructuralFeature visibleInDoc is available on PublishableElement. You can try:
- add the nsURI (or your version)

The EClass DRepresentation comes from Sirius. In your case it should be a DDiagram that represent the diagram and not the root element of the diagram. You can use to get the root element of the diagram (an element from your Capella model). The target type is EObject, so you will have to cast is to the type of element root of the diagram for instance as in the last point.
If you get stuck a some point writing an AQL expression, you can try to call the .eClass() service that will return the EClass of the element to help you with .oclAsType() and .eClass().eAllStructuralFeatures to list available EStructuralFeatures.

Hope this help.


Thank you for your quick awnser !

The first point is solved and it enlight me for the usage of nsURI
Iboke several template in the process, but it worth the effort !

The other two question I was not able to solve, because the target was not recognize, may be another missing nsURI

I installed the
and the core/common but it did not seems to have effect

if you have any hints ?

Tanks by advance


Do you have any new error message ? Maybe you don’t have the Sirius nsURI referenced ? Try to add *sirius* from the nsURI dialog. See template properties wizard for more details.

Hi Yvan

I am pretty sur you are right, looking at the template =>

{ m:for k | self.eAllContents()}
{ m:for rep | k.representationByDescriptionName(‘Logical Data Flow Blank’)}
{ m:if’[Overview]’)> O}
{ m:rep<—Couldn’t find the ‘target(org.eclipse.sirius.viewpoint.DRepresentation)’}

it is this org.eclipse.sirius.viewpoint.DRepresentation that is missing

but looking in the template configuration nsURI (expert)

I see no…

only a I tried but that does not give me the good result

of coruse looking in the Add I see no viewpoint …

I procedded to the standard installation … Am I missing something ? (hum … probably yes)

Thank you for your help and understanding !!

In the code you pasted I see instead of
It’s a feature not a service. But you will need Sirius nsURIs to use it.
You should see the *sirius* nsURIs in the dialog for selecting nsURIs since Capella is build on top of Sirius:


sorry for the target(), I also made the test without Brackets and it neither works …

Invalid query statement: Feature target not found in EClass DRepresentation

Juste to explain, I started my template using the LA_Complete.docx, it comes with plenty of capella and sirius nsURI

Please find hereafter a copy of all my nsURI in the Template nsURI list file
You can see at the bottom the kitalpha/emde you asked me to add and that solve the warning problem.

I also tried to include all nsURI using the Package Tab (2 entry : capella and sirius) but it seems to add to much things that are uncompatible together

So I started again from the LA_Complete.docx
Tempate_nsURI list.JPG

Hi, I found a solution finaly, lucky me ! :slight_smile:

{m:for lc | self.eAllContents (la::LogicalComponent) }
{m:if lc.oclAsType(modellingcore::PublishableElement).visibleInDoc}

It seems to work !

Hi !
Even if I have improve and found several things (eClass().eAllStructuralFeatures is great)

I am still stuck with my Description …

{ m:for k | self.eAllContents(la::LogicalComponent)}
{m:if lc.oclAsType(modellingcore::PublishableElement).visibleInDoc.toString() == ‘false’}
// I put false because it is more simple to set one or two element visibleInDoc to false
// in order to display them … but it is non intuitive

{ m:for rep | k.representationByDescriptionName(‘Logical Data Flow Blank’)}
{ }
{ m:rep.aslmage().fit(500,400)}
{ }
// there I would like to have access to the rep description texte to
// but the target does not work

{ m:endif }
{ m:endfor }
{m:endfor }

Do you have any idea ?

Best regards


There is a DRepresentation.documentation but Capella stores the content of the rich text editor in the DRepresentationDescriptor.documentation. You can retrieve it like this:

{m:rep.precedingSiblings()->filter(viewpoint::DAnalysis).ownedViews.ownedRepresentationDescriptors->select(descriptor | descriptor.representation = rep).documentation}

The content will be in HTML if you are using M2Doc 3.0.0 or newer you probably want to add a call to the fromHTMLBodyString() service.


Hum sorry it does not work

m:rep.precedingSiblings()->filter(viewpoint::DAnalysis).ownedViews.ownedRepresentationDescriptors->select(descriptor | descriptor.representation = rep).documentation
<—Empty collection: Nothing will be left after calling precedingSiblings: Only EClass can have preceding siblings not org.eclipse.sirius.viewpoint.DRepresentation
<—Empty collection: Nothing will be left after calling filter: Nothing will be left after calling precedingSiblings: Only EClass can have preceding siblings not org.eclipse.sirius.viewpoint.DRepresentation
<—Couldn’t find the ‘aqlFeatureAccess(Nothing(Nothing will be left after calling filter: Nothing will be left after calling precedingSiblings: Only EClass can have preceding siblings not org.eclipse.sirius.viewpoint.DRepresentation),java.lang.String)’ service<—The descriptor variable has no type

As it says the DRepresentation as no preceding Sibilings …

Could it be that the orginal wrongness it getting the object from

{ m:for rep | k.representationByDescriptionName(‘Logical Data Flow Blank’)}

that stuck us in a Drepresentation type that is limited ?

Do you have the sirius nsURI imported in your template ? because a DRepresentation should be recognized as an EClass, here it seems to be recognized as a Java Class.

I am using Capella 1.4.1 (the modele comes from 1.4.2 but it does not seems that M2DOC existe for this Capella version)

In my template here are the sirius references

Should I send you the template by mail ?

The validation of the precedingSibling() service is broken, as a workaround you can add a cast:

{m:rep.oclAsType(viewpoint::DRepresentation).precedingSiblings(viewpoint::DAnalysis).ownedViews.ownedRepresentationDescriptors->select(descriptor | descriptor.representation = rep).documentation}

I opened the following issue:

It works in a perfect way ! many thanks !!!

Should I risk another question … easy ones

I used the M2Doc for Capella 1.4.1 but users are working with 1.4.2
Is it compatible (I do not think so) and do you know when we will have the future version 1.4.2 (roughly speaking)

Thanks again

It should be compatible since it’s a minor version. But it has not been tested with Capella 1.4.2. The main reason the M2Doc Capella extension follows the Capella releases is the IFE example model and few specific services used in the example templates. If you don’t need them you can use a version of M2Doc directly.
But as said in the beginning more tests are preformed for the compatibility between M2Doc and Capella when a version of the M2Doc Capella extension is released.
For the moment I didn’t has a look at Capella 1.4.2, but I should have some time to release a new version of the M2Doc Capella extension at the beginning of 2021 hopefully.

When I realized that it was available only for 1.4.1, I just copied the model under 1.4.2 and opened it with a 1.4.1 Capella. It works, as you said the differences are minimal

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