jaxb不生成带有基本整数的枚举 [英] jaxb doesn't generate enums with base integer

查看:106
本文介绍了jaxb不生成带有基本整数的枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下xsd:

<xs:simpleType name="resultcode">
    <xs:restriction base="xs:integer">
        <xs:enumeration value="0" id="Approved_no_error">
            <xs:annotation>
                <xs:appinfo>
                    <jxb:typesafeEnumMember name="Approved_no_error"/>
                </xs:appinfo>
            </xs:annotation>
        </xs:enumeration>

JAX-B什么都不做,没有错误,没有警告只是不生成这个类。如果从 xs:integer 更改为 xs:string ,则可以。但我需要完全整数值。

JAX-B just does nothing, no errors, no warnings just doesn't generate this class. If change base from xs:integer to xs:string then it's ok. But I need exactly integer values.

我用maven生成类:

I generate classes with maven:

<groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>1.3</version>
    <executions>
        <execution>
            <id>AuthGateway</id>
            <goals>
                <goal>xjc</goal>
            </goals>

问题2. JAX-B和IDE(IDEA)不允许id attrribute中的空格。为什么?

And question 2. JAX-B and IDE (IDEA) doesn't allow whitespaces in id attrribute. Why?

< xs:enumeration value =0id =Approved_no_error> - ok < br>
< xs:enumeration value =0id =已批准无错误> - 不行

<xs:enumeration value="0" id="Approved_no_error"> - ok
<xs:enumeration value="0" id="Approved no error"> - not ok

这是正确的行为吗?

推荐答案

您可以使用外部绑定文件来获取您的行为寻找:

You can use an external binding file to get the behaviour that you are looking for:

  • JAXB enumeration with numeric values
  • http://blog.bdoughan.com/2011/08/jaxb-and-enums.html

这篇关于jaxb不生成带有基本整数的枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆