java – JAXB Generation nillable = true

Using JAXB 2.2 4 I generate java code using the following binding files:

<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 a nillable = true annotation 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'm not generating CT_ If the artId is set in the Beitrag object, the unmarshaller generates similar output

<ns:ArtID xsi:nil="true"/>

The XML output is invalid because the element artId has an abstract type

How to generate code using JAXB and ignore nillable = true in xmlelement comments? By the way, the architecture cannot be changed

Solution

I don't have a solution, but this problem is solved in a bug

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>