Hash :
e18fc185
Author :
Date :
2002-12-28T22:56:33
extended the XmlTextReader API a bit, addding accessors for the current * xmlreader.c include/libxml/xmlreader.h doc/libxml2-api.xml: extended the XmlTextReader API a bit, addding accessors for the current doc and node, and an entity substitution mode for the parser. * python/libxml.py python/libxml2class.txt: related updates * python/tests/Makefile.am python/tests/reader.py python/tests/reader2.py python/tests/reader3.py: updated a bit the old tests and added a new one to test the entities handling 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 DTD 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()