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

Bug 345776

Summary: Schema Validation errors when mapping Byte[]
Product: z_Archived Reporter: Rick Barkhouse <rick.barkhouse>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
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:16:34 EDT
Given the following object:

@XmlRootElement
public class Employee {
   public Byte[] bigBytes = new Byte[] {23,1,112,12,1,64,1,14,3,2};
}

The JAXB RI and EclipseLink generate slightly different schemas (note xs:byte vs. xs:base64binary, and the unused byteArray type):

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:ns0="http://jaxb.dev.java.net/array" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://jaxb.dev.java.net/array">
   <xsd:complexType name="byteArray">
      <xsd:sequence>
         <xsd:element name="item" type="xsd:byte" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
   </xsd:complexType>
</xsd:schema>
, <?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:element name="bigBytes" type="xsd:base64Binary" 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>
]

This results in validation errors for each individual Byte elements:

ERROR
cvc-datatype-valid.1.2.1: '23' is not a valid value for 'base64Binary'.
ERROR
cvc-type.3.1.3: The value '23' of element 'bigBytes' is not valid.
ERROR
cvc-datatype-valid.1.2.1: '1' is not a valid value for 'base64Binary'.
ERROR
cvc-type.3.1.3: The value '1' of element 'bigBytes' is not valid.
ERROR
cvc-datatype-valid.1.2.1: '112' is not a valid value for 'base64Binary'.
ERROR
cvc-type.3.1.3: The value '112' of element 'bigBytes' is not valid.
...
Comment 1 Denise Smith CLA 2011-06-27 15:40:07 EDT
Created attachment 198680 [details]
Proposed changes and test
Comment 2 Denise Smith CLA 2011-06-28 11:21:28 EDT
Checked in changes to SDOProperty, AnnotationsProcessor and Helper to handle Byte[] properly.
Comment 3 Denise Smith CLA 2011-08-30 16:09:16 EDT
Changed target milestone to 2.3.1 and also checked in to that stream.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:34:55 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink