Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 366255 - Schema Gen: Wrong schema generated for two predicate mappings that share an element/attribute combination
Summary: Schema Gen: Wrong schema generated for two predicate mappings that share an ...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-09 16:11 EST by Blaise Doughan CLA
Modified: 2022-06-09 10:22 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix. (3.68 KB, patch)
2012-05-30 15:55 EDT, David McCann CLA
no flags Details | Diff
Supporting test cases. (10.78 KB, patch)
2012-05-30 15:55 EDT, David McCann CLA
no flags Details | Diff
Supporting test cases. (11.80 KB, patch)
2012-05-30 15:58 EDT, 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 Blaise Doughan CLA 2011-12-09 16:11:39 EST
Given the following class:

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

    private String id;
    private String name;

    @XmlJavaTypeAdapter(LinkAdapter.class)
    @XmlPath("atom:link[@rel='address']/@href")
    private Address address;

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

  }

Currently 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" type="xsd:string"/>
         <xsd:attribute name="href" type="xsd:string"/>
         <xsd:attribute name="rel" type="xsd:string"/>
      </xsd:complexType>
   </xsd:element>
 </xsd:schema>

The schemas should look as follows:

 <?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>
Comment 1 Blaise Doughan CLA 2011-12-09 16:13:26 EST
Additional Info

public class LinkAdapter extends XmlAdapter<String, Object> {
   ...
}
Comment 2 David McCann CLA 2012-05-30 15:55:32 EDT
Created attachment 216528 [details]
Proposed fix.
Comment 3 David McCann CLA 2012-05-30 15:55:44 EDT
Created attachment 216529 [details]
Supporting test cases.
Comment 4 David McCann CLA 2012-05-30 15:58:44 EDT
Created attachment 216531 [details]
Supporting test cases.
Comment 5 David McCann CLA 2012-05-31 10:28:15 EDT
Fix checked into 2.4, Revision:  11568
Reviewed by:  blaise.doughan@oracle.com 
Tests: all unit tests pass as expected;  jaxb.annotations.xmlpath.predicate.adapter.CustomerTestCases
Comment 6 David McCann CLA 2012-05-31 13:54:22 EDT
Fix checked into 2.5, revision: 11579
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:16:14 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 8 Eclipse Webmaster CLA 2022-06-09 10:22:32 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink