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的更多相关文章

  1. JAXB - XML Schema Types, Date and Time

    JAXB binds all three of the schema types xsd:date, xsd:time and xsd:dateTime to XMLGregorianCalendar ...

  2. JAXB - XML Schema Types, Defining Subtypes

    Although object orientation isn't a key feature of XML or the XML Schema language, it's still possib ...

  3. JAXB - XML Schema Types, Defining an Enumeration

    If you want a data type that enumerates discrete values you should use a restriction of the schema t ...

  4. JAXB - XML Schema Types, Defining Types for XML Elements With Content

    Content: A Value The content of an XML element may be some value, or one or more subordinate element ...

  5. JAXB - XML Schema Types, Defining Types for XML Elements Without Content

    Types for XML elements are constructed using xsd:complexType, even if they do not have content. The ...

  6. XML Schema and XMLspy notes

    Introduction An xml documents consists of elements, attributes and text. There are two structures in ...

  7. 【转】XSD (xml Schema Definition)

    来自:http://www.cnblogs.com/newsouls/archive/2011/10/28/2227765.html Xml Schema的用途 1.  定义一个Xml文档中都有什么元 ...

  8. [BTS] System.Xml.Schema.XmlSchemaException: The complexType has already been declared when generate IDoc schema.

    I use wcf-sap adapter for generate the schema of IDoc that named "YHREMPMASTER". but throw ...

  9. Xml Schema的用途

    Xml Schema的用途 1.  定义一个Xml文档中都有什么元素 2.  定义一个Xml文档中都会有什么属性 3.  定义某个节点的都有什么样的子节点,可以有多少个子节点,子节点出现的顺序 4.  ...

随机推荐

  1. 从代码都发布遇到的问题总结(C#调用非托管dll文件,部署项目) 转

    http://www.cnblogs.com/Purple_Xiapei/archive/2012/06/30/2570928.html

  2. 在生成 Visual c + + 2005年或从 DLL 文件中使用 CString 派生的类的 Visual c + +.net 应用程序时,您可能会收到 LNK2019 错误消息

    http://support.microsoft.com/kb/309801

  3. org.springframework.web.filter.DelegatingFilterProxy的理解

    org.springframework.web.filter.DelegatingFilterProxy可以将filter交给spring管理. 我们web.xml中配置filter时一般采用下面这种 ...

  4. 利用XSD配合XSLT產出特定格式Word檔案 -摘自网络

    利用類別產生XSD檔 產出XSD檔的目的在於提供Word樣板設計之資料框架 在此使用微軟提供之XML Schema Definition Tool (Xsd.exe)工具產生XSD檔 1. 定義類別 ...

  5. Java HashMap 核心源码解读

    本篇对HashMap实现的源码进行简单的分析. 所使用的HashMap源码的版本信息如下: /* * @(#)HashMap.java 1.73 07/03/13 * * Copyright 2006 ...

  6. [C语言 - 13] 运算符

    算术运算符 运算符的优先级 括号 > 正负 > 数学运算 > 位运算 > 数学对比 > 逻辑对比 > 条件运算 > 赋值运算   A.赋值运算符 复合赋值运算 ...

  7. BAT及各大互联网公司2014前端笔试面试题:HTML/CSS篇

    BAT及各大互联网公司2014前端笔试面试题:HTML/CSS篇 2014/08/03 · Web前端, 开发 · CSS, HTML, 技术面试 分享到: 188 MongoDB集群之分片技术应用 ...

  8. 低级错误之Hbm中类型不一致错误

    Myeclipse将数据库中的长整形生成为Bigdecimal类型,实际应该生成为Long.导致保存的时候报错.

  9. .NET自带IOC容器MEF之初体验

    .NET自带IOC容器MEF之初体验   本文主要把MEF作为一种IOC容器进行讲解,.net中可用的IOC容器非常多,如 CastleWindsor,Unity,Autofac,ObjectBuil ...

  10. SQL 正则表达式使模式匹配和数据提取变得更容易

    SQL Server 2005 正则表达式使模式匹配和数据提取变得更容易 David Banister 本文讨论: 使用正则表达式进行高效的 SQL 查询 SQL Server 2005 对正则表达式 ...