Data that have no "natural" representation with printable characters must, for inclusion in a XML file, still be represent ed in printable characters. The simple technique-consists in converting, the binary byte values to their hexadecimal representations. The XML Schema datatype to use of the IS xsd:hexBinary
. A Sample Schema declaration is shown below.
< xsd:complextype name = "Binarytype" > < xsd:sequence > < xsd:element name = "Data" type =" Xsd:hexbinary " Span style= "color: #0000ff;" >/> </ xsd:sequence > </ xsd:complextype Span style= "color: #0000ff;" >>
The Java class produced by JAXB contains a convenient pair of getters and setters methods for accessing the instance Vari Able (called data
) that stores the binary data. Its type and the type for passing the binary data is byte[]
. All conversions is handled by JAXB.
Public class binarytype { protectedbyte[] data; Public byte [] GetData () { return data; } Public void setData (byte[] value) { this. Data = ((byte[]) value);} }
Jaxb-xml Schema Types, Binary Data