Using JAXB 2.2.4 I generate Java code with the following binding file:
<bindings xmlns="http://java.sun.com/xml/ns/jaxb" version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <globalBindings generateElementProperty="false"> </globalBindings>
Unfortunately, the generated code has the annotation nillable = true. See the following example:
@XmlElement(name = "ArtID", nillable = true) protected STEBeitrag artID;
This is the definition of STEBeitrag:
<xsd:complexType name="CT_Beitrag"> <xsd:complexContent> <xsd:extension base="allgemein:CT_Objekt"> <xsd:sequence> <xsd:element name="ArtID" type="daten:STE_Beitrag" minOccurs="0" maxOccurs="1" nillable="true"/></xsd:element> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:complexType name="STE_Beitrag" abstract="true"> <xsd:simpleContent> <xsd:extension base="xsd:string"/> </xsd:simpleContent> </xsd:complexType>
If I do not set the ArtID in the generated CT_Beitrag object, then the marshaller produces output, for example
<ns:ArtID xsi:nil="true"/>
The ArtID element has an abstract type, so this XML output is not valid.
How can I generate code with JAXB that omits nillable = true in the XmlElement annotation? By the way, the circuit cannot be changed.
source share