From fc6e04efd8c4634fc5aec9f4b9ecf9e507f80ae4 Mon Sep 17 00:00:00 2001 From: hns Date: Thu, 6 Jun 2002 13:40:50 +0000 Subject: [PATCH] Only include encoding in xml declaration if it was explicitly set by the constructor. --- src/helma/objectmodel/dom/XmlWriter.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/helma/objectmodel/dom/XmlWriter.java b/src/helma/objectmodel/dom/XmlWriter.java index ff7bfb6d..7494bbbc 100644 --- a/src/helma/objectmodel/dom/XmlWriter.java +++ b/src/helma/objectmodel/dom/XmlWriter.java @@ -35,6 +35,10 @@ public class XmlWriter extends OutputStreamWriter implements XmlConstants { private SimpleDateFormat format = new SimpleDateFormat ( DATEFORMAT ); private boolean dbmode = true; + + // Only add encoding to XML declaration if it was explicitly set, not when we're using + // the platform's standard encoding. + private String explicitEncoding; /** * create ids that can be used for temporary files. @@ -56,6 +60,7 @@ public class XmlWriter extends OutputStreamWriter implements XmlConstants { public XmlWriter (OutputStream out, String enc) throws UnsupportedEncodingException { super(out, enc); + explicitEncoding = enc; } public XmlWriter (String desc) throws FileNotFoundException { @@ -64,6 +69,7 @@ public class XmlWriter extends OutputStreamWriter implements XmlConstants { public XmlWriter (String desc, String enc) throws FileNotFoundException, UnsupportedEncodingException { super (new FileOutputStream (desc), enc); + explicitEncoding = enc; } public XmlWriter (File file) throws FileNotFoundException { @@ -72,6 +78,7 @@ public class XmlWriter extends OutputStreamWriter implements XmlConstants { public XmlWriter (File file, String enc) throws FileNotFoundException, UnsupportedEncodingException { super (new FileOutputStream (file), enc); + explicitEncoding = enc; } /** @@ -104,8 +111,10 @@ public class XmlWriter extends OutputStreamWriter implements XmlConstants { */ public boolean write( INode node ) throws IOException { convertedNodes = new Vector(); - String encoding = getEncoding(); - writeln (""); + if (explicitEncoding == null) + writeln (""); + else + writeln (""); writeln (""); writeln ("" ); write ("