After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 164142 - current namespace isn't popped in empty element
current namespace isn't popped in empty element
Status: VERIFIED FIXED
Product: libxml2
Classification: Platform
Component: general
2.6.16
Other All
: Normal major
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2005-01-15 04:05 UTC by Sarah Wilkin
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
augmented reader example (2.61 KB, application/octet-stream)
2005-01-15 04:13 UTC, Sarah Wilkin
  Details
test case (163 bytes, application/xml)
2005-01-15 04:14 UTC, Sarah Wilkin
  Details
patch for parser.c (349 bytes, patch)
2005-01-15 04:15 UTC, Sarah Wilkin
none Details | Review

Description Sarah Wilkin 2005-01-15 04:05:10 UTC
Augment sample reader1.c code after node info printf:
	if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {
		printf(" num attrs:%d", xmlTextReaderAttributeCount(reader));
	}

Run it with the following case:
<test>
	<child><default xmlns="http://example.com"/></child>
	<child>shouldn't have a namespace added</child>
	<child xmlns="">should report empty</child>
</test>

emptyxmlns.xml:3: warning: Namespace prefix (null) was not found
        <child>shouldn't have a namespace added</child>
              ^
0 1 test 0 0 num attrs:0
1 14 #text 0 1 

1 1 child 0 0 num attrs:0
2 1 default 1 0 num attrs:1
1 15 child 0 0
1 14 #text 0 1 

1 1 child 0 0 num attrs:1 <--- there shouldn't be an attribute here (it's a NULL namespace)
2 3 #text 0 1 shouldn't have a namespace added
1 15 child 0 0
1 14 #text 0 1 

1 1 child 0 0 num attrs:1
2 3 #text 0 1 should report empty
1 15 child 0 0
1 14 #text 0 1 


Patch diffed with 2.6.16: (based off of behaviour in xmlParseElement):
--- parser.c.orig       2005-01-14 19:30:54.000000000 -0800
+++ parser.c    2005-01-14 19:49:11.000000000 -0800
@@ -9262,6 +9262,8 @@
 #endif /* LIBXML_SAX1_ENABLED */
                    }
                    spacePop(ctxt);
+                       if (nsNr != ctxt->nsNr)
+                               nsPop(ctxt, ctxt->nsNr - nsNr);             
                    if (ctxt->nameNr == 0) {
                        ctxt->instate = XML_PARSER_EPILOG;
                    } else {
Comment 1 Sarah Wilkin 2005-01-15 04:13:17 UTC
Created attachment 36045 [details]
augmented reader example

Reader1 example augmented to display the # of attributes (including namespaces)
on an element.
Comment 2 Sarah Wilkin 2005-01-15 04:14:40 UTC
Created attachment 36046 [details]
test case
Comment 3 Sarah Wilkin 2005-01-15 04:15:53 UTC
Created attachment 36047 [details] [review]
patch for parser.c
Comment 4 Daniel Veillard 2005-01-15 10:22:41 UTC
Yes this is a real bug, but this was already fixed in CVS since the last
release:

paphio:~/XML -> cvs -z9 diff -rLIBXML2_2_6_16 parser.c | grep -C5 nsPop
@@ -9253,6 +9260,8 @@
                            (!ctxt->disableSAX))
                            ctxt->sax->endElementNs(ctxt->userData, name,
                                                    prefix, URI);
+                       if (ctxt->nsNr - nsNr > 0)
+                           nsPop(ctxt, ctxt->nsNr - nsNr);
 #ifdef LIBXML_SAX1_ENABLED
                    } else {
                        if ((ctxt->sax != NULL) &&
@@ -9921,8 +9930,10 @@
         return;
paphio:~/XML ->

  thanks anyway !

Daniel
Comment 5 Daniel Veillard 2005-01-17 22:48:24 UTC
 This should be closed by release of libxml2-2.6.17,

   thanks,

Daniel