XStream is used to generate XML in our application, but I don't think this problem is specific to XStream. I'm wondering if there's something I can do in
Java to make sure that this problem doesn't happen.
We are sending an XML file to another internal application, and I'm having trouble with an apostrophe in one of the XML nodes. It's a simple object and there is no special converter registered for it, and its comments field is just a
String. In two UNIX
testing environments, we are seeing different behavior, and I don't even know where to begin to look for the cause. At first, I assumed their parser was mishandling something, but upon investigation, we found out that this is what they're seeing in the XML file they receive from us:
XML: <comments>These are Stephen's comments.</comments>
Actually, it's not exactly what you see above--it's actually Stephen followed by an ampersand followed by apos; and then the final s (the end of "Stephen's"). Anyway, this renders correctly as: These are Stephen's comments.
In another environment (that should be the same as far as character encodings are concerned), here's what they see coming from us:
XML: <comments>These are Stephen's comments.</comments>
"Stephen's" gets incorrectly rendered as Stephen followed by an ampersand followed by #39; followed by the final s.
I don't know how this could be happening if the code is the same. Has anyone seen something like this before? Is there a way I can put in a bit of safety code to make sure this doesn't happen in any environment?
Thanks,
Stephen
[ May 01, 2008: Message edited by: Stephen Huey ]
[ May 01, 2008: Message edited by: Stephen Huey ]
[ May 01, 2008: Message edited by: Stephen Huey ]