Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Is :mixed EAttribute guaranteed to suggest that feature map contains all features of EClass?(A featuremap with :mixed annotation seems to contain all features)
Is :mixed EAttribute guaranteed to suggest that feature map contains all features of EClass? [message #859430] Fri, 27 April 2012 16:30 Go to next message
Seref Arikan is currently offline Seref ArikanFriend
Messages: 73
Registered: August 2010
Member
I am writing a tool that will walk instance of an ECore model to create a key-value form of it. This will happen during runtime, using information from ECore model's structure.

The Ecore model is generated from XSD, and there is a DocumentRoot type that is created when I read XML files compatible with the XSD.

The DocumentRootImpl has a featuremap (in the form of a BasicFeatureMap), and based on the DocumentRoot type from ECore, it seems to have an EAnnotation with name key and :mixed value.

The EMF book calls :mixed a special name that means the Eattribute is has a set of pointers to other features. In my code, I use getEAllStructuralFeatures to get all features of a class. EAttribute with name "mixed" is one of the features. I want to make sure that if the EAttribute with name "mixed" and EAnnotation "name=:mixed" contains only references to other EAttributes and References, which are also returned by getEAllStructuralFeatures.

I this is the case, I can skip this featuremap, and use the rest of the structural features returned by getEAllStructuralFeatures, since I'll already have all the features I'd need to walk on the instance.

Is my logic right? I hope this is clear enough Sad

Kind regards
Seref
Re: Is :mixed EAttribute guaranteed to suggest that feature map contains all features of EClass? [message #860561 is a reply to message #859430] Sat, 28 April 2012 05:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Seref,

Comments below.

On 27/04/2012 6:30 PM, Seref Arikan wrote:
> I am writing a tool that will walk instance of an ECore model to
> create a key-value form of it. This will happen during runtime, using
> information from ECore model's structure.
You might look to the EcoreUtil.Copier for guidance...
>
> The Ecore model is generated from XSD, and there is a DocumentRoot
> type that is created when I read XML files compatible with the XSD.
> The DocumentRootImpl has a featuremap (in the form of a
> BasicFeatureMap), and based on the DocumentRoot type from ECore, it
> seems to have an EAnnotation with name key and :mixed value.
Yes, it's treated as mixed content so the deserializer will be able to
capture leading comments.
>
> The EMF book calls :mixed a special name that means the Eattribute is
> has a set of pointers to other features.
Yes, in an XML Schema affects the entire content type. All the features
will delegate their storage to the mixed feature.
> In my code, I use getEAllStructuralFeatures to get all features of a
> class. EAttribute with name "mixed" is one of the features. I want to
> make sure that if the EAttribute with name "mixed" and EAnnotation
> "name=:mixed" contains only references to other EAttributes and
> References, which are also returned by getEAllStructuralFeatures.
You could use ExtendedMetaData.INSTANCE.getMixedFeature to find if it
has one.
> I this is the case, I can skip this featuremap, and use the rest of
> the structural features returned by getEAllStructuralFeatures, since
> I'll already have all the features I'd need to walk on the instance.
You won't capture other data stored in the mixed feature, e.g., text,
comments, and processing instructions.
>
> Is my logic right? I hope this is clear enough :(
In general, features that delegate their storage for models derived from
XML Schema will be marked as derived. They'll delegate to a feature map
corresponding to mixed content, a wildcard, or a group (see
ExtendedMetaData.getFeatureKind). You might want to take the approach
of ignoring derived features and only build information about
non-derived (and non-transient) features. An important aspect of
feature maps is that they preserve the original XML order of the elements.

It's probably a good idea to look at the Copier to see how it avoids
copying data more than once.
>
> Kind regards
> Seref
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Is :mixed EAttribute guaranteed to suggest that feature map contains all features of EClass? [message #861413 is a reply to message #860561] Sat, 28 April 2012 14:55 Go to previous message
Seref Arikan is currently offline Seref ArikanFriend
Messages: 73
Registered: August 2010
Member
Thanks a lot Ed,
My XML input is guaranteed to not to contain any text, comments etc that will be of interest to me. I am only interested in child elements which have types from the original XSD(s).

Thanks for the very helpful pointers to relevant metadata. I think I can use the featuremap to preserve order, and skip derived features.

Kind regards
Seref
Previous Topic:EObject resource detached
Next Topic:Using markers in nested TextEditor(s)
Goto Forum:
  


Current Time: Thu Apr 25 09:21:19 GMT 2024

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

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

Back to the top