diff -ur ruby-1.8.4-xhtml_cgi/lib/cgi.rb ruby-1.8.4-xhtml_cgi-2/lib/cgi.rb
--- ruby-1.8.4-xhtml_cgi/lib/cgi.rb	2006-01-21 12:57:43.000000000 -0500
+++ ruby-1.8.4-xhtml_cgi-2/lib/cgi.rb	2006-01-21 12:50:41.000000000 -0500
@@ -1664,13 +1664,14 @@
     # "DOCTYPE", if given, is used as the leading DOCTYPE SGML tag; it
     # should include the entire text of this tag, including angle brackets.
     #
-    # For XHTML 1.0 output, two addition pseudo-attributes, "XMLDECL"
-    # and "XML_ENCODING", are available.  "XMLDECL" is, as the name
-    # implies, the full XML declaration for the output document, and, 
-    # like the "DOCTYPE" pseudo-element, should include the entire text
-    # of the tag, including angle brackets. "XML_ENCODING" is the top-
-    # level XML encoding for the document, and defaults to "UTF-8" if
-    # unspecified.
+    # One additional pseudo-attribute, "XMLDECL", is available for XHTML
+    # 1.0 output.  "XMLDECL" is, as the name implies, the full XML
+    # declaration for the output document, and, like the "DOCTYPE"
+    # pseudo-element, should include the entire text of the tag,
+    # including the angle brackets.  The XML declaration is omitted by
+    # default because the XML specification requires it to be the first
+    # fragment in the document, but several modern browsers (IE6, Opera
+    # 7, and Konqueror 3.2).
     #
     # The body of the html element is supplied as a block.
     # 
@@ -1715,6 +1716,16 @@
       pretty = "  " if true == pretty
       buf = ""
 
+      # If the pseudo-attribute XMLDECL exists and is a string, then
+      # print it out in full as the XML declaration.  
+      #
+      # Note: IE6, Opera 7, and Konqueror 3.2 all get thrown into quirks
+      # mode if the first element in the document isn't a DOCTYPE
+      # declaration, so we deliberately omit the XML declaration by
+      # default here. 
+      buf += attributes['XMLDECL'] if attributes.key?('XMLDECL')
+      
+      # add the document's DOCTYPE
       if attributes.has_key?("DOCTYPE")
         if attributes["DOCTYPE"]
           buf += attributes.delete("DOCTYPE")
@@ -1725,33 +1736,6 @@
         buf += doctype
       end
 
-      # if the method xmldecl exists, then print out an XML
-      # declaration.  IE doesn't render in strict mode if the first
-      # element in the document isn't a DOCTYPE declaration, so we need
-      # to put the XML declaration after the DOCTYPE declaration, even
-      # though it really makes more sense the other way around.
-      if respond_to?(:xmldecl)
-        buf += if attributes.key?('XMLDECL')
-          # if the pseudo-attribute XMLDECL is specified, then delete it
-          # from the attribute list and use that instead of the
-          # pre-defined XML declaration
-          attributes.delete('XMLDECL')
-        else
-          # if the pseudo-attribute XML_ENCODING is specified, then
-          # delete it from the attribute list and use it instead of
-          # UTF-8
-          encoding = if attributes.key?('XMLENCODING') 
-            attributes.delete('XML_ENCODING')
-          else
-            'UTF-8'
-          end
-
-          # render the XML declaration with the specified encoding
-          xmldecl(encoding)
-        end
-      end
-      
-
       # add the xml namespace unless the xmlns method isn't defined
       # _and_ we don't have the xmlns attribute set
       unless attributes.key?('xmlns') || !respond_to?(:xmlns)
@@ -2354,10 +2338,6 @@
       %|<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">|
     end
 
-    def xmldecl(enc = 'UTF-8')
-      %|<?xml version='1.0' encoding='#{enc}'?>|
-    end
-
     def xmlns
       'http://www.w3.org/1999/xhtml'
     end
@@ -2405,10 +2385,6 @@
       %|<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">|
     end
 
-    def xmldecl(enc = 'UTF-8')
-      %|<?xml version='1.0' encoding='#{enc}'?>|
-    end
-
     def xmlns
       'http://www.w3.org/1999/xhtml'
     end
@@ -2457,11 +2433,6 @@
       %|<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">|
     end
 
-    # the XML declaration for this XHTML document
-    def xmldecl(enc = 'UTF-8')
-      %|<?xml version='1.0' encoding='#{enc}'?>|
-    end
-
     # the XML namespace attribute for this XHTML document
     def xmlns
       'http://www.w3.org/1999/xhtml'

