From 571b889b6b4a694e0b9ac52402675fe83195b42f Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Mon, 30 Dec 2002 12:37:59 +0000 Subject: [PATCH] =?UTF-8?q?fixed=20another=20problem=20pointed=20by=20St?= =?UTF-8?q?=E9phane=20Bidoul=20Daniel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * xmlreader.c python/tests/reader.py: fixed another problem pointed by Stéphane Bidoul Daniel --- ChangeLog | 5 +++ python/tests/reader.py | 71 +++++++++++++++++++++++++----------------- xmlreader.c | 3 +- 3 files changed, 50 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8123da5f..5af961af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Dec 30 13:36:50 CET 2002 Daniel Veillard + + * xmlreader.c python/tests/reader.py: fixed another problem + pointed by Stéphane Bidoul + Mon Dec 30 12:39:55 CET 2002 Daniel Veillard * xmlreader.c python/tests/reader.py: fixed a limit case problem diff --git a/python/tests/reader.py b/python/tests/reader.py index c8741603..be16b53d 100755 --- a/python/tests/reader.py +++ b/python/tests/reader.py @@ -235,34 +235,6 @@ if reader.MoveToNextAttribute() != 0: print "Failed to detect last attribute" sys.exit(1) -# -# Another test provided by Stéphane Bidoul and checked with C# -# -expect="""1 (a) [None] -1 (b) [None] --- 2 (b1) [b1] -1 (c) [None] -3 (#text) [content of c] -15 (c) [None] -15 (a) [None] -""" -res="" -f = StringIO.StringIO("""content of c""") -input = libxml2.inputBuffer(f) -reader = input.newTextReader("test5") - -while reader.Read(): - res=res + "%s (%s) [%s]\n" % (reader.NodeType(),reader.Name(), - reader.Value()) - if reader.NodeType() == 1: # Element - while reader.MoveToNextAttribute(): - res = res + "-- %s (%s) [%s]\n" % (reader.NodeType(), - reader.Name(),reader.Value()) - -if res != expect: - print "test5 failed" - print res - sys.exit(1) # # a couple of tests for namespace nodes @@ -319,6 +291,49 @@ if ret != 0: print "test8: failed to detect the EOF" sys.exit(1) +# +# Another test provided by Stéphane Bidoul and checked with C# +# +def tst_reader(s): + f = StringIO.StringIO(s) + input = libxml2.inputBuffer(f) + reader = input.newTextReader("tst") + res = "" + while reader.Read(): + res=res + "%s (%s) [%s] %d\n" % (reader.NodeType(),reader.Name(), + reader.Value(), reader.IsEmptyElement()) + if reader.NodeType() == 1: # Element + while reader.MoveToNextAttribute(): + res = res + "-- %s (%s) [%s]\n" % (reader.NodeType(), + reader.Name(),reader.Value()) + return res + +doc="""content of c""" +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 +""" +res = tst_reader(doc) +if res != expect: + print "test5 failed" + print res + sys.exit(1) + +doc="""""" +expect="""1 (test) [None] 0 +1 (b) [None] 1 +1 (c) [None] 1 +15 (test) [None] 0 +""" +res = tst_reader(doc) +if res != expect: + print "test5 failed" + print res + sys.exit(1) # # cleanup for memory allocation counting diff --git a/xmlreader.c b/xmlreader.c index 2b2436d6..bd0ba72e 100644 --- a/xmlreader.c +++ b/xmlreader.c @@ -431,7 +431,8 @@ xmlTextReaderRead(xmlTextReaderPtr reader) { return(1); } if ((oldstate == XML_TEXTREADER_ELEMENT) && - (reader->node->type == XML_ELEMENT_NODE)) { + (reader->node->type == XML_ELEMENT_NODE) && + (wasempty == 0)) { reader->state = XML_TEXTREADER_END; DUMP_READER return(1);