usr/src/lib/install_utils/TreeAcc.py
changeset 862 e9f31f2f2f2d
parent 650 8ee7d92070f0
child 947 29603af1b942
--- a/usr/src/lib/install_utils/TreeAcc.py	Tue Aug 17 18:22:44 2010 -0400
+++ b/usr/src/lib/install_utils/TreeAcc.py	Fri Aug 20 11:31:18 2010 -0600
@@ -18,8 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 
 # =============================================================================
 # =============================================================================
@@ -1348,6 +1347,18 @@
         except IOError, err:
             raise FileOpenError, errno.errorcode[err.errno]
 
+        # If the original document contained a reference to an external
+        # DTD, then reconstruct the DOCTYPE field and write it out at
+        # the top of the output file.
+        # (This is essential for loading DTD attribute defaults later.)
+        if ((self.treedoc.doctype is not None) and
+            (self.treedoc.doctype.name is not None) and
+            (self.treedoc.doctype.systemId is not None) and
+            (self.treedoc.doctype.systemId.endswith(".dtd"))):
+            doctype_str = "<!DOCTYPE %s SYSTEM \"%s\">\n" % \
+                (self.treedoc.doctype.name, self.treedoc.doctype.systemId)
+            fp.write(doctype_str)
+
         # Write the data.
         # Pylint bug: See http://www.logilab.org/ticket/8764
         # pylint: disable-msg=C0321