Isn't walking the object tree (prior to calling marshal) and pruning
and modifying
object feasible?
Or applying a transformation to the resulting XML before it is sent on the wire?
-W
On 27/11/2013, Krzysztof Sobkowiak <krzys.sobkowiak_at_gmail.com> wrote:
> Hi
>
> I have a functionality which sends a lot of xml data generated using
> JAXB from structures filled with data in business code. The generated
> xml contains many empty elements even if the attribute is optional, e.g.
> somebody sets empty string instead of null or sets empty data structure.
> I cannot force the changes in the business code, I cannot change the
> xsds but I can eventually change the generated java classes using
> binding customization.
>
> Is there any functionality which allows me to clean up the empty
> optional elements before/while/after marshalling? If not, is there any
> code in JAXB I could look at/I could reuse and implement a functionality
> which traverses the generated structure and performs the cleanup?
>
> I use currently the version 2.2.4-1 of JAXB implementation.
>
> Best regards
> Krzysztof
>