Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 335228

Summary: @XmlType does not support built-in types
Product: z_Archived Reporter: Paul Fullbright <paul.fullbright>
Component: EclipselinkAssignee: David McCann <david.mccann>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: david.mccann
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
source for schema gen
none
Proposed fix.
none
Supporting test case. none

Description Paul Fullbright CLA 2011-01-24 13:17:01 EST
Created attachment 187455 [details]
source for schema gen

Take the following example (see attachment for more):

@XmlType
public class EmploymentPeriod {
	
	@XmlElement
	public MyDate startDate;
	
	@XmlElement
	public MyDate endDate;
}

@XmlType(namespace="http://www.w3.org/2001/XMLSchema", name="date")
public class MyDate {
	
	@XmlValue
	public String value;
}


The reference implementation generates the following schema snippet:

  <xs:complexType name="employmentPeriod">
    <xs:sequence>
      <xs:element name="startDate" type="xs:date" minOccurs="0"/>
      <xs:element name="endDate" type="xs:date" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>

where "xs" refers to the schema for schema namespace.

MOXy generates the following schema snippet:

   <xsd:import schemaLocation="schema1.xsd" namespace="http://www.w3.org/2001/XMLSchema"/>
   <xsd:complexType name="employmentPeriod">
      <xsd:sequence>
         <xsd:element name="startDate" type="ns1:date" minOccurs="0"/>
         <xsd:element name="endDate" type="ns1:date" minOccurs="0"/>
      </xsd:sequence>
   </xsd:complexType>

where "ns1" refers to the imported schema, which is also generated thusly:

   <xsd:simpleType name="date">
      <xsd:restriction base="xsd:string"/>
   </xsd:simpleType>
Comment 1 David McCann CLA 2011-02-04 13:36:23 EST
Created attachment 188347 [details]
Proposed fix.
Comment 2 David McCann CLA 2011-02-04 13:36:46 EST
Created attachment 188348 [details]
Supporting test case.
Comment 3 David McCann CLA 2011-02-04 13:44:04 EST
Reviewed by:  blaise.doughan@oracle.com
Tests:  all unit tests pass as expected; jaxb/xmltype/XmlTypeTestsCases
Revision:  8938
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:06:33 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink