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

Bug 366259

Summary: Schema Gen: Wrong schema generated for collection property with predicate
Product: z_Archived Reporter: Blaise Doughan <blaise.doughan>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: david.twelves, matt.macivor, rick.barkhouse
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch - code changes
none
Patch - new tests
none
Patch - changes to existing test cases
none
Patch - new tests none

Description Blaise Doughan CLA 2011-12-09 16:17:36 EST
For the class;

  @XmlRootElement
  @XmlType(propOrder = {"id", "name", "phoneNumbers"})
  @XmlAccessorType(XmlAccessType.FIELD)
  public class Customer {

    private String id;
    private String name;

    @XmlJavaTypeAdapter(LinkAdapter.class)
    @XmlPath("atom:link[@rel='phone']/@href")
    private List<PhoneNumber> phoneNumbers = new ArrayList<PhoneNumber>();

  }

The following XML schemas are incorrectly generated:

 <?xml version="1.0" encoding="UTF-8"?>
 <xsd:schema xmlns:atom="http://www.w3.org/2005/Atom"  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:import schemaLocation="schema2.xsd" namespace="http://www.w3.org/2005/Atom"/>
   <xsd:complexType name="customer">
      <xsd:sequence>
         <xsd:element name="id" type="xsd:string" minOccurs="0"/>
         <xsd:element name="name" type="xsd:string" minOccurs="0"/>
         <xsd:element ref="atom:link" minOccurs="0"/>
      </xsd:sequence>
   </xsd:complexType>
   <xsd:element name="customer" type="customer"/>
 </xsd:schema>
 <?xml version="1.0" encoding="UTF-8"?>
 <xsd:schema xmlns:ns0="http://www.w3.org/2005/Atom" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/2005/Atom">
   <xsd:element name="link">
      <xsd:complexType>
         <xsd:sequence/>
         <xsd:attribute name="href">
            <xsd:simpleType>
               <xsd:list itemType="xsd:string"/>
            </xsd:simpleType>
         </xsd:attribute>
         <xsd:attribute name="rel" type="xsd:string"/>
      </xsd:complexType>
   </xsd:element>
 </xsd:schema>

The XML schemas should look like:

 <?xml version="1.0" encoding="UTF-8"?>
 <xsd:schema xmlns:atom="http://www.w3.org/2005/Atom"  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:import schemaLocation="schema2.xsd" namespace="http://www.w3.org/2005/Atom"/>
   <xsd:complexType name="customer">
      <xsd:sequence>
         <xsd:element name="id" type="xsd:string" minOccurs="0"/>
         <xsd:element name="name" type="xsd:string" minOccurs="0"/>
         <xsd:element ref="atom:link" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
   </xsd:complexType>
   <xsd:element name="customer" type="customer"/>
 </xsd:schema>
 <?xml version="1.0" encoding="UTF-8"?>
 <xsd:schema xmlns:ns0="http://www.w3.org/2005/Atom" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/2005/Atom">
   <xsd:element name="link">
      <xsd:complexType>
         <xsd:sequence/>
         <xsd:attribute name="href" type="xsd:string"/>
         <xsd:attribute name="rel" type="xsd:string"/>
      </xsd:complexType>
   </xsd:element>
 </xsd:schema>

Additional Info:

 public class LinkAdapter extends XmlAdapter<String, Object> {
    ...
 }
Comment 1 Rick Barkhouse CLA 2012-05-04 14:53:01 EDT
Created attachment 215095 [details]
Patch - code changes
Comment 2 Rick Barkhouse CLA 2012-05-04 14:53:22 EDT
Created attachment 215096 [details]
Patch - new tests
Comment 3 Rick Barkhouse CLA 2012-05-04 14:53:43 EDT
Created attachment 215097 [details]
Patch - changes to existing test cases
Comment 4 Rick Barkhouse CLA 2012-05-04 15:24:28 EDT
Created attachment 215098 [details]
Patch - new tests
Comment 5 Matt MacIvor CLA 2012-05-24 15:58:34 EDT
Attached patch checked into SVN into 2.4 and Trunk streams.

Reviewed by Blaise Doughan
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:27:39 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink