1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-23 15:01:05 +03:00

seriously changed the way data are pushed to the underlying parser, go by

* xmlreader.c: seriously changed the way data are pushed to
  the underlying parser, go by block of 512 bytes instead of
  tryng to detect tag boundaries at that level. Changed the
  way empty element are detected and tagged.
* python/tests/reader.py python/tests/reader2.py
  python/tests/reader3.py: small changes mostly due to context
  reporting being different and DTD node being reported. Some
  errors previously undetected are now caught and fixed.
* doc/xmlreader.html: flagged last section as TODO
Daniel
This commit is contained in:
Daniel Veillard
2003-01-05 01:27:54 +00:00
parent 51a447a578
commit 067bae5ff8
6 changed files with 78 additions and 80 deletions

View File

@ -14,56 +14,56 @@ input = libxml2.inputBuffer(f)
reader = input.newTextReader("test1")
ret = reader.Read()
if ret != 1:
print "Error reading to first element"
print "test1: Error reading to first element"
sys.exit(1)
if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \
reader.NodeType() != 1 or reader.HasAttributes() != 0:
print "Error reading the first element"
print "test1: Error reading the first element"
sys.exit(1)
ret = reader.Read()
if ret != 1:
print "Error reading to second element"
print "test1: Error reading to second element"
sys.exit(1)
if reader.Name() != "b" or reader.IsEmptyElement() != 1 or \
reader.NodeType() != 1 or reader.HasAttributes() != 1:
print "Error reading the second element"
print "test1: Error reading the second element"
sys.exit(1)
ret = reader.Read()
if ret != 1:
print "Error reading to third element"
print "test1: Error reading to third element"
sys.exit(1)
if reader.Name() != "c" or reader.IsEmptyElement() != 0 or \
reader.NodeType() != 1 or reader.HasAttributes() != 0:
print "Error reading the third element"
print "test1: Error reading the third element"
sys.exit(1)
ret = reader.Read()
if ret != 1:
print "Error reading to text node"
print "test1: Error reading to text node"
sys.exit(1)
if reader.Name() != "#text" or reader.IsEmptyElement() != 0 or \
reader.NodeType() != 3 or reader.HasAttributes() != 0 or \
reader.Value() != "content of c":
print "Error reading the text node"
print "test1: Error reading the text node"
sys.exit(1)
ret = reader.Read()
if ret != 1:
print "Error reading to end of third element"
print "test1: Error reading to end of third element"
sys.exit(1)
if reader.Name() != "c" or reader.IsEmptyElement() != 0 or \
reader.NodeType() != 15 or reader.HasAttributes() != 0:
print "Error reading the end of third element"
print "test1: Error reading the end of third element"
sys.exit(1)
ret = reader.Read()
if ret != 1:
print "Error reading to end of first element"
print "test1: Error reading to end of first element"
sys.exit(1)
if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \
reader.NodeType() != 15 or reader.HasAttributes() != 0:
print "Error reading the end of first element"
print "test1: Error reading the end of first element"
sys.exit(1)
ret = reader.Read()
if ret != 0:
print "Error reading to end of document"
print "test1: Error reading to end of document"
sys.exit(1)
#
@ -239,7 +239,7 @@ if reader.MoveToNextAttribute() != 0:
#
# a couple of tests for namespace nodes
#
f = StringIO.StringIO("""<a xmlns="http://example.com/foo">""")
f = StringIO.StringIO("""<a xmlns="http://example.com/foo"/>""")
input = libxml2.inputBuffer(f)
reader = input.newTextReader("test6")
ret = reader.Read()
@ -256,7 +256,7 @@ if reader.NamespaceUri() != "http://www.w3.org/2000/xmlns/" or \
print "test6: failed to read the namespace node"
sys.exit(1)
f = StringIO.StringIO("""<a xmlns:prefix="http://example.com/foo">""")
f = StringIO.StringIO("""<a xmlns:prefix="http://example.com/foo"/>""")
input = libxml2.inputBuffer(f)
reader = input.newTextReader("test7")
ret = reader.Read()

View File

@ -14,13 +14,13 @@ libxml2.debugMemory(1)
err=""
expect="""../../test/valid/rss.xml:172: validity error: Element rss does not carry attribute version
</rss>
^
^
../../test/valid/xlink.xml:450: validity error: ID dt-arc already defined
<p><termdef id="dt-arc" term="Arc">
<p><termdef id="dt-arc" term="Arc">An <term>arc</term> is contained within an
^
../../test/valid/xlink.xml:529: validity error: attribute def line 199 references an unknown ID "dt-xlg"
<?Pub *0000052575?>
^
../../test/valid/xlink.xml:530: validity error: attribute def line 199 references an unknown ID "dt-xlg"
^
"""
def callback(ctx, str):
global err
@ -61,7 +61,8 @@ s = """
<b>bbb</b>
</test>
"""
expect="""1,test
expect="""10,test
1,test
3,#text
1,x
1,c
@ -110,7 +111,8 @@ s = """<!DOCTYPE test [
</test>
"""
tst_ent = """<x>hello</x>"""
expect="""1 test
expect="""10 test
1 test
3 #text
1 x
3 #text
@ -161,7 +163,8 @@ s = """<!DOCTYPE test [
&x;
&x;
</test>"""
expect="""1 test 0
expect="""10 test 0
1 test 0
3 #text 1
1 x 1
1 y 2
@ -213,7 +216,8 @@ s = """<!DOCTYPE test [
&x;
&x;
</test>"""
expect="""1 test 0
expect="""10 test 0
1 test 0
3 #text 1
5 x 1
3 #text 1

View File

@ -1,6 +1,6 @@
#!/usr/bin/python -u
#
# this tests the validation with the XmlTextReader interface
# this tests the entities substitutions with the XmlTextReader interface
#
import sys
import StringIO
@ -22,6 +22,11 @@ f = StringIO.StringIO(docstr)
input = libxml2.inputBuffer(f)
reader = input.newTextReader("test_noent")
ret = reader.Read()
if ret != 1:
print "Error reading to root"
sys.exit(1)
if reader.Name() == "doc" or reader.NodeType() == 10:
ret = reader.Read()
if ret != 1:
print "Error reading to root"
sys.exit(1)
@ -55,6 +60,11 @@ input = libxml2.inputBuffer(f)
reader = input.newTextReader("test_noent")
reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES, 1)
ret = reader.Read()
if ret != 1:
print "Error reading to root"
sys.exit(1)
if reader.Name() == "doc" or reader.NodeType() == 10:
ret = reader.Read()
if ret != 1:
print "Error reading to root"
sys.exit(1)