码迷,mamicode.com
首页 > 其他好文 > 详细

JAXB - XML Schema Types, Binary Data

时间:2016-05-18 14:31:17      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

Data that has no "natural" representation with printable characters must, for inclusion in an XML file, still be represented in printable characters. The simple technique for this consists in converting the binary byte values to their hexadecimal representations. The XML Schema datatype to use in this case is xsd:hexBinary. A sample schema declaration is shown below.

<xsd:complexType name="BinaryType">
    <xsd:sequence>
        <xsd:element name="data" type="xsd:hexBinary"/>
    </xsd:sequence>
</xsd:complexType>

The Java class produced by JAXB contains a convenient pair of getter and setter methods for accessing the instance variable (called data) that stores the binary data. Its type and the type for passing the binary data is byte[]. All conversions are handled by JAXB.

public class BinaryType {

    protected byte[] data;

    public byte[] getData() {
        return data;
    }

    public void setData(byte[] value) {
        this.data = ((byte[]) value);
    }
}

 

JAXB - XML Schema Types, Binary Data

标签:

原文地址:http://www.cnblogs.com/huey/p/5505029.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!