Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » how to read xmi:id fields in models files?
how to read xmi:id fields in models files? [message #1834183] Wed, 04 November 2020 12:05 Go to next message
Fatima Rani is currently offline Fatima RaniFriend
Messages: 22
Registered: April 2020
Junior Member
Hi ! my all meta-models are registered,i want to read the xmi:id field of the model file but unable to retrieve its value,any suggestion?

model file :

?xml version="1.0" encoding="UTF-8"?>
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:abcd="https://petrinetdsl" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.3/notation" xmi:id="_vSD84LHJEeq1h8ti2UwKzQ" type="Petrinetdsl" name="default.petrinetdsl_diagram" measurementUnit="Pixel">
<children xmi:type="notation:Node" xmi:id="_qLutgLHPEeqGGrut8ExKFg" type="2001">
<children xmi:type="notation:DecorationNode" xmi:id="_qLxJwLHPEeqGGrut8ExKFg" type="5001">
<layoutConstraint xmi:type="notation:Location" xmi:id="_qLxJwbHPEeqGGrut8ExKFg" x="-78" y="7"/>
</children>
<styles xmi:type="notation:DescriptionStyle" xmi:id="_qLvUkLHPEeqGGrut8ExKFg"/>
<element xmi:type="abcd:Place" href="default.petrinetdsl#//@places.0"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_qLvUkbHPEeqGGrut8ExKFg" x="259" y="175"/>
</children>

my code for reading different key and values
[for (aNode: Node | aDiagram.children)]
[aNode/]
[/for]

[aDiagram.children.element/]
[aDiagram.children.styles/]
[aDiagram.children.layoutConstraint/]
Re: how to read xmi:id fields in models files? [message #1834200 is a reply to message #1834183] Wed, 04 November 2020 19:42 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6934
Registered: July 2009
Senior Member
Hi

Standard answer. The xmi:is is an artefact of XMI serialization, it is not part of your model. (If your model was read from a model database there might be a table/row id instead.) You should therefore not seek to use it for any non-debugging purpose.

If you have legitimate need to mess with the xmi:ids, perhaps to stabilize them then perhaps you should ensure that your XXXResourceImpl generates nice xmi:ids. The Eclipse OCL Locally Unique Semantically Sensitive ID generator does this.

If xmi:ids are really part of your domain then maybe you should do an XML2XML transformation so that the XMI structure is explicit. The /org.eclipse.qvtd.xml/model/XMLmodel.ecore supports this. See http://www.eclipse.org/mmt/qvt/docs/OCL2018TextM2M/TextM2M.pdf for more details.

Or if you are determined to undermine the modeling integrity you may find that your favourite M2M / M2T has a getXmiID helper that is useful in debug printouts. Else you can write your own helper.

Regards

Ed Willink
Previous Topic:Make Acceleo usable by non-programmers
Next Topic:Read Stereotype / compare Stereotype
Goto Forum:
  


Current Time: Sun Nov 29 14:16:58 GMT 2020

Powered by FUDForum. Page generated in 0.02180 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top