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

Bug 345774

Summary: Schema Generation differs from RI for @XmlAnyElement Object[]
Product: z_Archived Reporter: Rick Barkhouse <rick.barkhouse>
Component: EclipselinkAssignee: Denise Smith <denise.mahar>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: denise.mahar, eclipselink.oxm-inbox
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed changes and test none

Description Rick Barkhouse CLA 2011-05-13 15:11:08 EDT
Given the following object:

@XmlRootElement
public class Employee {
   @XmlAnyElement
   public Object[] anyObjects;
}

The JAXB RI will generate an unbounded <any> element, but EclipseLink does not.

JAXB Context: class com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl
[<?xml version="1.0" standalone="yes"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="employee" type="employee"/>

  <xs:complexType name="employee">
    <xs:sequence>
      <xs:element name="first-name" type="xs:string" minOccurs="0"/>
      <xs:element name="last-name" type="xs:string" minOccurs="0"/>
      <xs:element name="bigBytes" type="xs:byte" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
      <xs:any processContents="skip" namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="id" type="xs:int" use="required"/>
  </xs:complexType>
</xs:schema>

]

JAXB Context: class org.eclipse.persistence.jaxb.JAXBContext
[<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:complexType name="employee">
      <xsd:sequence>
         <xsd:element name="first-name" type="xsd:string" minOccurs="0"/>
         <xsd:element name="last-name" type="xsd:string" minOccurs="0"/>
         <xsd:any processContents="skip" namespace="##other"/>
      </xsd:sequence>
      <xsd:attribute name="id" type="xsd:int" use="required"/>
   </xsd:complexType>
   <xsd:element name="employee" type="employee"/>
</xsd:schema>
]
<?xml version="1.0" encoding="UTF-8"?>
<employee id="1221">
   <first-name>Dan</first-name>
   <last-name>Savage</last-name>
</employee>

This results in the following schema validation error:

ERROR
cvc-complex-type.2.4.b: The content of element 'employee' is not complete. One of '{WC[##other:""]}' is expected.
Comment 1 Denise Smith CLA 2011-05-26 09:44:00 EDT
Note that the difference only occurs when the XmlAnyElement in on an array.  When it is specified on a List<Object> both implementations behave the same and there is a minOccurs=0 specified.
Comment 2 Denise Smith CLA 2011-05-26 11:56:57 EDT
Created attachment 196676 [details]
Proposed changes and test
Comment 3 Denise Smith CLA 2011-06-07 13:29:25 EDT
Checked in changes to Schema Generation as well as fixing the Mappings generator to properly handle the Object[] case.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:04:13 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink