jaxb doesn't generate enums with base integer

2019-02-17 13:16发布

I have following 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 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.

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>

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

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

Is it correct behaviour?

1条回答
该账号已被封号
2楼-- · 2019-02-17 13:50

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

查看更多
登录 后发表回答