We have the following problem. We try to generate Java code from XSD files that contain group declarations and multiple group references to these group declarations. Here a simplified version:
<xs:group name="Information">
<xs:sequence>
<xs:element name="Name">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="updated" type="xs:boolean"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:group>
<xs:element name="Address">
<xs:complexType>
<xs:sequence>
<xs:group ref="Information" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:group ref="Information"/>
</xs:sequence>
</xs:complexType>
</xs:element>
The main points are:
Information
is references twiceName
element inside the groupThe problem we face now is that xjc generates non-deterministically depending on the machine where we build, sometimes the type Address.Name
and sometimes the type Customer.Name
, because the Name
element is a complex type and requires a type.
Is there any way to tell xjc to always generate the same type?
jaxb:class
binding and specify the class name.<jaxb:globalBindings localScoping="toplevel"/>
to generate inner classes on the top level instead.A combination of these two will give you a predictable class.