Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF] Get element name of an EObject
[EMF] Get element name of an EObject [message #1058252] Mon, 13 May 2013 11:12 Go to next message
Dhanya M is currently offline Dhanya M
Messages: 16
Registered: April 2013
Junior Member
Hi,

Is there a possibility to get the XML element name of an EObject.
I used eObject.eClass().getName(). But in cases where xml structure is with xsi types, it gives the specific type instead of the generic element.

Eg: I have an xml tag <GENERIC attr1="String" xsi:type="SPECIFIC"/>

When i do eObject.eClass().getName() I get SPECIFIC. However i need GENERIC as the value.

Thanks.
Regards,
Dhanya
Re: [EMF] Get element name of an EObject [message #1058300 is a reply to message #1058252] Mon, 13 May 2013 13:48 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles David
Messages: 128
Registered: July 2009
Senior Member
Try eObject.eContainingFeature().getName().

The XML tag name does not correspond to a type name but to the name of the (containment) feature through which the parent element/object contains this one.
Re: [EMF] Get element name of an EObject [message #1058335 is a reply to message #1058300] Mon, 13 May 2013 15:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26054
Registered: July 2009
Senior Member
Yes, or more generally, to get the actual XML name if there is extended
metadata, and to deal with features in feature maps, you'd to use
ExtendedMetaData.INSTANCE.getName(eObject.eContainmentFeature()).


On 13/05/2013 3:48 PM, Pierre-Charles David wrote:
> Try eObject.eContainingFeature().getName().
>
> The XML tag name does not correspond to a type name but to the name of
> the (containment) feature through which the parent element/object
> contains this one.
>
Re: [EMF] Get element name of an EObject [message #1058418 is a reply to message #1058335] Tue, 14 May 2013 04:46 Go to previous message
Dhanya M is currently offline Dhanya M
Messages: 16
Registered: April 2013
Junior Member
Thanks.

eObject.eContainingFeature().getName() gives me the type name. In the eg: gENERIC
and
ExtendedMetaData.INSTANCE.getName(eObject.eContainmentFeature()) gives me the XML tag name GENERIC
Previous Topic:Compare 2 EObjects with that same model
Next Topic:[POLL] Still Using Java 1.5?
Goto Forum:
  


Current Time: Mon Sep 22 12:14:21 GMT 2014

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

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