Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » seems like an "unsettable"-related serialization issue
seems like an "unsettable"-related serialization issue [message #431014] Wed, 24 June 2009 12:04 Go to next message
Adrian Herscu is currently offline Adrian HerscuFriend
Messages: 33
Registered: July 2009
Member
Hi all,

I have the following definition in my ecore:

<eClassifiers xsi:type="ecore:EClass" name="PrimitiveTypeComponent"
eSuperTypes="#//Component">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="PrimitiveTypeComponent"/>
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="modelType"
lowerBound="1"
eType="#//Primitive" defaultValueLiteral="Number">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="modelType"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>

which is is exported to XSD as:

<xsd:complexType name="PrimitiveTypeComponent">
<xsd:complexContent>
<xsd:extension base="appmodel:Component">
<xsd:attribute ecore:default="Number" ecore:unsettable="false"
name="modelType" type="appmodel:Primitive" use="required"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

If the user sets the modelType to Number then the serialized instance
looks like:

<appmodel:component xsi:type="appmodel:PrimitiveTypeComponent"
name="ConversionRateResultField"/>

which is invalid according to the schema since the modelType attribute
is flagged as "required". At the same time activating the EMF validator
returns OK. Hmmm... How is that?

If the user sets the modelType to something different than Number, then
everything is OK.

Please help,
Adrian.
Re: seems like an "unsettable"-related serialization issue [message #431017 is a reply to message #431014] Wed, 24 June 2009 12:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Adrian,

Comments below.


Adrian Herscu wrote:
> Hi all,
>
> I have the following definition in my ecore:
>
> <eClassifiers xsi:type="ecore:EClass" name="PrimitiveTypeComponent"
> eSuperTypes="#//Component">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="PrimitiveTypeComponent"/>
> <details key="kind" value="elementOnly"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="modelType"
> lowerBound="1"
> eType="#//Primitive" defaultValueLiteral="Number">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="modelType"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
>
> which is is exported to XSD as:
>
> <xsd:complexType name="PrimitiveTypeComponent">
> <xsd:complexContent>
> <xsd:extension base="appmodel:Component">
> <xsd:attribute ecore:default="Number" ecore:unsettable="false"
> name="modelType" type="appmodel:Primitive" use="required"/>
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
>
> If the user sets the modelType to Number then the serialized instance
> looks like:
>
> <appmodel:component xsi:type="appmodel:PrimitiveTypeComponent"
> name="ConversionRateResultField"/>
>
> which is invalid according to the schema since the modelType attribute
> is flagged as "required". At the same time activating the EMF
> validator returns OK. Hmmm... How is that?
For unsettable features with a lower bound of 1, the feature must be
eIsSet true to be valid. For non-unsettable features with a lower bound
of 1, there must be a non-null value returned by eGet. There are
statements about the state of the model instance in memory, not about
its serialize form. In terms of serialization, I suppose one could
argue that when mapping Ecore to XSD, we should map this case
differently, perhaps marking it optional, using a real schema default,
and specifying ecore:lowerBound="1" so it still produces the same Ecore
when imported...
>
> If the user sets the modelType to something different than Number,
> then everything is OK.
>
> Please help,
> Adrian.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: seems like an "unsettable"-related serialization issue [message #431030 is a reply to message #431017] Wed, 24 June 2009 19:45 Go to previous messageGo to next message
Adrian Herscu is currently offline Adrian HerscuFriend
Messages: 33
Registered: July 2009
Member
Ed Merks wrote:
> Adrian,
>
> Comments below.
>
>
> Adrian Herscu wrote:
>> Hi all,
>>
>> I have the following definition in my ecore:
>>
>> <eClassifiers xsi:type="ecore:EClass" name="PrimitiveTypeComponent"
>> eSuperTypes="#//Component">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="name" value="PrimitiveTypeComponent"/>
>> <details key="kind" value="elementOnly"/>
>> </eAnnotations>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="modelType"
>> lowerBound="1"
>> eType="#//Primitive" defaultValueLiteral="Number">
>> <eAnnotations
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> <details key="kind" value="attribute"/>
>> <details key="name" value="modelType"/>
>> </eAnnotations>
>> </eStructuralFeatures>
>> </eClassifiers>
>>
>> which is is exported to XSD as:
>>
>> <xsd:complexType name="PrimitiveTypeComponent">
>> <xsd:complexContent>
>> <xsd:extension base="appmodel:Component">
>> <xsd:attribute ecore:default="Number" ecore:unsettable="false"
>> name="modelType" type="appmodel:Primitive" use="required"/>
>> </xsd:extension>
>> </xsd:complexContent>
>> </xsd:complexType>
>>
>> If the user sets the modelType to Number then the serialized instance
>> looks like:
>>
>> <appmodel:component xsi:type="appmodel:PrimitiveTypeComponent"
>> name="ConversionRateResultField"/>
>>
>> which is invalid according to the schema since the modelType attribute
>> is flagged as "required". At the same time activating the EMF
>> validator returns OK. Hmmm... How is that?
> For unsettable features with a lower bound of 1, the feature must be
> eIsSet true to be valid. For non-unsettable features with a lower bound
> of 1, there must be a non-null value returned by eGet. There are
> statements about the state of the model instance in memory, not about
> its serialize form. In terms of serialization, I suppose one could
> argue that when mapping Ecore to XSD, we should map this case
> differently, perhaps marking it optional, using a real schema default,
> and specifying ecore:lowerBound="1" so it still produces the same Ecore
> when imported...

Then... What's the solution? I want it to serialize the modelType no
matter what its value is.

>>
>> If the user sets the modelType to something different than Number,
>> then everything is OK.
>>
>> Please help,
>> Adrian.
Re: seems like an "unsettable"-related serialization issue [message #431031 is a reply to message #431030] Wed, 24 June 2009 20:10 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080308000900070504080807
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Adrian,

If you don't care about the schema, try this option.

/**
* Keep default content ( e.g. default attributes). This applies
to saving and converting contents to DOM.
* By default the default content is discarded.
* To save the default content, set this option to
<code>Boolean.TRUE</code>.
*/
String OPTION_KEEP_DEFAULT_CONTENT = "KEEP_DEFAULT_CONTENT";


Adrian Herscu wrote:
>
>
> Ed Merks wrote:
>> Adrian,
>>
>> Comments below.
>>
>>
>> Adrian Herscu wrote:
>>> Hi all,
>>>
>>> I have the following definition in my ecore:
>>>
>>> <eClassifiers xsi:type="ecore:EClass" name="PrimitiveTypeComponent"
>>> eSuperTypes="#//Component">
>>> <eAnnotations
>>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>>> <details key="name" value="PrimitiveTypeComponent"/>
>>> <details key="kind" value="elementOnly"/>
>>> </eAnnotations>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>> name="modelType" lowerBound="1"
>>> eType="#//Primitive" defaultValueLiteral="Number">
>>> <eAnnotations
>>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>>> <details key="kind" value="attribute"/>
>>> <details key="name" value="modelType"/>
>>> </eAnnotations>
>>> </eStructuralFeatures>
>>> </eClassifiers>
>>>
>>> which is is exported to XSD as:
>>>
>>> <xsd:complexType name="PrimitiveTypeComponent">
>>> <xsd:complexContent>
>>> <xsd:extension base="appmodel:Component">
>>> <xsd:attribute ecore:default="Number"
>>> ecore:unsettable="false" name="modelType" type="appmodel:Primitive"
>>> use="required"/>
>>> </xsd:extension>
>>> </xsd:complexContent>
>>> </xsd:complexType>
>>>
>>> If the user sets the modelType to Number then the serialized
>>> instance looks like:
>>>
>>> <appmodel:component xsi:type="appmodel:PrimitiveTypeComponent"
>>> name="ConversionRateResultField"/>
>>>
>>> which is invalid according to the schema since the modelType
>>> attribute is flagged as "required". At the same time activating the
>>> EMF validator returns OK. Hmmm... How is that?
>> For unsettable features with a lower bound of 1, the feature must be
>> eIsSet true to be valid. For non-unsettable features with a lower
>> bound of 1, there must be a non-null value returned by eGet. There
>> are statements about the state of the model instance in memory, not
>> about its serialize form. In terms of serialization, I suppose one
>> could argue that when mapping Ecore to XSD, we should map this case
>> differently, perhaps marking it optional, using a real schema
>> default, and specifying ecore:lowerBound="1" so it still produces the
>> same Ecore when imported...
>
> Then... What's the solution? I want it to serialize the modelType no
> matter what its value is.
>
>>>
>>> If the user sets the modelType to something different than Number,
>>> then everything is OK.
>>>
>>> Please help,
>>> Adrian.

--------------080308000900070504080807
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Adrian,<br>
<br>
If you don't care about the schema,  try this option.<br>
<blockquote><small>  /**</small><br>
<small>   * Keep default content ( e.g. default attributes). This
applies to saving and converting contents to DOM.</small><br>
<small>   * By default the default content is discarded.</small><br>
<small>   * To save the default content, set this option to
&lt;code&gt;Boolean.TRUE&lt;/code&gt;.</small ><br>
<small>   */</small><br>
<small>  String OPTION_KEEP_DEFAULT_CONTENT = "KEEP_DEFAULT_CONTENT";</small><br>
</blockquote>
<br>
Adrian Herscu wrote:
<blockquote cite="mid:h1tvog$l8s$1@build.eclipse.org" type="cite"><br>
<br>
Ed Merks wrote:
<br>
<blockquote type="cite">Adrian,
<br>
<br>
Comments below.
<br>
<br>
<br>
Adrian Herscu wrote:
<br>
<blockquote type="cite">Hi all,
<br>
<br>
I have the following definition in my ecore:
<br>
<br>
&lt;eClassifiers xsi:type="ecore:EClass" name="PrimitiveTypeComponent"
eSuperTypes="#//Component"&gt;
<br>
    &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
      &lt;details key="name" value="PrimitiveTypeComponent"/&gt;
<br>
      &lt;details key="kind" value="elementOnly"/&gt;
<br>
    &lt;/eAnnotations&gt;
<br>
    &lt;eStructuralFeatures xsi:type="ecore:EAttribute"
name="modelType" lowerBound="1"
<br>
        eType="#//Primitive" defaultValueLiteral="Number"&gt;
<br>
      &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
        &lt;details key="kind" value="attribute"/&gt;
<br>
        &lt;details key="name" value="modelType"/&gt;
<br>
      &lt;/eAnnotations&gt;
<br>
    &lt;/eStructuralFeatures&gt;
<br>
  &lt;/eClassifiers&gt;
<br>
<br>
which is is exported to XSD as:
<br>
<br>
&lt;xsd:complexType name="PrimitiveTypeComponent"&gt;
<br>
    &lt;xsd:complexContent&gt;
<br>
      &lt;xsd:extension base="appmodel:Component"&gt;
<br>
        &lt;xsd:attribute ecore:default="Number"
ecore:unsettable="false" name="modelType" type="appmodel:Primitive"
use="required"/&gt;
<br>
      &lt;/xsd:extension&gt;
<br>
    &lt;/xsd:complexContent&gt;
<br>
  &lt;/xsd:complexType&gt;
<br>
<br>
If the user sets the modelType to Number then the serialized instance
looks like:
<br>
<br>
&lt;appmodel:component xsi:type="appmodel:PrimitiveTypeComponent"
name="ConversionRateResultField"/&gt;
<br>
<br>
which is invalid according to the schema since the modelType attribute
is flagged as "required". At the same time activating the EMF validator
returns OK. Hmmm... How is that?
<br>
</blockquote>
For unsettable features with a lower bound of 1, the feature must be
eIsSet true to be valid.  For non-unsettable features with a lower
bound of 1, there must be a non-null value returned by eGet.   There
are statements about the state of the model instance in memory, not
about its serialize form.  In terms of serialization, I suppose one
could argue that when mapping Ecore to XSD, we should map this case
differently, perhaps marking it optional, using a real schema default,
and specifying ecore:lowerBound="1" so it still produces the same Ecore
when imported...
<br>
</blockquote>
<br>
Then... What's the solution? I want it to serialize the modelType no
matter what its value is.
<br>
<br>
<blockquote type="cite">
<blockquote type="cite"><br>
If the user sets the modelType to something different than Number, then
everything is OK.
<br>
<br>
Please help,
<br>
Adrian.
<br>
</blockquote>
</blockquote>
</blockquote>
</body>
</html>

--------------080308000900070504080807--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: seems like an "unsettable"-related serialization issue [message #431035 is a reply to message #431031] Wed, 24 June 2009 21:54 Go to previous messageGo to next message
Adrian Herscu is currently offline Adrian HerscuFriend
Messages: 33
Registered: July 2009
Member
Ed Merks wrote:
> Adrian,
>
> If you don't care about the schema, try this option.

Works :)
Still, I do not understand what you meant by saying "If you don't care
about the schema". Of course I care about the schema, and now (thanks to
that option), the instance is serialized correctly.

>
> /**
> * Keep default content ( e.g. default attributes). This applies
> to saving and converting contents to DOM.
> * By default the default content is discarded.
> * To save the default content, set this option to
> <code>Boolean.TRUE</code>.
> */
> String OPTION_KEEP_DEFAULT_CONTENT = "KEEP_DEFAULT_CONTENT";
>
>
> Adrian Herscu wrote:
>>
>>
>> Ed Merks wrote:
>>> Adrian,
>>>
>>> Comments below.
>>>
>>>
>>> Adrian Herscu wrote:
>>>> Hi all,
>>>>
>>>> I have the following definition in my ecore:
>>>>
>>>> <eClassifiers xsi:type="ecore:EClass" name="PrimitiveTypeComponent"
>>>> eSuperTypes="#//Component">
>>>> <eAnnotations
>>>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>>>> <details key="name" value="PrimitiveTypeComponent"/>
>>>> <details key="kind" value="elementOnly"/>
>>>> </eAnnotations>
>>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>>> name="modelType" lowerBound="1"
>>>> eType="#//Primitive" defaultValueLiteral="Number">
>>>> <eAnnotations
>>>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>>>> <details key="kind" value="attribute"/>
>>>> <details key="name" value="modelType"/>
>>>> </eAnnotations>
>>>> </eStructuralFeatures>
>>>> </eClassifiers>
>>>>
>>>> which is is exported to XSD as:
>>>>
>>>> <xsd:complexType name="PrimitiveTypeComponent">
>>>> <xsd:complexContent>
>>>> <xsd:extension base="appmodel:Component">
>>>> <xsd:attribute ecore:default="Number"
>>>> ecore:unsettable="false" name="modelType" type="appmodel:Primitive"
>>>> use="required"/>
>>>> </xsd:extension>
>>>> </xsd:complexContent>
>>>> </xsd:complexType>
>>>>
>>>> If the user sets the modelType to Number then the serialized
>>>> instance looks like:
>>>>
>>>> <appmodel:component xsi:type="appmodel:PrimitiveTypeComponent"
>>>> name="ConversionRateResultField"/>
>>>>
>>>> which is invalid according to the schema since the modelType
>>>> attribute is flagged as "required". At the same time activating the
>>>> EMF validator returns OK. Hmmm... How is that?
>>> For unsettable features with a lower bound of 1, the feature must be
>>> eIsSet true to be valid. For non-unsettable features with a lower
>>> bound of 1, there must be a non-null value returned by eGet. There
>>> are statements about the state of the model instance in memory, not
>>> about its serialize form. In terms of serialization, I suppose one
>>> could argue that when mapping Ecore to XSD, we should map this case
>>> differently, perhaps marking it optional, using a real schema
>>> default, and specifying ecore:lowerBound="1" so it still produces the
>>> same Ecore when imported...
>>
>> Then... What's the solution? I want it to serialize the modelType no
>> matter what its value is.
>>
>>>>
>>>> If the user sets the modelType to something different than Number,
>>>> then everything is OK.
>>>>
>>>> Please help,
>>>> Adrian.
Re: seems like an "unsettable"-related serialization issue [message #431053 is a reply to message #431035] Thu, 25 June 2009 09:52 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Adrian,

Comments below.

Adrian Herscu wrote:
>
>
> Ed Merks wrote:
>> Adrian,
>>
>> If you don't care about the schema, try this option.
>
> Works :)
As if there were a doubt. :-P
> Still, I do not understand what you meant by saying "If you don't care
> about the schema". Of course I care about the schema, and now (thanks
> to that option), the instance is serialized correctly.
Your original question seemed more focused on schema conformance which
can be achieved either by changing how the schema looks to conform to
what's actually serialized or changing how the serialization looks to
conform to the existing schema. It wasn't clear which of the two was
your goal.
>
>>
>> /**
>> * Keep default content ( e.g. default attributes). This applies
>> to saving and converting contents to DOM.
>> * By default the default content is discarded.
>> * To save the default content, set this option to
>> <code>Boolean.TRUE</code>.
>> */
>> String OPTION_KEEP_DEFAULT_CONTENT = "KEEP_DEFAULT_CONTENT";
>>
>>
>> Adrian Herscu wrote:
>>>
>>>
>>> Ed Merks wrote:
>>>> Adrian,
>>>>
>>>> Comments below.
>>>>
>>>>
>>>> Adrian Herscu wrote:
>>>>> Hi all,
>>>>>
>>>>> I have the following definition in my ecore:
>>>>>
>>>>> <eClassifiers xsi:type="ecore:EClass"
>>>>> name="PrimitiveTypeComponent" eSuperTypes="#//Component">
>>>>> <eAnnotations
>>>>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>>>>> <details key="name" value="PrimitiveTypeComponent"/>
>>>>> <details key="kind" value="elementOnly"/>
>>>>> </eAnnotations>
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>>>> name="modelType" lowerBound="1"
>>>>> eType="#//Primitive" defaultValueLiteral="Number">
>>>>> <eAnnotations
>>>>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>>>>> <details key="kind" value="attribute"/>
>>>>> <details key="name" value="modelType"/>
>>>>> </eAnnotations>
>>>>> </eStructuralFeatures>
>>>>> </eClassifiers>
>>>>>
>>>>> which is is exported to XSD as:
>>>>>
>>>>> <xsd:complexType name="PrimitiveTypeComponent">
>>>>> <xsd:complexContent>
>>>>> <xsd:extension base="appmodel:Component">
>>>>> <xsd:attribute ecore:default="Number"
>>>>> ecore:unsettable="false" name="modelType"
>>>>> type="appmodel:Primitive" use="required"/>
>>>>> </xsd:extension>
>>>>> </xsd:complexContent>
>>>>> </xsd:complexType>
>>>>>
>>>>> If the user sets the modelType to Number then the serialized
>>>>> instance looks like:
>>>>>
>>>>> <appmodel:component xsi:type="appmodel:PrimitiveTypeComponent"
>>>>> name="ConversionRateResultField"/>
>>>>>
>>>>> which is invalid according to the schema since the modelType
>>>>> attribute is flagged as "required". At the same time activating
>>>>> the EMF validator returns OK. Hmmm... How is that?
>>>> For unsettable features with a lower bound of 1, the feature must
>>>> be eIsSet true to be valid. For non-unsettable features with a
>>>> lower bound of 1, there must be a non-null value returned by
>>>> eGet. There are statements about the state of the model instance
>>>> in memory, not about its serialize form. In terms of
>>>> serialization, I suppose one could argue that when mapping Ecore to
>>>> XSD, we should map this case differently, perhaps marking it
>>>> optional, using a real schema default, and specifying
>>>> ecore:lowerBound="1" so it still produces the same Ecore when
>>>> imported...
>>>
>>> Then... What's the solution? I want it to serialize the modelType no
>>> matter what its value is.
>>>
>>>>>
>>>>> If the user sets the modelType to something different than Number,
>>>>> then everything is OK.
>>>>>
>>>>> Please help,
>>>>> Adrian.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO] EFeatureMap support in DBStore
Next Topic:In-document non-containment references serialized as XML elements
Goto Forum:
  


Current Time: Thu Apr 25 13:27:25 GMT 2024

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

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

Back to the top