Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Xsd to Ecore Mapping: attributes with simple types
Xsd to Ecore Mapping: attributes with simple types [message #1624113] Thu, 19 February 2015 15:19 Go to next message
Sebastian Zitzelsberger is currently offline Sebastian ZitzelsbergerFriend
Messages: 33
Registered: August 2014
Member
Hi,

I need to map an xsd metamodel to an ecore metamodel.
I have complextypes that have attributes like this:

<xs:attribute name="ranodmInt" type="xs:integer"/>
<xs:attribute name="ranodmdouble" type="xs:double"/>


By default those attributes will be mapped to Eattributes and their type is determined by the table found in this document.


For example:
xs:integer will be mapped to EDataType: name=Integer instanceClass=java.math.BigInteger

xs:double will be mapped to EDataType: name=Double instanceClass=double

The map further provides information to change the mapping.
xs:integer with nillable="true" will be mapped to EDataType: name=IntObject instanceClass=java.lang.Integer.


As my attributes all are optional (i.e. they don't have use="required") and thus have to support NULL values, i'd like them to be mapped to ObjectTypes in Java (instanceClass) instead of simple types (Integer instead of int, Double instead of double etc.).

However i cannot find a way to do so, as attributes don't support the nillable attribut and use="optional" did not change the mapping.

Is there a way to do this?

[Updated on: Thu, 19 February 2015 16:49]

Report message to a moderator

Re: Xsd to Ecore Mapping: attributes with simple types [message #1624637 is a reply to message #1624113] Thu, 19 February 2015 23:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29552
Registered: July 2009
Senior Member
Sebastian,

Don't these primitive-typed attribute also result in unsettable features
such that you can check isSetRandomInt to distinguish whether the
attribute was present in the XML?

You should also be able to use ecore: annotations to influence the type.
If you're not sure how, try changing the Ecore model to what you want
manually, and, via the GenModel, export it to XML Schema and look at
those annotations.


On 19.02.2015 16:19, Sebastian Zitzelsberger wrote:
> Hi,
>
> I need to map an xsd metamodel to an ecore metamodel.
> I have complextypes that have attributes like this:
>
> <xs:attribute name="ranodmInt" type="xs:integer"/>
> <xs:attribute name="ranodmdouble" type="xs:double"/>
>
>
> By default those attributes will be mapped to Eattributes and their type
> is determined by the table found in
> https://www.eclipse.org/modeling/emf/docs/overviews/XMLSchemaToEcoreMapping.pdf
>
>
>
> For example:
> xs:integer will be mapped to EDataType: name=Integer
> instanceClass=java.math.BigInteger
>
> xs:double will be mapped to EDataType: name=Double instanceClass=double
>
> The map further provides information to change the mapping.
> xs:integer with nillable="true" will be mapped to EDataType:
> name=IntObject instanceClass=java.lang.Integer.
>
>
> As my attributes all are optional (i.e. they don't have use="required"),
> i'd like them to be mapped to ObjectTypes instead of simple types
> (Integer instead of int, Double instead of double etc.).
>
> However i cannot find a way to do so, as attributes don't support the
> nillable attribut and use="optional" did not change the mapping.
>
> Is there a way to do this?
>
>
Re: Xsd to Ecore Mapping: attributes with simple types [message #1634979 is a reply to message #1624637] Wed, 25 February 2015 14:59 Go to previous message
Sebastian Zitzelsberger is currently offline Sebastian ZitzelsbergerFriend
Messages: 33
Registered: August 2014
Member
Hi Ed,

Thanks for your response.

Yes, i can use the eIsSet method. But I still wan't the value to be NULL when i load the model with my ecore-metamodel without handling it explicitely.
I tried your suggestion to generate an xsd from an ecore model and see what it produces. however it simply takes the short cut and uses the ecore-Types alltogether instead of the xsd-types.
<xsd:attribute name="int" type="ecore:EIntegerObject"/>
<xsd:attribute name="bigInt" type="ecore:EBigInteger"/>

I guess I'll have to create the ecore-metamodel statically then, as i am not the owner of the xsd-metamodel and thus have limited influcence which types they use.

[Updated on: Wed, 25 February 2015 15:06]

Report message to a moderator

Previous Topic:Problem with an XML schema
Next Topic:Problem unmarshalling to Java object
Goto Forum:
  


Current Time: Tue Sep 25 17:26:24 GMT 2018

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

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

Back to the top