问题
For JAXB we could use Inline Customization to adjust schema compiler in some way. This could be done via Schema Binding Declarations (<jxb:schemaBindings/>).
Any way to make other XML tags (e.g. ActualType, EnumerationValue in example below) work with standard XJC compiler to affect generated classes?
<xs:simpleType name="SomeType">
<xs:annotation>
<xs:appinfo>
<ActualType Name="unsignedInt" />
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="PredefinedEnumValue">
<xs:annotation>
<xs:appinfo>
<EnumerationValue>10000</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
回答1:
For enumeration value you need to use <jaxb:typesafeEnumMember value="10000" />
(check example here) and for simple type conversion you need to use <jaxb:baseType name="int" />
(check example there).
P.S. Java does not support unsigned ints. Also don't forget to define jaxb namespace xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
in your <xsd:schema>
.
来源:https://stackoverflow.com/questions/10041393/can-i-configure-xjc-compiler-to-consume-custom-xml-bindings-for-inline-customiza