JAXB marshalling attributes of an element in its parent element
843834Dec 17 2002 — edited Nov 19 2008I am getting some strange results using JAXB to marshall instances of a schema containing the following complexType definition:
<xs:complexType name="restrictionType">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="literal" type="literalType"/>
<xs:element name="range" type="rangeType"/>
</xs:choice>
<xs:attribute name="description" type="xs:string"/>
</xs:complexType>
<xs:complexType name="literalType">
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:complexType>
<xs:complexType name="rangeType">
<xs:attribute name="minValue" type="xs:string" use="required"/>
<xs:attribute name="maxValue" type="xs:string" use="required"/>
</xs:complexType>
Any 'literal' or 'range' objects I create and add to the 'restrictionType' are not written out as subelements. Instead their attributes are added to the 'restrictionType' element.
Has anyone else seen this behaviour?
Does anyone know if it is a bug, a mistake in my schema, or a mistake in my code ?
Cheers,
Simon Heinrich