Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » generate Integer type from schema attribute
generate Integer type from schema attribute [message #419182] Mon, 12 May 2008 00:18 Go to next message
Will Horn is currently offline Will HornFriend
Messages: 265
Registered: July 2009
Senior Member
From
http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf,
the only schema type that maps to Integer is xs:int with
nillable="true". This is only possible for elements since attributes
don't use the nillable property.

I am wondering if there is a way to map an optional xs:int attribute in
xsd to an Integer in the Java code where a missing attribute in a
document would correspond to null. This would seem analogous to how a
missing optional xs:string attribute corresponds to a null String object.

I have a feeling it's possible, just haven't found the right trick ;o)

-Will
Re: generate Integer type from schema attribute [message #419186 is a reply to message #419182] Mon, 12 May 2008 01:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Will,

You'd really have to defineda new simple type and specify its
ecore:instanceClassName to be java.lang.Integer. For primitive types,
it seems better to make use the fact that the feature unsettable and
isSetX == false can be used to detect if the feature is missing.


Will Horn wrote:
> From
> http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf,
>
> the only schema type that maps to Integer is xs:int with
> nillable="true". This is only possible for elements since attributes
> don't use the nillable property.
>
> I am wondering if there is a way to map an optional xs:int attribute
> in xsd to an Integer in the Java code where a missing attribute in a
> document would correspond to null. This would seem analogous to how
> a missing optional xs:string attribute corresponds to a null String
> object.
>
> I have a feeling it's possible, just haven't found the right trick ;o)
>
> -Will


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: generate Integer type from schema attribute [message #419202 is a reply to message #419186] Mon, 12 May 2008 15:10 Go to previous messageGo to next message
Will Horn is currently offline Will HornFriend
Messages: 265
Registered: July 2009
Senior Member
Okay. It is not a big issue. There is also xs:integer which maps to
BigInteger if an object is really necessary.

However, I am curious - there is no way to use the IntObject EDataType
unless you have an element with type xs:int and xs:nillable="true"?

-Will

Ed Merks wrote:
> Will,
>
> You'd really have to defineda new simple type and specify its
> ecore:instanceClassName to be java.lang.Integer. For primitive types,
> it seems better to make use the fact that the feature unsettable and
> isSetX == false can be used to detect if the feature is missing.
>
>
> Will Horn wrote:
>> From
>> http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf,
>>
>> the only schema type that maps to Integer is xs:int with
>> nillable="true". This is only possible for elements since attributes
>> don't use the nillable property.
>>
>> I am wondering if there is a way to map an optional xs:int attribute
>> in xsd to an Integer in the Java code where a missing attribute in a
>> document would correspond to null. This would seem analogous to how
>> a missing optional xs:string attribute corresponds to a null String
>> object.
>>
>> I have a feeling it's possible, just haven't found the right trick ;o)
>>
>> -Will
Re: generate Integer type from schema attribute [message #419206 is a reply to message #419202] Mon, 12 May 2008 16:27 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Will,

Most people don't want to use wrapper types anyway. They take a lot
more storage. The "Object" versions of the data types are provided
purely to support nillable where it's obvious that the data is supposed
to include an additional value representing nil which is different from
just the absence of a value...


Will Horn wrote:
> Okay. It is not a big issue. There is also xs:integer which maps to
> BigInteger if an object is really necessary.
>
> However, I am curious - there is no way to use the IntObject EDataType
> unless you have an element with type xs:int and xs:nillable="true"?
>
> -Will
>
> Ed Merks wrote:
>> Will,
>>
>> You'd really have to defineda new simple type and specify its
>> ecore:instanceClassName to be java.lang.Integer. For primitive
>> types, it seems better to make use the fact that the feature
>> unsettable and isSetX == false can be used to detect if the feature
>> is missing.
>>
>>
>> Will Horn wrote:
>>> From
>>> http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf,
>>>
>>> the only schema type that maps to Integer is xs:int with
>>> nillable="true". This is only possible for elements since
>>> attributes don't use the nillable property.
>>>
>>> I am wondering if there is a way to map an optional xs:int attribute
>>> in xsd to an Integer in the Java code where a missing attribute in a
>>> document would correspond to null. This would seem analogous to
>>> how a missing optional xs:string attribute corresponds to a null
>>> String object.
>>>
>>> I have a feeling it's possible, just haven't found the right trick ;o)
>>>
>>> -Will


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: generate Integer type from schema attribute [message #419209 is a reply to message #419206] Mon, 12 May 2008 23:11 Go to previous messageGo to next message
Will Horn is currently offline Will HornFriend
Messages: 265
Registered: July 2009
Senior Member
Yeah, that is true. In my experience, though, for databinding purposes
it seems easier to deal with Objects and null than with isSetX. But I
am still getting the hang of databinding...

Ed Merks wrote:
> Will,
>
> Most people don't want to use wrapper types anyway. They take a lot
> more storage. The "Object" versions of the data types are provided
> purely to support nillable where it's obvious that the data is supposed
> to include an additional value representing nil which is different from
> just the absence of a value...
>
>
> Will Horn wrote:
>> Okay. It is not a big issue. There is also xs:integer which maps to
>> BigInteger if an object is really necessary.
>>
>> However, I am curious - there is no way to use the IntObject EDataType
>> unless you have an element with type xs:int and xs:nillable="true"?
>>
>> -Will
>>
>> Ed Merks wrote:
>>> Will,
>>>
>>> You'd really have to defineda new simple type and specify its
>>> ecore:instanceClassName to be java.lang.Integer. For primitive
>>> types, it seems better to make use the fact that the feature
>>> unsettable and isSetX == false can be used to detect if the feature
>>> is missing.
>>>
>>>
>>> Will Horn wrote:
>>>> From
>>>> http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf,
>>>>
>>>> the only schema type that maps to Integer is xs:int with
>>>> nillable="true". This is only possible for elements since
>>>> attributes don't use the nillable property.
>>>>
>>>> I am wondering if there is a way to map an optional xs:int attribute
>>>> in xsd to an Integer in the Java code where a missing attribute in a
>>>> document would correspond to null. This would seem analogous to
>>>> how a missing optional xs:string attribute corresponds to a null
>>>> String object.
>>>>
>>>> I have a feeling it's possible, just haven't found the right trick ;o)
>>>>
>>>> -Will
Re: generate Integer type from schema attribute [message #419213 is a reply to message #419209] Tue, 13 May 2008 01:47 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Will,

Yes, the whole concept of unsettable along with isSet and unset does
tend to bend people's minds a bit... But if you need to deal with large
amounts of data, wrapper objects can be a bit of a space killer


Will Horn wrote:
> Yeah, that is true. In my experience, though, for databinding
> purposes it seems easier to deal with Objects and null than with
> isSetX. But I am still getting the hang of databinding...
>
> Ed Merks wrote:
>> Will,
>>
>> Most people don't want to use wrapper types anyway. They take a lot
>> more storage. The "Object" versions of the data types are provided
>> purely to support nillable where it's obvious that the data is
>> supposed to include an additional value representing nil which is
>> different from just the absence of a value...
>>
>>
>> Will Horn wrote:
>>> Okay. It is not a big issue. There is also xs:integer which maps
>>> to BigInteger if an object is really necessary.
>>>
>>> However, I am curious - there is no way to use the IntObject
>>> EDataType unless you have an element with type xs:int and
>>> xs:nillable="true"?
>>>
>>> -Will
>>>
>>> Ed Merks wrote:
>>>> Will,
>>>>
>>>> You'd really have to defineda new simple type and specify its
>>>> ecore:instanceClassName to be java.lang.Integer. For primitive
>>>> types, it seems better to make use the fact that the feature
>>>> unsettable and isSetX == false can be used to detect if the feature
>>>> is missing.
>>>>
>>>>
>>>> Will Horn wrote:
>>>>> From
>>>>> http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf,
>>>>>
>>>>> the only schema type that maps to Integer is xs:int with
>>>>> nillable="true". This is only possible for elements since
>>>>> attributes don't use the nillable property.
>>>>>
>>>>> I am wondering if there is a way to map an optional xs:int
>>>>> attribute in xsd to an Integer in the Java code where a missing
>>>>> attribute in a document would correspond to null. This would
>>>>> seem analogous to how a missing optional xs:string attribute
>>>>> corresponds to a null String object.
>>>>>
>>>>> I have a feeling it's possible, just haven't found the right trick
>>>>> ;o)
>>>>>
>>>>> -Will


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Using EMF with an existing well-defined code
Next Topic:[DataBinding] Default validation in EMFUpdateValueStrategy
Goto Forum:
  


Current Time: Thu Sep 26 07:20:51 GMT 2024

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

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

Back to the top