Commit 5d68e8e3 authored by Guido van Rossum's avatar Guido van Rossum

Fixed case sensitivity of attributes (they are case *sensitive*).

parent eae121e4
# A parser for XML, using the derived class as static DTD. # A parser for XML, using the derived class as static DTD.
# Author: Sjoerd Mullender # Author: Sjoerd Mullender.
import re import re
import string import string
...@@ -44,14 +44,13 @@ attrfind = re.compile( ...@@ -44,14 +44,13 @@ attrfind = re.compile(
# XML parser base class -- find tags and call handler functions. # XML parser base class -- find tags and call handler functions.
# Usage: p = XMLParser(); p.feed(data); ...; p.close(). # Usage: p = XMLParser(); p.feed(data); ...; p.close().
# The dtd is defined by deriving a class which defines methods # The dtd is defined by deriving a class which defines methods with
# with special names to handle tags: start_foo and end_foo to handle # special names to handle tags: start_foo and end_foo to handle <foo>
# <foo> and </foo>, respectively, or do_foo to handle <foo> by itself. # and </foo>, respectively. The data between tags is passed to the
# (Tags are converted to lower case for this purpose.) The data # parser by calling self.handle_data() with some data as argument (the
# between tags is passed to the parser by calling self.handle_data() # data may be split up in arbutrary chunks). Entity references are
# with some data as argument (the data may be split up in arbutrary # passed by calling self.handle_entityref() with the entity reference
# chunks). Entity references are passed by calling # as argument.
# self.handle_entityref() with the entity reference as argument.
class XMLParser: class XMLParser:
...@@ -313,8 +312,6 @@ class XMLParser: ...@@ -313,8 +312,6 @@ class XMLParser:
attrvalue = attrvalue[1:-1] attrvalue = attrvalue[1:-1]
else: else:
self.syntax_error(self.lineno, 'attribute value not quoted') self.syntax_error(self.lineno, 'attribute value not quoted')
# XXXX are attribute names case sensitive?
attrname = string.lower(attrname)
if attrlist is not None and attrname not in attrlist: if attrlist is not None and attrname not in attrlist:
self.syntax_error(self.lineno, self.syntax_error(self.lineno,
'unknown attribute %s of element %s' % 'unknown attribute %s of element %s' %
...@@ -565,4 +562,3 @@ def test(args = None): ...@@ -565,4 +562,3 @@ def test(args = None):
if __name__ == '__main__': if __name__ == '__main__':
test() test()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment