fixed another pair of problem pointed by Stéphane Bidoul: depth start at 0
* xmlreader.c python/tests/reader.py: fixed another pair of problem
pointed by Stéphane Bidoul: depth start at 0 and a parse problem.
Daniel
diff --git a/ChangeLog b/ChangeLog
index 5af961a..314709e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/python/tests/reader.py b/python/tests/reader.py
index be16b53..69724bd 100755
--- a/python/tests/reader.py
+++ b/python/tests/reader.py
@@ -300,22 +300,24 @@
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 @@
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)
diff --git a/xmlreader.c b/xmlreader.c
index bd0ba72..a65a1bf 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -369,9 +369,9 @@
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 @@
reader->mode = XML_TEXTREADER_DONE;
}
reader->node = NULL;
- reader->depth = 0;
+ reader->depth = -1;
/*
* Cleanup of the old node