- tree.[ch]: fixing bug #54446, by cleaning some bugs in the
  attributes handling and #54433 by adding xmlUnsetProp()
  and xmlUnsetNsProp()
Daniel
diff --git a/tree.c b/tree.c
index 3f6bcbf..16d6486 100644
--- a/tree.c
+++ b/tree.c
@@ -770,7 +770,7 @@
 	} else
 	    cur++;
     }
-    if (cur != q) {
+    if ((cur != q) || (ret == NULL)) {
         /*
 	 * Handle the last piece of text.
 	 */
@@ -4342,7 +4342,8 @@
 	return(NULL);
     doc = node->doc;
     while (prop != NULL) {
-        if (xmlStrEqual(prop->name, name)) {
+        if ((xmlStrEqual(prop->name, name)) &&
+	    (prop->ns == NULL)){
 	    if (prop->children != NULL) 
 	        xmlFreeNodeList(prop->children);
 	    prop->children = NULL;
@@ -4364,7 +4365,7 @@
 		    tmp = tmp->next;
 		}
 		xmlFree(buffer);
-	    }	
+	    }
 	    return(prop);
 	}
 	prop = prop->next;
@@ -4374,6 +4375,36 @@
 }
 
 /**
+ * xmlUnsetProp:
+ * @node:  the node
+ * @name:  the attribute name
+ *
+ * Remove an attribute carried by a node.
+ * Returns 0 if successful, -1 if not found
+ */
+int
+xmlUnsetProp(xmlNodePtr node, const xmlChar *name) {
+    xmlAttrPtr prop = node->properties, prev = NULL;;
+
+    if ((node == NULL) || (name == NULL))
+	return(-1);
+    while (prop != NULL) {
+        if ((xmlStrEqual(prop->name, name)) &&
+	    (prop->ns == NULL)) {
+	    if (prev == NULL)
+		node->properties = prop->next;
+	    else
+		prev->next = prop->next;
+	    xmlFreeProp(prop);
+	    return(0);
+	}
+	prev = prop;
+	prop = prop->next;
+    }
+    return(-1);
+}
+
+/**
  * xmlSetNsProp:
  * @node:  the node
  * @ns:  the namespace definition
@@ -4441,6 +4472,43 @@
 }
 
 /**
+ * xmlUnsetNsProp:
+ * @node:  the node
+ * @ns:  the namespace definition
+ * @name:  the attribute name
+ *
+ * Remove an attribute carried by a node.
+ * Returns 0 if successful, -1 if not found
+ */
+int
+xmlUnsetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name) {
+    xmlAttrPtr prop = node->properties, prev = NULL;;
+
+    if ((node == NULL) || (name == NULL))
+	return(-1);
+    if (ns == NULL)
+	return(xmlUnsetProp(node, name));
+    if (ns->href == NULL)
+	return(-1);
+    while (prop != NULL) {
+        if ((xmlStrEqual(prop->name, name)) &&
+	    (((prop->ns == NULL) && (node->ns != NULL) &&
+	      (xmlStrEqual(node->ns->href, ns->href))) ||
+	     ((prop->ns != NULL) && (xmlStrEqual(prop->ns->href, ns->href))))) {
+	    if (prev == NULL)
+		node->properties = prop->next;
+	    else
+		prev->next = prop->next;
+	    xmlFreeProp(prop);
+	    return(0);
+	}
+	prev = prop;
+	prop = prop->next;
+    }
+    return(-1);
+}
+
+/**
  * xmlNodeIsText:
  * @node:  the node
  *