Types returned by : fromHTMLBodyString() and replaceLink()

I am trying the following code :

m:let TEXT1= U3.description.trim().fromHTMLBodyString().replaceLink(U3)
m:if TEXT1 = 'ID'
Write something

I also tried

 m:let TEXT1= U3.description.trim().fromHTMLBodyString()
 m:if TEXT1 = 'ID'
 Write something

However the comparison does not seem to work.
I know that TEXT1 here is 'ID", yet the comparison does not work.
Do this 2 functions not return a string, explaining why the comparisons are failing?
I tried to check these, but wasn’t able to identify a solution:
M2DocHTMLServices - M2Doc
M2DocGenServices - M2Doc


Edit : I usually check for types on the Capella interpreter, however the M2DOC interpreter does not show the returned “type”.

The fromHTMLBodyString() returns a Sequence of MElement.
And yes, that’s why the comparison fails.

To manipulate such elements you will need to create a Java service. MElement should be converted to EObject to be used without services. The is a bug opened for this:

I am note quite familiar with creating java services, don’t know the how/where/when. My coding experience is mainly Python and C++.
Thank you for your response

I don’t know if I should make a new post to continue here, i would like to point out 2 things:

  1. In the M2DOC documentation nightly ( Reference Documentation - M2Doc), some links do not work.
    For instance in:

An example of implementation can be found in the Sirius integration plug-in see the class SiriusConfigurationProvider and the extension in the plugin .xml.

SiriusConfigurationProvider lead to an empty page.

  1. A) In 2019, you said that you would create a service that returns the “element of interest” in Capella (here:https:// stackoverflow. com/questions/59457543/how-can-i-access-to-the-dannotation-eoi-of-a-diagram-elements-of-interest-with )

It this the one : (((((https:// www.m2doc. org/ref-doc/nightly/m2doc_service_semanticbrowserservices.html#orgpolarsyskitalphaemdemodelelementgetelementofinterestfordiagram–sequenceeobject)))))

  1. B) I usually use the “selection” or “selection.eClass()” to obtain the class of an element in my model, however the “element of interest” is not something that can be selected. How was it possible to establish that “element of interest” is actually a DAnnotation?

Same question for all other elements of the model that are not clickable.

  1. C) When tryign to add the service related to the element of interest manually, it was impossible., Whether i have written ( getElementsOfInterest()) in the research bar, or SemanticBrowserServices, or even the full link org.eclipse.sirius.viewpoint, DRepresentationDescriptor.getElementsOfInterest(), nothing would show under the research bar. Only when selecting “Capella” package that i got all the services shown below.

    This begs the question, how to actually add a single service… without having to tick the capella package box.

  2. As I said earlier, I am quite used to Python & C++, however I never had to code a Java service or anything similar, I would not know where to start it. Maybe the missing page/link in my question number 1, would help? That’s an example of a full service?
    From my understanding, i am guessing that creating a service can be done through Capella Studio maybe (following a tutorial similar to this one? https:// www.youtube. com/watch?v=NWCyKsPfc2Y ) or with Capella, following a tutorial similar to this one? ( Add Menu · eclipse/capella Wiki · GitHub ) and configuring org.eclipse.ui.commands and org.eclipse.ui.menus, but both examples seems to be targeting the developpemnt of a full add-on, rather than a service. Is creating a service for M2DOC a much simpler task? I would have loved to be guided through the process, eventhough this might be out of the scope of document generation? I am not sure. Instead, maybe get hints/guides where to start actually.

  1. Thank you I fixed the documentation.

2.A) Yes I think it should return the same objects.

2.B) I had to look at the code of Capella and the XMI .aird model to find how this information was stored. I made a copy of the model to use as reference then added an element of interest and compared the two files.

2.C) You need to search for SemanticBrowserServices, but if you don’t have the class in your workspace nor you template is inside a plug-in project that depend on org.obeonetwork.capella.m2doc.aql.queries, you will not be able to import it. You can edit the custom properties with MS Word and set:

 package org.obeonetwork.capella.m2doc.aql.queries.SemanticBrowserServices
  1. Using an IServicesConfigurator is not mandatory to create a service. But you will need to be familliar with plug-in development and build. You can have a look at the Capella extensions on github to see how it is done. The build is done using maven and run using github action.

The viewpoint generates plug-ins but not what you will need here. But yes the Plug-in development perspective and plug-in project will be needed. A good starting point can be found here. And yes you should be able to do all this with the Capella studio.

1 Like