Details
Description
I used the castor code generator version 0.9.3.4 on an XML schema file which
contains the following type and element definition:
<xsd:simpleType name="IVRData">
<xsd:restriction base="xsd:hexBinary">
<xsd:minLength value="0"/>
<xsd:maxLength value="20"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="callData">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ivrData" type="adm-ctx:IVRData"
minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
When marshaling an XML file by using Castor, I entered the following Java code:
byte [] ivrData = {0x1, 0x4A};
CallData callData = new CallData();
callData.setIvrData(ivrData);
But the code generator produced the following XML file part:
<callData>
<ivrData>AUo=</ivrData>
</callData>
This XML file is definitely not schema conforming. I exptected an XML element
like the following:
<ivrData>014A</ivrData>
Vice versa, the Unmarshaller reads the wrong string 'AUo=' without throwing an
exception and transforms it to a byte array which does not have anything to do
with the original byte array. Additionally, when reading a valid hexBinary
string, the byte array read is totally different from the original hexBinary
string.
---------------------------------------------------------
Another comment/proposal:
In Java castor uses a byte array. But the allowed range of values from 0 to 255
is transferred to a signed byte value. In order to extract the correct hex
values from the byte, I have to know about the Java internal representation of
signs. Wouldn´t have it be better to define an 'array of short' and use allowed
values from 0 to 255 here?
Currently only base64 encoding is supporting. Accepting bug.