devtools/htmlparser.py
branchstable
changeset 5276 5037d891e207
parent 4252 6c4f109c2b03
child 5421 8167de96c523
--- a/devtools/htmlparser.py	Thu Apr 15 12:04:48 2010 +0200
+++ b/devtools/htmlparser.py	Thu Apr 15 14:06:33 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):