If you want a data type that enumerates discrete values you should use a restriction of the schema type xsd:string, enumerating all the values as you would in a Java enum type.

<xsd:simpleType name="IXLType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="eStwA"/>
<xsd:enumeration value="eStwS"/>
<xsd:enumeration value="SpDrL"/>
<xsd:enumeration value="SpDrS"/>
<xsd:enumeration value="VGS80"/>
</xsd:restriction>
</xsd:simpleType>

The JAXB compiler generates a Java enum, but the names of the enum constants are transformed so that they conform to the style commonly accepted in the Java community. Below is the (somewhat shortened) Java code.

public enum IXLType {

    E_STW_A("eStwA"),
E_STW_S("eStwS"),
SP_DR_L("SpDrL"),
SP_DR_S("SpDrS"),
VGS_80("VGS80"); private final String value; IXLType(String v) {
value = v;
} public String value() {
return value;
}
}

If you want to use the original identifiers as enum constant names, you may resort to an explicit specification of the binding, for each enum constant name, as shown below.

<xsd:simpleType name="IXLType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="eStwA">
<xsd:annotation>
<xsd:appinfo>
<jxb:typesafeEnumMember name="eStwA"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
...
</xsd:restriction>
</xsd:simpleType>

The generated enum class will now contain enum constant names that exactly match the original strings.

public enum IXLType {

    eStwA,
eStwS,
SpDrL,
SpDrS,
VGS80; public String value() {
return name();
}
...
}

There is no need now to store the XML representations along with each enum constant, and method value may now simply call name() to obtain the stringified value.

JAXB - XML Schema Types, Defining an Enumeration的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. JAXB - XML Schema Types, Date and Time

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

  5. JAXB - XML Schema Types, Binary Data

    Data that has no "natural" representation with printable characters must, for inclusion in ...

  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. C#与XML Schema的问题

    http://bbs.csdn.net/topics/50493564 weileily: 用XmlSchema.Read方法读取了一个xsd文件,请问如何遍历检索器中的ComplexType与Sim ...

  9. XML Schema的基本语法(转)

    XML Schema的基本语法(转) XSDL(XML Schema定义语言)由元素.属性.命名空间和XML文档种的其他节点构成的. 一.XSD中的元素 XSD文档至少要包含:schema根元素和XM ...

随机推荐

  1. Vijos1404 遭遇战 最短路,dijkstra,堆

    P1404遭遇战 标签:[显示标签]     背景 你知道吗,SQ Class的人都很喜欢打CS.(不知道CS是什么的人不用参加这次比赛). 描述 今天,他们在打一张叫DUSTII的地图,万恶的恐怖分 ...

  2. gimp之旅

    随着大学生活的告一段落,新的征途已经开始了.鉴于本人如此喜欢旅游,如此喜欢拍照,如此喜欢处理图片,所以打算在照片处理上下点功夫.总所周知,图像处理软件大牛级的就属windows下的photoshop以 ...

  3. 【原创】tcp协议那块一些点(想到了再加)

    1.3次握手 4次握手 2.那张状态图,FIN_WAIT主动关闭方,CLOSE_WAIT被动关闭方 主动关闭方发出FIN后进入FIN_WAIT,FIN_WAIT方收到了ACK和FIN,发出了ACK,则 ...

  4. HDFS的shell操作

    bin/hadoop命令操作: namenode -format 格式化文件系统 fs(缩写:FileSystem) 运行一个文件系统的用户客户端 bin/hadoop fs常用命令操作: -ls h ...

  5. POJ-3744 Scout YYF I 概率DP

    题目链接:http://poj.org/problem?id=3744 简单的概率DP,分段处理,遇到mine特殊处理.f[i]=f[i-1]*p+f[i-2]*(1-p),i!=w+1,w为mine ...

  6. 第二十章、启动流程、模块管理与 Loader grub

    Boot Loader: Grub 『 boot loader 是加载核心的重要工具』!没有 boot loader 的话,那么 kernel 根本就没有办法被系统加载! boot loader 的两 ...

  7. Linux web工程部署远程必备软件安装

    一.序 最近在将程序往linux上面部署,特此记录下部署步骤,待以后参考. web工程部署必备软件为:JDK.tomcat.数据库软件(oracle或mysql),远程监控.上传下载必备软件:VNC. ...

  8. mac不可或缺的套件管理器Homebrew

    Homebrew 1.简介 可以帮助我们快速安装软件, 如 brew install svn 快速卸载软件 , 如  brew uninstall svn 2.下载 打开终端, /usr/bin/ru ...

  9. ASP.NET 学习的总结

    应用程序域 使用.Net建立的可执行程序*.exe,并没有直接承载到进程当中,而是承载到应用程序域(AppDomain)当中.应用程序域是.Net引入的一个新概念,它比进程所占用的资源要少,可以被看做 ...

  10. 【转】Android studio 导入github工程

    http://blog.csdn.net/feixiaku/article/details/45155587/ 从github下载两个开源项目: PagerSlidingTabStrip    |   ...