I have a service that needs to generate xml. Currently I am using jaxb and a Marshaller to create the xml using a StringWriter.
Here is the current output that I am getting.
<CompanyName>Bakery é &</CompanyName>
While this may be fine for some webservices, I need to escape special unicode characters. The service that is comsuming my xml needs to have this:
<CompanyName>Bakery é &</CompanyName>
If I use StringEscapeUtils from commons-lang I end up with something like the follwing. This one does not work also:
<CompanyName>Bakery &#233; &amp;</CompanyName>
Are there some settings for the Marshaller that will allow me to encode these special characters as their decimal values?
Yes, Marshaller.setProperty(jaxb.encoding,encoding) will set the encoding to use for the document. I’d guess that you want “US-ASCII”.