Sandeep Tirumala
Sandeep Tirumala

Reputation: 1

How can i suppress xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" using JAXB

I am running into an issue with JAXB marshaller. According to the document when @XmlElement(required = true) which is nillable = false as default, an instance of null is omitted, but instead i see in the generated xml, how should i let JAXB omit "ExternalEventId" altogether from xml.

Upvotes: 0

Views: 8964

Answers (1)

Ian Roberts
Ian Roberts

Reputation: 122364

If you want to represent null by the complete absence of the element then simply use required=false (the default). If null values are to be allowed at all then the element must be either required=false or nillable=true - in the former case null is represented by omitting the element, in the latter by xsi:nil.

A null value for a property that is neither optional nor nillable makes no sense.

Upvotes: 1

Related Questions