Hi all,

I investigated the issue where corrupted XML headers are produced a bit 
further, and it appears that the problem happens when 'encoding' comes through 
as 'null' and the formatting outputters are used.

Here's a patch that fixes the issue (I think) although I haven't been able to 
compile and/or test this because of setup issues:

--- orig/FormattedDataWriter.java       2010-07-19 15:08:24.000000000 -0400
+++ new/FormattedDataWriter.java        2010-07-19 14:31:45.000000000 -0400
@@ -328,10 +328,13 @@
    */
   public void startDocument() throws SAXException {
     reset();
-    String encoding = transformer.getOutputProperty(OutputKeys.ENCODING);
-    String standalone = transformer.getOutputProperty(OutputKeys.STANDALONE);
-    write("<?xml version=\"1.0\" " + (encoding == null ? "UTF-8" : 
"encoding=\""
-      +encoding+"\" ") + "standalone=\""+standalone+"\"" + "?>\n\n");
+    String omitheader = 
transformer.getOutputProperty(OutputKeys.OMIT_XML_DECLARATION);
+    if ( omitheader != "yes") {
+        String encoding = transformer.getOutputProperty(OutputKeys.ENCODING);
+        String standalone = 
transformer.getOutputProperty(OutputKeys.STANDALONE);
+        write("<?xml version=\"1.0\" " + "encoding=\"" + (encoding == null ? 
"UTF-8" : 
+          encoding) + "\" " + "standalone=\""+standalone+"\"" + "?>\n\n");
+    }
   }


Basically, I did two things:
1) Fixed the bad test for null encodings that caused the wrong default output
2) Added the "omit headers" test to skip this entirely if set

Note that the "omit headers" test should also be added for the non-formatted 
headers, I think.


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Xmltask-users mailing list
Xmltask-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xmltask-users

Reply via email to