0

I've my object, configured with the code:

object.setName("");

marshaled into following XML:

<object>
    <name></name>
</object>

But I want single tag:

<object>
    <name/>
</object>

Is it easy to do with JAXB for all my objects at once?

UPDATE

Similar question: How to instantiate an empty element with JAXB

It's suggested to use prettifier javax.xml.transform.TransformerFactory.newTransformer(), but without explanation how to use it. Ideally my goal is to get exact code to configure JAXB to get the desired result.

Thanks.

Community
  • 1
  • 1
Vladimir
  • 4,782
  • 7
  • 35
  • 56
  • Possible duplicate. http://stackoverflow.com/questions/594537/how-to-instantiate-an-empty-element-with-jaxb – James Sep 08 '11 at 19:00
  • Hi @James, that's very similar, but the subject is a bit different plus there is no detailed explanation how to user prettifier, so let me keep this question open. I will update the goal. – Vladimir Sep 09 '11 at 11:29

1 Answers1

0

The answer to my question was found in another question How to instantiate an empty element with JAXB where it's suggested to either use a prettifier or don't do anything at all because both versions of XML are equivalent.

Community
  • 1
  • 1
Vladimir
  • 4,782
  • 7
  • 35
  • 56