Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 335228 - @XmlType does not support built-in types
Summary: @XmlType does not support built-in types
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: David McCann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-24 13:17 EST by Paul Fullbright CLA
Modified: 2022-06-09 10:06 EDT (History)
1 user (show)

See Also:


Attachments
source for schema gen (894 bytes, application/zip)
2011-01-24 13:17 EST, Paul Fullbright CLA
no flags Details
Proposed fix. (1.97 KB, patch)
2011-02-04 13:36 EST, David McCann CLA
no flags Details | Diff
Supporting test case. (5.29 KB, patch)
2011-02-04 13:36 EST, David McCann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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