Is :mixed EAttribute guaranteed to suggest that feature map contains all features of EClass? [message #859430] |
Fri, 27 April 2012 16:30 |
Seref Arikan 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
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 |
Ed Merks 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/
|
|
|
|
Powered by
FUDForum. Page generated in 0.04065 seconds