diff --git a/ChangeLog b/ChangeLog index 385a8eae..2d82ecdb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Jan 10 00:16:49 CET 2003 Daniel Veillard + + * parser.c: one more IsEmptyElement crazyness, that time in + external parsed entities if substitution is asked. + * python/tests/reader3.py: added a specific test. + Thu Jan 9 22:35:31 CET 2003 Daniel Veillard * python/drv_libxml2.py: update from Stéphane Bidoul: python 2.1 diff --git a/parser.c b/parser.c index 54159d3e..cb2be96a 100644 --- a/parser.c +++ b/parser.c @@ -5599,10 +5599,13 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { cur = ent->children; while (cur != NULL) { new = xmlCopyNode(cur, 1); - if (firstChild == NULL){ - firstChild = new; + if (new != NULL) { + new->_private = cur->_private; + if (firstChild == NULL){ + firstChild = new; + } + xmlAddChild(ctxt->node, new); } - xmlAddChild(ctxt->node, new); if (cur == ent->last) break; cur = cur->next; diff --git a/python/tests/reader3.py b/python/tests/reader3.py index 2a4fbe07..2458c89e 100755 --- a/python/tests/reader3.py +++ b/python/tests/reader3.py @@ -104,6 +104,41 @@ if ret != 0: print "test_noent: Error detecting the end" sys.exit(1) +# +# third test, crazy stuff about empty element in external parsed entities +# +s = """ +]> +&simplestruct2.ent; +""" +expect="""10 struct 0 0 +1 struct 0 0 +1 descr 1 1 +15 struct 0 0 +""" +res="" +simplestruct2_ent="""""" + +def myResolver(URL, ID, ctxt): + if URL == "simplestruct2.ent": + return(StringIO.StringIO(simplestruct2_ent)) + return None + +libxml2.setEntityLoader(myResolver) + +input = libxml2.inputBuffer(StringIO.StringIO(s)) +reader = input.newTextReader("test3") +reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) +while reader.Read() == 1: + res = res + "%s %s %d %d\n" % (reader.NodeType(),reader.Name(), + reader.Depth(),reader.IsEmptyElement()) + +if res != expect: + print "test3 failed: unexpected output" + print res + sys.exit(1) + # # cleanup #