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. Win10系统安装

    2016正月十一来到了学校,刚刚拿到了姐姐的thinkpad,到学校来想重新安装一下系统并且重新磁盘分区. 上一次也安装过win10,不过基本方法已经忘了,制作的U启动盘也不在了. 首先按照http: ...

  2. 浅析Netty的异步事件驱动(二)

    上一篇文件浅析了Netty中的事件驱动过程,这篇主要写一下异步相关的东东. 首先,什么是异步了? 异步的概念和同步相对.当一个异步过程调用发出后,调用者不能立刻得到结果.实际处理这个调用的部件在完成后 ...

  3. HW5.30

    public class Solution { public static void main(String[] args) { for(int i = 3; i <= 1000; i++) i ...

  4. xerox Network system

    XNS协议 IPX/SPX 是基于施乐的XEROX’S Network System(XNS)协议,而SPX是基于施乐的XEROX’S SPP(Sequenced Packet Protocol:顺序 ...

  5. 最简单的计算MD5方法

    原来写过一个计算MD5的程序,是用了一个叫MD5.pas的单元,使用起来还算简单,但还有更简单的办法,安装了indy就会有IdHashMessageDigest单元(delphi 7默认安装indy) ...

  6. hql注意事项一

    Space is not allowed after parameter prefix ':' [from EmPaperCatalogDef e where e.parentId =: pcdId]

  7. Appium Android定位元素与操作

    文章写得很好,转载备用 一.常用识别元素的工具 uiautomator:Android SDK自带的一个工具,在tools目录下 monitor:Android SDK自带的一个工具,在tools目录 ...

  8. 【转】Javascript 面向对象编程(一):封装

    原文链接:http://www.ruanyifeng.com/blog/2010/05/object-oriented_javascript_encapsulation.html Javascript ...

  9. cocos2d-x RenderTexture

    转自:http://blog.csdn.net/bill_man/article/details/7250911 1.CCRenderTexture 使用CCRenderTexture的过程总结起来一 ...

  10. fb设置viewSourceURL