Permalink
Browse files

Warn doubly for a non-XHTML-namespaced div.

Warn that an xhtml:div is missing and that the 'div' is in an
unexpected namespace when content's top-level 'div' has an
incorrect namespace.
  • Loading branch information...
1 parent aa32000 commit 36e53b3c8f34f0a2124917cbfe2549c16474dfb4 @josephw josephw committed Mar 17, 2013
Showing with 9 additions and 5 deletions.
  1. +9 −5 src/feedvalidator/content.py
@@ -5,6 +5,10 @@
from base import validatorBase, namespaces
from validators import *
from logging import *
+
+def _isXhtmlDiv(ns, elem):
+ return ns == 'http://www.w3.org/1999/xhtml' and elem == 'div'
+
#
# item element.
#
@@ -98,17 +102,17 @@ def characters(self, string):
self.log(MissingXhtmlDiv({"parent":self.parent.name, "element":self.name}))
validatorBase.characters(self,string)
- def isXhtmlDiv(ns, elem):
- return ns == 'http://www.w3.org/1999/xhtml' and elem == 'div'
-
def startElementNS(self, name, qname, attrs):
if (self.type<>'xhtml') and not (
self.type.endswith('+xml') or self.type.endswith('/xml')):
self.log(UndefinedElement({"parent":self.name, "element":name}))
if self.type=="xhtml":
- if not isXhtmlDiv(qname, name) and not self.value.strip():
+ if not _isXhtmlDiv(qname, name) and not self.value.strip():
self.log(MissingXhtmlDiv({"parent":self.parent.name, "element":self.name}))
+ if name == 'div':
+ self.log(NotHtml({"parent":self.parent.name, "element":self.name, "message":"unexpected namespace", "value": qname}))
+
elif qname not in ["http://www.w3.org/1999/xhtml"]:
self.log(NotHtml({"parent":self.parent.name, "element":self.name, "message":"unexpected namespace", "value": qname}))
@@ -122,7 +126,7 @@ def startElementNS(self, name, qname, attrs):
if self.attrs.getValue((None,"mode")) == 'escaped':
self.log(NotEscaped({"parent":self.parent.name, "element":self.name}))
- if isXhtmlDiv(qname, name):
+ if _isXhtmlDiv(qname, name):
handler=diveater()
else:
handler=eater()

0 comments on commit 36e53b3

Please sign in to comment.