#
# this tests the entities substitutions with the XmlTextReader interface
#
import sys
import StringIO
import libxml2
docstr="""<?xml version='1.0'?>
<!DOCTYPE doc [
<!ENTITY tst "<p>test</p>">
]>
<doc>&tst;</doc>"""
# Memory debug specific
#
# First test, normal don't substitute entities.
#
if ret != 1:
print "Error reading to root"
if ret != 1:
print "Error reading to root"
print "test_normal: Error reading the root element"
if ret != 1:
print "test_normal: Error reading to the entity"
print "test_normal: Error reading the entity"
if ret != 1:
print "test_normal: Error reading to the end of root"
print "test_normal: Error reading the end of the root element"
if ret != 0:
print "test_normal: Error detecting the end"
#
# Second test, completely substitute the entities.
#
if ret != 1:
print "Error reading to root"
if ret != 1:
print "Error reading to root"
print "test_noent: Error reading the root element"
if ret != 1:
print "test_noent: Error reading to the entity content"
print "test_noent: Error reading the p element from entity"
if ret != 1:
print "test_noent: Error reading to the text node"
print "test_noent: Error reading the text node"
if ret != 1:
print "test_noent: Error reading to the end of p element"
print "test_noent: Error reading the end of the p element"
if ret != 1:
print "test_noent: Error reading to the end of root"
print "test_noent: Error reading the end of the root element"
if ret != 0:
print "test_noent: Error detecting the end"
#
# third test, crazy stuff about empty element in external parsed entities
#
s = """<!DOCTYPE struct [
<!ENTITY simplestruct2.ent SYSTEM "simplestruct2.ent">
]>
<struct>&simplestruct2.ent;</struct>
"""
expect="""10 struct 0 0
1 struct 0 0
1 descr 1 1
15 struct 0 0
"""
simplestruct2_ent="""<descr/>"""
if URL == "simplestruct2.ent":
return None
print "test3 failed: unexpected output"
print res
#
# cleanup
#
del f
del input
del reader
# Memory debug specific
print "OK"
else: