Avoid Empty Sub-Tags in XML if everything is blank in an object
问题 We have JAXB objects marshing/unmarshalling XML. Currently, we get this tag, even though everything inside it is empty. We need to completely get rid of the Top section if all its sub-elements are empty. (If at least one is not empty, it should exist.) <ns2:Top> <ns2:OrganizationName></ns2:OrganizationName> <ns2:Address> <ns2:Street1></ns2:Street1> <ns2:Street2></ns2:Street2> <ns2:City></ns2:City> <ns2:ZipPostalCode></ns2:ZipPostalCode> </ns2:Address> </ns2:Top> The JAXB class is defined as: