Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 441901 - Non-default type mapping ecore:type is not taken into account in xs:list mapping
Summary: Non-default type mapping ecore:type is not taken into account in xs:list mapping
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: XML/XMI (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows Vista
: P3 major with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Ed Merks CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-16 05:25 EDT by Gordan Vosicki CLA
Modified: 2018-12-20 04:37 EST (History)
0 users

See Also:


Attachments
Example where the xs:list using FaceType is not msapped to int or Integer. (178.87 KB, application/xml)
2014-08-16 05:25 EDT, Gordan Vosicki CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gordan Vosicki CLA 2014-08-16 05:25:24 EDT
Created attachment 246061 [details]
Example where the xs:list using FaceType is not msapped to int or Integer.

ecore:type="ecore:Exxxxx" can be used in attributes and types to force non-default mapping. This is particularly useful in not-so-well-designed schemas using too wide types. This works well for simple attributes, but does not work for lists:

	<xs:simpleType name="FaceType" ecore:type="ecore:EInt">
		<xs:list itemType="xs:integer" ecore:type="ecore:EInt"/>
	</xs:simpleType>

A typical example is xs:integer which maps by default to BigDecimal. In many cases, it is preferable to map to int or long. In the example above, "FaceType" is still mapped to  list of java.lang.BigInteger.

BTW, it would be *much* nicer to be able to put such definitions in an external file, like it is possible with JAXB.
Comment 1 Gordan Vosicki CLA 2015-03-01 15:00:21 EST
The same bug is present in restrictions:

	<xs:simpleType name="zoneNumberType" ecore:type="ecore:EInt">
		<xs:restriction base="xs:positiveInteger" ecore:type="ecore:EInt">
			<xs:minInclusive value="1"/>
			<xs:maxInclusive value="99"/>
		</xs:restriction>
	</xs:simpleType>

The "zoneNumberType" gets implemented as "BigInteger" instead of "int".
Comment 2 Ed Merks CLA 2018-11-27 03:45:19 EST
The enhancement is committed to master:

https://git.eclipse.org/c/xsd/org.eclipse.xsd.git/commit/?id=afe6a50f0bb4de1b7192a57dfcb229ebda8213a5

Both the restriction element and list element of a simple type now support ecore:type to override the value of the base attribute or the itemType attribute.

In your sample, the use of ecore:type on the simpleType element itself makes no sense. Here you are always defining a new data type and you can only control things like the name and the instance class/type of the corresponding EDataType.  

On a restriction element or list element you are referencing some other type, and here it makes sense to be able to redirect/override it.

Note that in your sample, the use of ecore:type on the restriction below is not sensible and will lead to an Ecore model with validation constraint problem (because the extended metadata annotations are validated as of EMF 2.15):

	<xs:element name="F">
		<xs:simpleType ecore:type="ecore:EInt">
			<xs:restriction base="FaceType" ecore:type="ecore:EInt">
				<xs:minLength value="3"/>
				<xs:maxLength value="4"/>
			</xs:restriction>
		</xs:simpleType>
	</xs:element>

In particular here you redirect the base to a type that is not a list type so the length facets do no sensibly apply.

Of course with the FaceType being generated as a list of Integer, you'd not want/need this ecore:type annotation here and would want to leave the restriction to constrain the size of the list.
Comment 3 Ed Merks CLA 2018-12-20 04:37:45 EST
The changes are available in the 2.16 release:

http://download.eclipse.org/modeling/emf/emf/builds/release/2.16