Skip to main content



      Home
Home » Modeling » EMF » Unsettable and minOccurs="0" and nillable="0"
Unsettable and minOccurs="0" and nillable="0" [message #396438] Fri, 28 October 2005 07:16 Go to next message
Eclipse UserFriend
Hi Ed,
I am trying to understand when an unset method and ESet member is
generated using xml schema as the model. When I have this schema:
<xsd:complexType name="test">
<xsd:sequence>
<xsd:element name="name" type="xsd:string" nillable="false"/>
<xsd:element name="nameNil" type="xsd:string" nillable="true"/>
<xsd:element name="nameMin" type="xsd:string" minOccurs="0"/>
<xsd:element name="val" type="xsd:int" nillable="false"/>
<xsd:element name="valNil" type="xsd:int" nillable="true"/>
<xsd:element name="valMin" type="xsd:int" minOccurs="0"/>
<xsd:element name="dec" type="xsd:decimal" nillable="false"/>
<xsd:element name="decimalNil" type="xsd:decimal" nillable="true"/>
<xsd:element name="decimalMin" type="xsd:decimal" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>

I get unSet/isSet methods for
nameNil, decimalNil, val, valNil, valMin

in addition emf generates the ESet members for these members. There are
two things which I don't understand:
why unSet is generated for val?
why no unSet is generated for nameMin and valMin?

Did I miss something in the schema?

Another related question I have if it's possible to distinguish (in the
generated code) between minOccurs="0" and the java null value when these
are combined? For example:
<xsd:element name="valMinNil" type="xsd:int" minOccurs="0" nillable="true"/>

I do not actually have that much of a usecase for this but am just
wondering.

I tried searching the newsgroup for a similar discussion but couldn't
find anything.

Btw I am using emf 2.1

gr. Martin
Re: Unsettable and minOccurs="0" and nillable="0" [message #396439 is a reply to message #396438] Fri, 28 October 2005 07:38 Go to previous message
Eclipse UserFriend
Martin,

The rules are quite complicated and are also affected by whether the
resulting Java type is primitive and by the default value. The rules
are designed to ensure that what's read in will write out the same way
or at least in a valid way.


Martin Taal wrote:

> Hi Ed,
> I am trying to understand when an unset method and ESet member is
> generated using xml schema as the model. When I have this schema:
> <xsd:complexType name="test">
> <xsd:sequence>
> <xsd:element name="name" type="xsd:string"
> nillable="false"/>
> <xsd:element name="nameNil" type="xsd:string"
> nillable="true"/>
> <xsd:element name="nameMin" type="xsd:string"
> minOccurs="0"/>
> <xsd:element name="val" type="xsd:int" nillable="false"/>
> <xsd:element name="valNil" type="xsd:int" nillable="true"/>
> <xsd:element name="valMin" type="xsd:int" minOccurs="0"/>
> <xsd:element name="dec" type="xsd:decimal"
> nillable="false"/>
> <xsd:element name="decimalNil" type="xsd:decimal"
> nillable="true"/>
> <xsd:element name="decimalMin" type="xsd:decimal"
> minOccurs="0"/>
> </xsd:sequence>
> </xsd:complexType>
>
> I get unSet/isSet methods for
> nameNil, decimalNil, val, valNil, valMin
>
> in addition emf generates the ESet members for these members. There are
> two things which I don't understand:
> why unSet is generated for val?

This will map to the primitive int type. We won't be able to tell the
default 0, from being set to 0, and we need the feature to be considered
set when it has the zero value so that the required value will be
written out.

> why no unSet is generated for nameMin and valMin?

Since the nameMin is optional, when it has the default null value, we
won't write anything out, and that's valid. Similarly for valMin: when
it has default value 0, we won't write anything out and that's valid.

>
>
> Did I miss something in the schema?
>
> Another related question I have if it's possible to distinguish (in the
> generated code) between minOccurs="0" and the java null value when these
> are combined? For example:
> <xsd:element name="valMinNil" type="xsd:int" minOccurs="0"
> nillable="true"/>
>
One half of the question seems to be about the meta model the other half
about the instance behavior. The lowerBound of the EAttribute will be 0
and since it will be unsettable, you can set the value to null and have
be considered set.

> I do not actually have that much of a usecase for this but am just
> wondering.

Inquiring minds want to know. ;-)

>
> I tried searching the newsgroup for a similar discussion but couldn't
> find anything.

No one else was quite so inquisitive. ;-)

>
> Btw I am using emf 2.1
>
> gr. Martin
Previous Topic:Avoid a double identical object or with the same name in the runtime of EMF
Next Topic:uniqueness using xsd:ID
Goto Forum:
  


Current Time: Sat Jul 26 20:01:58 EDT 2025

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

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

Back to the top