Error with xmlns:prefix= with namespace processing enabled.
It seems that storeAtts() has the following properties:
- when called with tagNamePtr = NULL and bindingsPtr = NULL,
it does not process attributes incl. namespace declarations
- when called with all arguments non-NULL it processes
attributes (incl. default attributes) and namespace declarations
We also have these requirements:
A) for start of element event:
1) if we have a startElementHandler:
we need to process at least default attributes,
so we must call storeAtts with all arguments non-NULL
2) if we have no startElementHandler, but we have attributes:
we need to process namespace declarations,
so we must call storeAtts with all arguments non-NULL
3) if we have no startElementHandler and no attributes:
we need to store the name (for the end element event, where
the names are compared) and call only the default handler
Note: Storing the name is a pre-requisiste for calling
storeAtts with all arguments non-NULL.
So there really is no place for calling storeAtts with
tagNamePtr = NULL and bindingsPtr = NULL.
B) for empty element event:
1) if we have a startElementHandler:
we need to process at least default attributes,
so we must call storeAtts with all arguments non-NULL
2) if we have no startElementHandler, but we have attributes:
we need to process namespace declarations,
so we must call storeAtts with all arguments non-NULL
3) if we have no startElementHandler and no attributes,
but we have an endElementHandler:
we need to store the name for calling the handler,
but we need not process any attributes (default or not)
4) if we have no start- or endElementHandler, and no attributes:
we need to call only the default handler
Given that storeAtts will now always be called with all arguments
non-NULL we could remove a few internal checks in storeAtts,
if that improves efficiency. Not sure if that is worth it.
This patch should therefore fix the problem of namespace declarations
not being processed when no startElementHandler is set, that is,
it will fix Jeremy's NS processing patch.
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.
Implemented with two API additions:
1) For element declaration handler support:
XML_FreeContentModel
2) Exposing Expat's memory allocation functions:
XML_MemMalloc
XML_MemRealloc
XML_MemFree