1

I face a weird problem. I'm supposed to use a number of third party XSDs for a webservice. My framework of choice is Apache CXF, and I generate code using its Maven plugin. So far so good, everything works, neither generation nor webservice itself is problematic.

But, since the authors of the XSDs are weird and I cannot change them myself, I face a problem: They use a lot of basically duplicated SimpleType-definitions. They all bear their own name, but do the same thing.

Example:

<xs:simpleType name="VehicleFittedWithEcoInnovInd">
    <xs:restriction base="xs:string">
        <xs:maxLength value="1"/>
        <xs:enumeration value="Y"/>
        <xs:enumeration value="N"/>
    </xs:restriction>
</xs:simpleType>

<xs:simpleType name="TypeApprTranspDangerGoodsInd">
    <xs:restriction base="xs:string">
        <xs:maxLength value="1"/>
        <xs:enumeration value="Y"/>
        <xs:enumeration value="N"/>
    </xs:restriction>
</xs:simpleType>

And many more (Numbers, Stringdefinitions etc etc).

So the question is, is it possible, through a jaxb-plugin or similar, to aggregate these SimpleTypes into one, or at least generate an abstract class structure, so that the amount of irrelevant duplicate code is reduced?

lexicore
  • 42,748
  • 17
  • 132
  • 221
Scorpio
  • 2,309
  • 1
  • 27
  • 45
  • What do you actually get generated? Enum types? If yes, then you might be interested in `typesafeEnumBase`. http://docs.oracle.com/cd/E17802_01/webservices/webservices/docs/2.0/tutorial/doc/JAXBUsing4.html#wp148515 – lexicore Oct 16 '14 at 12:08

0 Answers0