In the context of Sirius, M2Doc reuse the crossreferencer installed by Sirius to implement eInverse(). This crossreferencer only reference semantic cross references and not semantic to diagram references.
You have two options here:
tell M2Doc to install its own crossreferencer by setting the InstallCrossReferenceAdapter option to true in the generation configuration (the .genconf file). This can can be time consuming depending on the size of your model.
You can use the following expression to get the representations a semantic element is visible on:
It’s time consuming at generation time. M2Doc will install a new crossreferencer that will need to compute all cross references in the model. But it might not be an issue in your case.
The semantic element needs to be a model object not a String, in your example it was the selection. Of course you can adapt the condition according to your needs. If you want to select on the type you can use:
viewpoint::DRepresentation.allInstances().representationElements->select(re | re.oclIsKindOf(diagram::DNodeList) and re.target = semanticElement)
If you want only representation element that are diagram::DNodeList and represent the given semantic element.