[Checkins] SVN: Sandbox/malthe/chameleon.core/ Do not fix-up self-closing tags if an XML declaration is present without a DOCTYPE.

Malthe Borch mborch at gmail.com
Mon Nov 24 11:38:27 EST 2008


Log message for revision 93317:
  Do not fix-up self-closing tags if an XML declaration is present without a DOCTYPE.

Changed:
  U   Sandbox/malthe/chameleon.core/CHANGES.txt
  U   Sandbox/malthe/chameleon.core/src/chameleon/core/translation.py

-=-
Modified: Sandbox/malthe/chameleon.core/CHANGES.txt
===================================================================
--- Sandbox/malthe/chameleon.core/CHANGES.txt	2008-11-24 16:35:59 UTC (rev 93316)
+++ Sandbox/malthe/chameleon.core/CHANGES.txt	2008-11-24 16:38:27 UTC (rev 93317)
@@ -4,6 +4,9 @@
 HEAD
 ~~~~
 
+- Do not fix-up self-closing tags if an XML declaration is present
+  without a DOCTYPE. [malthe]
+
 - Prefix tags which do not belong to the default namespace. [malthe]
 
 1.0b10 (released 24/11/2008)

Modified: Sandbox/malthe/chameleon.core/src/chameleon/core/translation.py
===================================================================
--- Sandbox/malthe/chameleon.core/src/chameleon/core/translation.py	2008-11-24 16:35:59 UTC (rev 93316)
+++ Sandbox/malthe/chameleon.core/src/chameleon/core/translation.py	2008-11-24 16:38:27 UTC (rev 93317)
@@ -44,7 +44,7 @@
     dict_attributes = None
     static_attributes = utils.emptydict()
     dynamic_attributes = utils.emptydict()
-    
+
     def __init__(self, element):
         self.element = element
 
@@ -69,7 +69,7 @@
         if self.element.tail is None:
             return ()
         return (self.element.tail,)
-    
+
     @property
     def stream(self):
         return self.element.stream
@@ -600,11 +600,13 @@
         elif parsed_doctype and not no_doctype_declaration:
             self.doctype = parsed_doctype
 
-        # limit self-closing tags to the allowed subset for templates
-        # with a non-XML compliant document type (non-strict); see
+        # if the document has no XML declaration, limit self-closing
+        # tags to the allowed subset for templates with a non-XML
+        # compliant document type (non-strict); see
         # http://www.w3.org/TR/xhtml1/#C_3 for more information.
         ldoctype = (self.doctype or implicit_doctype or "").lower()
-        if 'html' in ldoctype and 'strict' not in ldoctype:
+        if no_xml_declaration and \
+               'html' in ldoctype and 'strict' not in ldoctype:
             for element in self.root.getiterator():
                 try:
                     tag = element.tag.split('}')[-1]



More information about the Checkins mailing list