Reputation: 3462
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>
Upvotes: 0
Views: 266
Reputation: 3462
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 15.4. Customizing Enumeration Mapping - Red Hat JBoss Fuse 6.0 Developing Applications Using JAX-WS for more details.
Upvotes: 0