Skip to main content



      Home
Home » Modeling » EMF » How to add get a GUID attribute when reading a XMI file(Using: ResourceSet and org.eclipse.emf.ecore.xmi.XMLResource)
How to add get a GUID attribute when reading a XMI file [message #698122] Mon, 18 July 2011 16:06 Go to next message
Eclipse UserFriend
Hi,

I was hoping someone out there could help me out with this issue of mine. My ultimate goal is to interpret and traverse this .xmi file through Eclipse to create appropriate diagrams from it. However, to do so I must have access to the GUIDs from the .xmi with a relationship to the interpreted EObjects; Does anyone have any ideas on how to make this work? (It would be amazing if I can somehow have Eclipse add an attribute say .GUID to provide me with this piece of information) Here is the code I used to have Eclipse interpret the .xmi for me.

ResourceSet RS = new ResourceSetImpl();
RS.getLoadOptions().put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE,Boolean.TRUE);
org.eclipse.emf.ecore.xmi.XMLResource resource = (XMLResource) RS.getResource(fileURI, true);

So from here resource has everything I need so far EXCEPT the GUID relationship of each object.

Any form of assistance would be much appreciated.
Thanks.
Benson
Re: How to add get a GUID attribute when reading a XMI file [message #698150 is a reply to message #698122] Mon, 18 July 2011 17:25 Go to previous messageGo to next message
Eclipse UserFriend
Benson,

Comments below.

On 18/07/2011 1:06 PM, Benson wrote:
> Hi,
>
> I was hoping someone out there could help me out with this issue of
> mine. My ultimate goal is to interpret and traverse this .xmi file
> through Eclipse to create appropriate diagrams from it. However, to
> do so I must have access to the GUIDs from the .xmi with a
> relationship to the interpreted EObjects;
Generally everything to do with IDs, e.g., resolving them, is handled
for you without you ever having to manipulate a GUID...
> Does anyone have any ideas on how to make this work? (It would be
> amazing if I can somehow have Eclipse add an attribute say .GUID to
> provide me with this piece of information) Here is the code I used to
> have Eclipse interpret the .xmi for me.
>
> ResourceSet RS = new ResourceSetImpl();
> RS.getLoadOptions().put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE,Boolean.TRUE);
>
> org.eclipse.emf.ecore.xmi.XMLResource resource = (XMLResource)
> RS.getResource(fileURI, true);
You can use resource.getID(EObject) to get the extrinsic ID associated
with that object.
>
> So from here resource has everything I need so far EXCEPT the GUID
> relationship of each object.
>
> Any form of assistance would be much appreciated.
> Thanks.
> Benson
Re: How to add get a GUID attribute when reading a XMI file [message #698667 is a reply to message #698150] Tue, 19 July 2011 19:26 Go to previous message
Eclipse UserFriend
Thanks Ed! That was exactly what I was looking for.

Benson
Previous Topic:EMF compare source bundles contain plugin.xml
Next Topic:[CDO] and the EMF commands.
Goto Forum:
  


Current Time: Mon Jul 28 14:45:15 EDT 2025

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

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

Back to the top