In my XSD I've the following type definition:
<xs:simpleType name="Color">
<xs:annotation />
<xs:restriction base="xs:token">
<xs:enumeration value="B">
<xs:annotation>
<xs:appinfo>
<codeName>BLUE</codeName>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="R">
<xs:annotation>
<xs:appinfo>
<codeName>RED</codeName>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
Out of the box wsimport would generate the following java enum out of it:
public enum Color {
B,
R;
public String value() {
return name();
}
public static Color fromValue(String v) {
return valueOf(v);
}
}
I'd like wsimport to consider the long descriptions in the codename elements <codeName>BLUE</codeName>
and include them as an instance variable in the java enum. Is this prossible for example by using an JAXB binding file?
You can provide a one-to-one mapping of values by providing a JAXB bindings file. Within the bindings file, you would want something like this:
Alternatively, you could provide the JAXB bindings inline within the schema, but I do not like that approach because it clutters the schema with implementation details that will probably not apply to everyone.
An example of that is below:
You could also do it all at once, with it being a bit disjoint from the actual values, therefore a bit more duplicative: