Community
Participate
Working Groups
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>
Additional Info public class LinkAdapter extends XmlAdapter<String, Object> { ... }
Created attachment 216528 [details] Proposed fix.
Created attachment 216529 [details] Supporting test cases.
Created attachment 216531 [details] Supporting test cases.
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
Fix checked into 2.5, revision: 11579
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink