How to represent null value as empty element with JAXB?

前端 未结 4 758
[愿得一人]
[愿得一人] 2020-12-01 06:58

My XSD structure is like the below:-


         


        
4条回答
  •  一生所求
    2020-12-01 07:51

    You should read nillable and minOccurs XSD element attributes because the difference between nil and an empty element is significant in XML. i.e. xsi:nil=true is similar to SQL NULL but having empty element represents the presents of an empty element. :)
    I know it is confusing.

    To fix your specific issue, if you are using JAXB serialization to generate that, i recommend reading How to instantiate an empty element with JAXB. The question itself shows you how to generate an empty element.

提交回复
热议问题