jaxb不生成带有基本整数的枚举

Dmi*_*voi 5 java xsd jaxb maven

我有以下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>
Run Code Online (Sandbox Code Playgroud)

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

我用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>
Run Code Online (Sandbox Code Playgroud)

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

<xs:enumeration value="0" id="Approved_no_error">- 好的
<xs:enumeration value="0" id="Approved no error">- 不行

这是正确的行为吗?

bdo*_*han 6

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

  • 该死的.`code`(<xs:simpleType name ="resultcode"> <xs:annotation> <xs:appinfo> <jxb:typesafeEnumClass /> </ xs:appinfo> </ xs:annotation> <xs:restriction base ="xs :int"> <xs:enumeration value ="0"id ="Approved_no_error"> <xs:annotation> <xs:appinfo> <jxb:typesafeEnumMember name ="Approved_no_error"/>`code` </ xs:appinfo> </xs:annotation> </ xs:enumeration>)`code` (3认同)