1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

fixed another pair of problem pointed by Stphane Bidoul: depth start at 0

* xmlreader.c python/tests/reader.py: fixed another pair of problem
  pointed by Stphane Bidoul: depth start at 0 and a parse problem.
Daniel
This commit is contained in:
Daniel Veillard 2002-12-30 18:40:42 +00:00
parent 571b889b6b
commit 4d8db8a22c
3 changed files with 42 additions and 19 deletions

View File

@ -1,3 +1,8 @@
Mon Dec 30 19:39:36 CET 2002 Daniel Veillard <daniel@veillard.com>
* xmlreader.c python/tests/reader.py: fixed another pair of problem
pointed by Stéphane Bidoul: depth start at 0 and a parse problem.
Mon Dec 30 13:36:50 CET 2002 Daniel Veillard <daniel@veillard.com>
* xmlreader.c python/tests/reader.py: fixed another problem

View File

@ -300,22 +300,24 @@ def tst_reader(s):
reader = input.newTextReader("tst")
res = ""
while reader.Read():
res=res + "%s (%s) [%s] %d\n" % (reader.NodeType(),reader.Name(),
reader.Value(), reader.IsEmptyElement())
res=res + "%s (%s) [%s] %d %d\n" % (reader.NodeType(),reader.Name(),
reader.Value(), reader.IsEmptyElement(),
reader.Depth())
if reader.NodeType() == 1: # Element
while reader.MoveToNextAttribute():
res = res + "-- %s (%s) [%s]\n" % (reader.NodeType(),
reader.Name(),reader.Value())
res = res + "-- %s (%s) [%s] %d\n" % (reader.NodeType(),
reader.Name(),reader.Value(),
reader.Depth())
return res
doc="""<a><b b1="b1"/><c>content of c</c></a>"""
expect="""1 (a) [None] 0
1 (b) [None] 1
-- 2 (b1) [b1]
1 (c) [None] 0
3 (#text) [content of c] 0
15 (c) [None] 0
15 (a) [None] 0
expect="""1 (a) [None] 0 0
1 (b) [None] 1 1
-- 2 (b1) [b1] 2
1 (c) [None] 0 1
3 (#text) [content of c] 0 2
15 (c) [None] 0 1
15 (a) [None] 0 0
"""
res = tst_reader(doc)
if res != expect:
@ -324,14 +326,30 @@ if res != expect:
sys.exit(1)
doc="""<test><b/><c/></test>"""
expect="""1 (test) [None] 0
1 (b) [None] 1
1 (c) [None] 1
15 (test) [None] 0
expect="""1 (test) [None] 0 0
1 (b) [None] 1 1
1 (c) [None] 1 1
15 (test) [None] 0 0
"""
res = tst_reader(doc)
if res != expect:
print "test5 failed"
print "test9 failed"
print res
sys.exit(1)
doc="""<a><b>bbb</b><c>ccc</c></a>"""
expect="""1 (a) [None] 0 0
1 (b) [None] 0 1
3 (#text) [bbb] 0 2
15 (b) [None] 0 1
1 (c) [None] 0 1
3 (#text) [ccc] 0 2
15 (c) [None] 0 1
15 (a) [None] 0 0
"""
res = tst_reader(doc)
if res != expect:
print "test10 failed"
print res
sys.exit(1)

View File

@ -369,9 +369,9 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
if (reader->node == NULL)
return(-1);
} else {
reader->node = reader->ctxt->node;
reader->node = reader->ctxt->nodeTab[0];
}
reader->depth = 1;
reader->depth = 0;
return(1);
}
oldstate = reader->state;
@ -449,7 +449,7 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
reader->mode = XML_TEXTREADER_DONE;
}
reader->node = NULL;
reader->depth = 0;
reader->depth = -1;
/*
* Cleanup of the old node