0

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>
Artem Oboturov
  • 4,344
  • 2
  • 30
  • 48

1 Answers1

0

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>.

dma_k
  • 10,431
  • 16
  • 76
  • 128
  • It would work with what you propose. The typesafeEnumMember gives you a way to customize generated name of Enum instance from "value" to "name" (as in example 3). – Artem Oboturov Apr 06 '12 at 12:32
  • From this manual: The jaxb:typesafeEnumMember element also has a value attribute. The value is used to associate the enumeration facet with the proper jaxb:typesafeEnumMember element. The value of the value attribute must match one of the values of an enumeration facets' value attribute. This attribute is required when you use an external binding specification for customizing the type generation, or when you group the jaxb:typesafeEnumMember elements as children of the jaxb:typesafeEnumClass element. – Artem Oboturov Apr 06 '12 at 12:35
  • From you comment I though you need to customize the value :) Of course, name customization is also possible using `name` attribute. Happy testing :) – dma_k Apr 06 '12 at 18:14
  • I didn't really get how it was possible to do based on example you proposed to look at. – Artem Oboturov Apr 09 '12 at 09:25
  • Just add to you your question with final version of XSD you came to – it may happen what you need is not supported. – dma_k Apr 09 '12 at 10:03
  • Both links are dead. – Magnilex Oct 26 '16 at 09:05