0

I'm encoding a short integer with value 0 and XMLEncoder does not encode it.

How can I force it?

daigorocub
  • 786
  • 8
  • 15

2 Answers2

0

XMLEncoder does not encode default values. It saves space. It works.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • It works sometimes. Unfortunately unless the semantics are well defined (e.g. a correctly used XSD -- perhaps with xsl:nil -- or documentation) it might leave someone with some "bad data". A missing attribute is different than an attribute with a default value. –  Dec 10 '10 at 06:26
  • I'm referring to values that are defaulted in the Java code, not the XSD. Not sure what XSD's have to do with XMLEncoder actually, they all share the same one. – user207421 Dec 13 '10 at 00:43
-1

I switched to another library: XStream (http://x-stream.github.io/)

Much simpler and it works.

facundofarias
  • 2,973
  • 28
  • 27
daigorocub
  • 786
  • 8
  • 15