When I marshal java object using JAXB I am getting below xml element
<error line="12" column="" message="test" />
But I want xml as below
<error line="12" message="test" />
If column value is empty then I need to get the xml as shown above otherwise I need to get the column attribute in the element.
Is there any way to get it?
An attribute will only be marshalled out with an empty
Stringvalue if the corresponding field/property contains a emptyStringvalue. If the value is null the attribute will not be marshalled.Root
Demo
Output