0

I'm trying to generate enums from a simple-type of base int using the Maven maven-jaxb2-plugin. But no enum is being generated.

I can see that the generator is using the bindings-file, since it throws errors if it couldn't find a mapping.

When I change the base to string the enum gets generated (but I'm not allowed to change the base).

So do I have something configured wrong, or is it simply not possible?

xsd-excerpt:

<xs:simpleType name="codeType">
  <xs:restriction base="xs:int">
    <xs:enumeration value="200"/>
    <xs:enumeration value="400"/>
  </xs:restriction>
</xs:simpleType>

bindings-file excerpt:

<jaxb:bindings schemaLocation="some.xsd">
  <jaxb:bindings node="//xs:simpleType[@name='codeType']/xs:restriction/xs:enumeration[@value='200']">
    <jaxb:typesafeEnumMember name="OK" />
  </jaxb:bindings>
  <jaxb:bindings node="//xs:simpleType[@name='codeType']/xs:restriction/xs:enumeration[@value='400']">
    <jaxb:typesafeEnumMember name="BAD_REQUEST" />
  </jaxb:bindings>
</jaxb:bindings>
user871611
  • 3,307
  • 7
  • 51
  • 73

1 Answers1

0

I finally managed, that the enum is generated.

bindings-file excerpt:

<jaxb:bindings schemaLocation="some.xsd">
  <jaxb:bindings node="//xs:simpleType[@name='codeType']">
    <jaxb:typesafeEnumClass>
      <jaxb:typesafeEnumMember value="200" name="OK" />
      <jaxb:typesafeEnumMember value="400" name="BAD_REQUEST" />
    </jaxb:typesafeEnumClass>
  </jaxb:bindings>
</jaxb:bindings>

See https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.0/html/Developing_Applications_Using_JAX-WS/files/JAXWSCustomTypeMappingEnum.html for more details.

user871611
  • 3,307
  • 7
  • 51
  • 73