diff --git a/SAX2.c b/SAX2.c index 84c1f00..c0482c0 100644 --- a/SAX2.c +++ b/SAX2.c @@ -2242,8 +2242,12 @@ xmlSAX2StartElementNs(void *ctx, if ((URI != NULL) && (prefix == pref)) ret->ns = ns; } else { - xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs"); - return; + /* + * any out of memory error would already have been raised + * but we can't be garanteed it's the actual error due to the + * API, best is to skip in this case + */ + continue; } #ifdef LIBXML_VALID_ENABLED if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed && diff --git a/tree.c b/tree.c index 1e1a23a..24db82a 100644 --- a/tree.c +++ b/tree.c @@ -721,8 +721,19 @@ xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix) { if ((node != NULL) && (node->type != XML_ELEMENT_NODE)) return(NULL); - if ((prefix != NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) - return(NULL); + if ((prefix != NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) { + /* xml namespace is predefined, no need to add it */ + if (xmlStrEqual(href, XML_XML_NAMESPACE)) + return(NULL); + + /* + * Problem, this is an attempt to bind xml prefix to a wrong + * namespace, which breaks + * Namespace constraint: Reserved Prefixes and Namespace Names + * from XML namespace. But documents authors may not care in + * their context so let's proceed. + */ + } /* * Allocate a new Namespace and fill the fields.