Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » ecore XMLHandler barfing on transient and derived member - why?
ecore XMLHandler barfing on transient and derived member - why? [message #1015172] Wed, 27 February 2013 16:22 Go to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I'm creating my EMF model from an XML schema. In my schema, I am trying to create an object that is a URI that also contains 4 attributes - i.e. I'm trying to extend xs:anyURI.

To comply with the schema I am working with, I may only persist the attributes and NOT the URI. In the schema, the 4 attributes constitute a "library reference", but I'm trying to get EMF to build an actual ecore reference for me - but I can't persist that reference.

So I have declared some ecore annotations like this:

<xs:complexType name="resolvedComponentLibraryRefType">
<xs:simpleContent ecore:reference="spirit:componentType" ecore:derived="true" ecore:transient="true">
<xs:extension base="xs:anyURI">
<xs:attributeGroup ref="spirit:libraryRefGroup"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>


The resulting EMF object looks correct to me.


public class ResolvedComponentLibraryRefTypeImpl extends EObjectImpl implements ResolvedComponentLibraryRefType {
protected ComponentType value;


I have a member called "value" that points to a ComponentType. Perfect, that's what I want. That reference is marked as derived and transient. So I believe this member will not be persisted and only the attributes in <xs:attributeGroup ref="spirit:libraryRefGroup"/> will be persisted.


However, when I load an XML file that doesn't contain anything for "value", the XMLHandler throws and exception:


Value 'null' is not legal. (file:///blah blah)
org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2663)


I've read the EMF book and I've seen that derived, transient, and volatile go hand in hand, but I did not like how volatile="true" did not create local storage for my reference; I want that local storage in my application domain, I just don't want it to be persisted.

I see the Lower Bound for value is set to 0, so I don't think anyone should be expecting something to be required to be there. The Upper Bound is 1.

Anyone have any ideas what I'm doing wrong? Why is EMF's XMLHandler complaining about null when I've already told it that there shouldn't be anything there?
Re: ecore XMLHandler barfing on transient and derived member - why? [message #1015198 is a reply to message #1015172] Wed, 27 February 2013 17:36 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Brandon,

Comments below.

On 27/02/2013 5:22 PM, Brandon Lewis wrote:
> I'm creating my EMF model from an XML schema. In my schema, I am
> trying to create an object that is a URI that also contains 4
> attributes - i.e. I'm trying to extend xs:anyURI.
> To comply with the schema I am working with, I may only persist the
> attributes and NOT the URI. In the schema, the 4 attributes
> constitute a "library reference", but I'm trying to get EMF to build
> an actual ecore reference for me - but I can't persist that reference.
I'm not sure I parsed all that correctly...
>
> So I have declared some ecore annotations like this:
>
> <xs:complexType name="resolvedComponentLibraryRefType">
> <xs:simpleContent ecore:reference="spirit:componentType"
> ecore:derived="true" ecore:transient="true">
> <xs:extension base="xs:anyURI">
> <xs:attributeGroup ref="spirit:libraryRefGroup"/>
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
>
I'm not sure how a reference is supposed to capture all that attribute
content...
>
> The resulting EMF object looks correct to me.
>
> public class ResolvedComponentLibraryRefTypeImpl extends EObjectImpl
> implements ResolvedComponentLibraryRefType {
> protected ComponentType value;
>
>
> I have a member called "value" that points to a ComponentType.
> Perfect, that's what I want. That reference is marked as derived and
> transient. So I believe this member will not be persisted and only
> the attributes in <xs:attributeGroup ref="spirit:libraryRefGroup"/>
> will be persisted.
>
>
> However, when I load an XML file that doesn't contain anything for
> "value", the XMLHandler throws and exception:
>
>
> Value 'null' is not legal. (file:///blah blah)
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2663)
>
>
>
> I've read the EMF book and I've seen that derived, transient, and
> volatile go hand in hand, but I did not like how volatile="true" did
> not create local storage for my reference; I want that local storage
> in my application domain, I just don't want it to be persisted.
I totally don't get what you're trying to do...
>
> I see the Lower Bound for value is set to 0, so I don't think anyone
> should be expecting something to be required to be there. The Upper
> Bound is 1.
> Anyone have any ideas what I'm doing wrong? Why is EMF's XMLHandler
> complaining about null when I've already told it that there shouldn't
> be anything there?
What does an instance look like?


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:A newbie question of EMF transaction
Next Topic:Store EMF Objects in PreferenceStore
Goto Forum:
  


Current Time: Fri Apr 19 06:43:33 GMT 2024

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

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

Back to the top