expat/lib xmlparse.c,1.103,1.104
"Karl Waclawek" <[email protected]>
| Newsgroups | gmane.text.xml.expat.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/expat/expat/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv30438
Modified Files:
xmlparse.c
Log Message:
For the start of element and end of element events, it is possible that
the default handler does not get called even when no element handlers
are called, because storeAtts() may trigger the startNamespaceDeclHandler
where the application has a chance to clear the element handlers.
This patch fixes this with one issue still open, which applies to empty elements only:
When the endElement handler is called, but not the startElementHandler,
then the default handler is not called, which causes attributes to not
be reported at all. The other alternative would be to call the default handler,
but then the element would be reported twice.
Index: xmlparse.c
===================================================================
RCS file: /cvsroot/expat/expat/lib/xmlparse.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- xmlparse.c 22 Jan 2003 14:26:07 -0000 1.103
+++ xmlparse.c 22 Jan 2003 14:52:20 -0000 1.104
@@ -2116,6 +2116,8 @@
if (startElementHandler)
startElementHandler(handlerArg, tag->name.str,
(const XML_Char **)atts);
+ else if (defaultHandler)
+ reportDefault(parser, enc, s, next);
}
else if (defaultHandler)
reportDefault(parser, enc, s, next);
@@ -2134,6 +2136,7 @@
const char *rawName = s + enc->minBytesPerChar;
enum XML_Error result;
BINDING *bindings = NULL;
+ XML_Bool noElmHandlers = XML_TRUE;
TAG_NAME name;
name.str = poolStoreString(&tempPool, enc, rawName,
rawName + XmlNameLength(enc, rawName));
@@ -2144,13 +2147,18 @@
if (result)
return result;
poolFinish(&tempPool);
- if (startElementHandler)
+ if (startElementHandler) {
startElementHandler(handlerArg, name.str, (const XML_Char **)atts);
+ noElmHandlers = XML_FALSE;
+ }
if (endElementHandler) {
if (startElementHandler)
*eventPP = *eventEndPP;
endElementHandler(handlerArg, name.str);
+ noElmHandlers = XML_FALSE;
}
+ if (noElmHandlers && defaultHandler)
+ reportDefault(parser, enc, s, next);
poolClear(&tempPool);
while (bindings) {
BINDING *b = bindings;