decal
decal

Reputation: 1017

Prevent XmlBeans from trimming whitespaces

have a little problem with XmlBeans. It seems that it automatically is trimming the whitespaces of Strings that I am trying to add to the XML. For example. I have a list of codes and values. Each code has a value.

<code>
 <value/>
</code>

It is possible that some codes have missing values, in which case their value could be " ".

however, when I call the code objects set value method(String) than it seems like XmlBeans trims the whitespaces.

code.setValue(" ");
=
<code>
 <value></value>
</code>

I was wondering if anyone knows how to get around this in XmlBeans, as the correct output should be

<code>
 <value> </value>
</code>

Thanks!

Upvotes: 2

Views: 979

Answers (1)

decal
decal

Reputation: 1017

Ahh so this has nothing to do with how I am setting the value, but rather how I have save the file. I saved it using XmlOptions().setSavePrettyPrint(). According to the mailing list

http://mail-archives.apache.org/mod_mbox/xmlbeans-user/200803.mbox/%[email protected]%3E

This is what is responsible for trimming the whitespaces.

Upvotes: 2

Related Questions