In my schema I have some types that simply extend a simple XSD type (int or string). JAXB creates a separate java class per such type. I want to drop this intermediate class and configure JAXB to use primitives where possible (e.g. substitute CountryType
with java.lang.String
and DocumentType
with int
or lava.lang.Integer
). For example, for a given XSD it would be nice to have DestinationType.setDocumentType(int)
and List<String> StatesType.getCountry()
. I am happy to write type-wide an adapter for that, but it looks like only conversions from primitive XML types are supported. Maybe it is possible to make per-property type conversion? Please, give any example of JAXB binding customization, that can help.
<?xml version="1.0" encoding="UTF-8"?>
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:exch="http://www.mycompany.org/exchange"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
targetNamespace="http://www.mycompany.org/exchange"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<complexType name="countryType">
<simpleContent>
<extension base="string"/>
</simpleContent>
</complexType>
<complexType name="statesType">
<sequence maxOccurs="unbounded">
<element name="country" type="exch:countryType"/>
</sequence>
</complexType>
<complexType name="documentType">
<simpleContent>
<extension base="integer"/>
</simpleContent>
</complexType>
<complexType name="destinationType">
<sequence>
<element name="states" type="exch:statesType" maxOccurs="1"/>
<element name="document-type" type="exch:documentType" minOccurs="1" maxOccurs="1"/>
</sequence>
</complexType>
</schema>