Represent null value as empty element in xml jaxb
问题 I need to display null value as empty element in jaxb. I am using moxy implementation of jaxb. I found this option @XmlNullPolicy(emptyNodeRepresentsNull = true, nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE) Is there any similar extension that can be applied at Class level (for all elements defined in it) 回答1: I would strongly recommend representing null with either the absence of the node or with the xsi:nil="true" attribute. This works best with schema validation (i.e.