devtools/htmlparser.py
changeset 5302 dfd147de06b2
parent 5276 5037d891e207
child 5421 8167de96c523
--- a/devtools/htmlparser.py	Thu Apr 15 18:54:13 2010 +0200
+++ b/devtools/htmlparser.py	Thu Apr 15 19:39:55 2010 +0200
@@ -74,6 +74,21 @@
         Validator.__init__(self)
         self.parser = etree.XMLParser()
 
+class XMLDemotingValidator(SaxOnlyValidator):
+    """ some views produce html instead of xhtml, using demote_to_html
+
+    this is typically related to the use of external dependencies
+    which do not produce valid xhtml (google maps, ...)
+    """
+
+    def preprocess_data(self, data):
+        if data.startswith('<?xml'):
+            self.parser = etree.XMLParser()
+        else:
+            self.parser = etree.HTMLParser()
+        return data
+
+
 class HTMLValidator(Validator):
 
     def __init__(self):