我有以下 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
那么就可以了。但我需要的是整数值。
我用 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 属性中使用空格。为什么?
<xs:enumeration value="0" id="Approved_no_error">
- 好的
<xs:enumeration value="0" id="Approved no error">
- 不好
这是正确的行为吗?
最佳答案
您可以使用外部绑定(bind)文件来获得您正在寻找的行为:
关于java - jaxb 不生成具有基本整数的枚举,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8569299/