1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-17 18:21:05 +03:00

Fixing some more mess with validation and recursive entities while using

* xmlreader.c python/tests/reader2py: Fixing some more mess
  with validation and recursive entities while using the
  reader interface, it's getting a bit messy...
Daniel
This commit is contained in:
Daniel Veillard
2003-01-03 01:18:43 +00:00
parent dab8ea9b83
commit 1fdfd115e5
3 changed files with 261 additions and 15 deletions

View File

@ -144,6 +144,59 @@ if err != "":
print err
sys.exit(1)
#
# Another test for recursive entity parsing, validation, and replacement of
# entities, making sure the entity ref node doesn't show up in that case
#
s = """<!DOCTYPE test [
<!ELEMENT test (x, x)>
<!ELEMENT x (y)>
<!ELEMENT y (#PCDATA)>
<!ENTITY x "<x>&y;</x>">
<!ENTITY y "<y>yyy</y>">
]>
<test>
&x;
&x;
</test>"""
expect="""1 test 0
3 #text 1
1 x 1
1 y 2
3 #text 3
15 y 2
15 x 1
3 #text 1
1 x 1
1 y 2
3 #text 3
15 y 2
15 x 1
3 #text 1
15 test 0
"""
res=""
err=""
input = libxml2.inputBuffer(StringIO.StringIO(s))
reader = input.newTextReader("test4")
reader.SetParserProp(libxml2.PARSER_LOADDTD,1)
reader.SetParserProp(libxml2.PARSER_DEFAULTATTRS,1)
reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1)
reader.SetParserProp(libxml2.PARSER_VALIDATE,1)
while reader.Read() == 1:
res = res + "%s %s %d\n" % (reader.NodeType(),reader.Name(),reader.Depth())
if res != expect:
print "test4 failed: unexpected output"
print res
sys.exit(1)
if err != "":
print "test4 failed: validation error found"
print err
sys.exit(1)
#
# cleanup
#