Hash :
336fc7d3
Author :
Date :
2002-12-27T19:37:04
final touch running DTD validation on the XmlTextReader added a specific * valid.c xmlreader.c: final touch running DTD validation on the XmlTextReader * python/tests/Makefile.am python/tests/reader2.py: added a specific run based on the examples from test/valid/*.xml Daniel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
#!/usr/bin/python -u
#
# this tests the validation with the XmlTextReader interface
#
import sys
import glob
import string
import libxml2
# Memory debug specific
libxml2.debugMemory(1)
err=""
expect="""../../test/valid/xlink.xml:450: validity error: ID dt-arc already defined
<p><termdef id="dt-arc" term="Arc">
^
../../test/valid/xlink.xml:529: validity error: attribute def line 199 references an unknown ID "dt-xlg"
<?Pub *0000052575?>
^
../../test/valid/rss.xml:172: validity error: Element rss does not carry attribute version
</rss>
^
"""
def callback(ctx, str):
global err
err = err + "%s" % (str)
libxml2.registerErrorHandler(callback, "")
valid_files = files = glob.glob("../../test/valid/*.x*")
for file in valid_files:
if string.find(file, "t8") != -1:
continue
reader = libxml2.newTextReaderFilename(file)
#print "%s:" % (file)
reader.setParserProp(libxml2.PARSER_VALIDATE, 1)
ret = reader.read()
while ret == 1:
ret = reader.read()
if ret != 0:
print "Error parsing and validating %s" % (file)
#sys.exit(1)
if err != expect:
print err
del reader
# Memory debug specific
libxml2.cleanupParser()
if libxml2.debugMemory(1) == 0:
print "OK"
else:
print "Memory leak %d bytes" % (libxml2.debugMemory(1))
libxml2.dumpMemory()