RE: DOM 3 LS - LSSerializer.writeToString encoding declaration

A definitive resolution would need to come from the working group.

My take on it is that serializer.writeToString(nodeArg) should be 
equivalent to:

LSOutput output = domImplLS.createLSOutput();
output.characterStream = new StringWriter();
serializer.write(nodeArg, output);

And that that should be equivalent to:

LSOutput output = domImplLS.createLSOutput();
output.byteStream = new ByteArrayOutputStream();
serializer.write(nodeArg, output);
And then reading the byteStream with an InputStreamReader with the 
appropriate encoding.


If these equivalences were followed then Document.inputEncoding or 
Document.xmlEncoding would control the encoding declaration.  So if the 
source document had <?xml encoding="US-ASCII"?> then the string from 
writeToString would contain "<?xml encoding="US-ASCII"?>" and all 
non-US-ASCII characters would be represented by character entities.

Received on Thursday, 22 January 2004 20:09:16 UTC