[xml] Namespace issue with empty element using SAX (patch)



I ran into an issue when an empty element declares a namespace, the namespace doesnt get popped off the stack correctly.
i.e.:
<root>
   <foo xmlns="abc" />
   <bar />
</root>

bar ends up in the abc namespace.

The following patch pops the namespace for empty elements.

Index: parser.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/parser.c,v
retrieving revision 1.406
diff -c -r1.406 parser.c
*** parser.c    25 Dec 2004 10:14:57 -0000    1.406
--- parser.c    4 Jan 2005 21:01:28 -0000
***************
*** 9256,9261 ****
--- 9260,9268 ----
                 (!ctxt->disableSAX))
                 ctxt->sax->endElementNs(ctxt->userData, name,
                                         prefix, URI);
+             nsNr = (int) (long) ctxt->pushTab[ctxt->nameNr * 3 - 1];
+             if (nsNr > 0)
+                 nsPop(ctxt, nsNr);
 #ifdef LIBXML_SAX1_ENABLED
             } else {
             if ((ctxt->sax != NULL) &&




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]