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. Bzoj 4556: [Tjoi2016&Heoi2016]字符串

    4556: [Tjoi2016&Heoi2016]字符串 Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 177  Solved: 92[Sub ...

  2. Microsoft Dynamics CRM 数据库连接存储位置在哪里 是在注册表里

    Microsoft Dynamics CRM 数据库连接存储位置是在注册表里

  3. Hadoop概念学习系列之例子形象再谈Client、NameNode、元数据(三十一)

    Client相当于是送货人或提货人. NameNode相当于是仓库管理员. 元数据相当于是账本清单.

  4. 教程-最全ASCII 码对照表

    第一部分由 00H 到 1FH 共 32 个,一般用来通讯或作为控制之用,有些字符可显示于屏幕,有些则无法显示在屏幕上,但能看到其效果(例如换行字符.归位字符). 第二部分是由 20H 到 7FH 共 ...

  5. 关于PCB布线的顺序到底是怎样才合理?

    有人说先布好电源线和地线,让它们尽量靠近走,然后再考虑信号线:也有人说先布好关键的信号线,然后再走电源和地线:还有人说先布好电源线,再布信号线,地线最后布.到底怎么样才算好呢?或者说,一般应按照什么顺 ...

  6. iOS开发—字典转模型,KVC设计模式

    iOS开发UI基础—字典转模型 开发中,通常使用第三方框架可以很快的实现通过字典转模型,通过plist创建模型,将字典的键值对转成模型属性,将模型转成字典,通过模型数组来创建一个字典数组,通过字典数组 ...

  7. hdu 2212

    1.简单的思维问题 各个位上阶乘的和 要和这个数相匹配 这样才能得到正确的解.各个位上阶乘的和 是最大是9*9!这样来求解.999999999   9个9 最大的各个位上的阶乘的和为3265920=9 ...

  8. jquery判断input值不为空 val()

    <input type="text" class="searchbox" /> <script type='text/javascript'& ...

  9. cocos2d-x 纹理研究

    转自:http://blog.csdn.net/qq51931373/article/details/9119161 1.通常情况下用PVR格式的文件来进行图片显示的时候,在运行速度和内存消耗方面都要 ...

  10. cocos2dx中android下动态更新.so文件

    作者:HU 转载请注明,原文链接:http://www.cnblogs.com/xioapingguo/p/4037595.html  因为没用lua脚本写游戏,所以每次发布出去后,发现在bug,需要 ...