Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.1.3
-
Component/s: None
-
Labels:None
-
JDK version and platform:1.5.0-beta2-b51
Description
When using the DomDriver(), strings with 0x0c (and probably other chars as well) do not unmarshal correctly, yielding an error:
[Fatal Error] :1:14: An invalid XML character (Unicode: 0xc) was found in the element content of the document.
Using the default (XPP) driver works correctly.
It might be worth noting this in the FAQ, because I suspect it is out of your hands (i.e. error exists in DomDriver).
Here is a test case demonstrating this behaviour:
import junit.framework.TestCase;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
public class DomTest extends TestCase
{
public void testDomDriver()
{ XStream xs = new XStream( new DomDriver() ); String input = "hello" + ( char ) 0x0c; assertEquals( input, xs.fromXML( xs.toXML( input ) ) ); }public void testDefaultDriver()
{ XStream xs = new XStream(); String input = "hello" + ( char ) 0x0c; assertEquals( input, xs.fromXML( xs.toXML( input ) ) ); }}
Issue Links
- relates to
-
XSTR-147 String "\0" serialized as inavlid XML
Well, the DomDriver is correct, XML 1.0 specifies in Chapter 2.2 only tabs, carriage return and line feed as valid characters in the non-printable area from 0-31. This is changed in XML 1.1 though, here only a \0 is invalid. I added support at least for this character.