mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-05 19:35:54 +03:00
- tree.[ch]: fixing bug #54446, by cleaning some bugs in the
attributes handling and #54433 by adding xmlUnsetProp() and xmlUnsetNsProp() Daniel
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
Fri May 11 19:37:30 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
|
* tree.[ch]: fixing bug #54446, by cleaning some bugs in the
|
||||||
|
attributes handling and #54433 by adding xmlUnsetProp()
|
||||||
|
and xmlUnsetNsProp()
|
||||||
|
|
||||||
Fri May 11 16:07:13 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
Fri May 11 16:07:13 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
* HTMLparser.c: Patch from Jonas Borgstr<74>m
|
* HTMLparser.c: Patch from Jonas Borgstr<74>m
|
||||||
|
@@ -584,6 +584,8 @@ xmlAttrPtr xmlSetProp (xmlNodePtr node,
|
|||||||
const xmlChar *value);
|
const xmlChar *value);
|
||||||
xmlChar * xmlGetProp (xmlNodePtr node,
|
xmlChar * xmlGetProp (xmlNodePtr node,
|
||||||
const xmlChar *name);
|
const xmlChar *name);
|
||||||
|
int xmlUnsetProp (xmlNodePtr node,
|
||||||
|
const xmlChar *name);
|
||||||
xmlAttrPtr xmlHasProp (xmlNodePtr node,
|
xmlAttrPtr xmlHasProp (xmlNodePtr node,
|
||||||
const xmlChar *name);
|
const xmlChar *name);
|
||||||
xmlAttrPtr xmlSetNsProp (xmlNodePtr node,
|
xmlAttrPtr xmlSetNsProp (xmlNodePtr node,
|
||||||
@@ -593,6 +595,9 @@ xmlAttrPtr xmlSetNsProp (xmlNodePtr node,
|
|||||||
xmlChar * xmlGetNsProp (xmlNodePtr node,
|
xmlChar * xmlGetNsProp (xmlNodePtr node,
|
||||||
const xmlChar *name,
|
const xmlChar *name,
|
||||||
const xmlChar *nameSpace);
|
const xmlChar *nameSpace);
|
||||||
|
int xmlUnsetNsProp (xmlNodePtr node,
|
||||||
|
xmlNsPtr ns,
|
||||||
|
const xmlChar *name);
|
||||||
xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc,
|
xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc,
|
||||||
const xmlChar *value);
|
const xmlChar *value);
|
||||||
xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc,
|
xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc,
|
||||||
|
72
tree.c
72
tree.c
@@ -770,7 +770,7 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
|
|||||||
} else
|
} else
|
||||||
cur++;
|
cur++;
|
||||||
}
|
}
|
||||||
if (cur != q) {
|
if ((cur != q) || (ret == NULL)) {
|
||||||
/*
|
/*
|
||||||
* Handle the last piece of text.
|
* Handle the last piece of text.
|
||||||
*/
|
*/
|
||||||
@@ -4342,7 +4342,8 @@ xmlSetProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
doc = node->doc;
|
doc = node->doc;
|
||||||
while (prop != NULL) {
|
while (prop != NULL) {
|
||||||
if (xmlStrEqual(prop->name, name)) {
|
if ((xmlStrEqual(prop->name, name)) &&
|
||||||
|
(prop->ns == NULL)){
|
||||||
if (prop->children != NULL)
|
if (prop->children != NULL)
|
||||||
xmlFreeNodeList(prop->children);
|
xmlFreeNodeList(prop->children);
|
||||||
prop->children = NULL;
|
prop->children = NULL;
|
||||||
@@ -4373,6 +4374,36 @@ xmlSetProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
|
|||||||
return(prop);
|
return(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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:
|
* xmlSetNsProp:
|
||||||
* @node: the node
|
* @node: the node
|
||||||
@@ -4440,6 +4471,43 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
|
|||||||
return(prop);
|
return(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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:
|
* xmlNodeIsText:
|
||||||
* @node: the node
|
* @node: the node
|
||||||
|
5
tree.h
5
tree.h
@@ -584,6 +584,8 @@ xmlAttrPtr xmlSetProp (xmlNodePtr node,
|
|||||||
const xmlChar *value);
|
const xmlChar *value);
|
||||||
xmlChar * xmlGetProp (xmlNodePtr node,
|
xmlChar * xmlGetProp (xmlNodePtr node,
|
||||||
const xmlChar *name);
|
const xmlChar *name);
|
||||||
|
int xmlUnsetProp (xmlNodePtr node,
|
||||||
|
const xmlChar *name);
|
||||||
xmlAttrPtr xmlHasProp (xmlNodePtr node,
|
xmlAttrPtr xmlHasProp (xmlNodePtr node,
|
||||||
const xmlChar *name);
|
const xmlChar *name);
|
||||||
xmlAttrPtr xmlSetNsProp (xmlNodePtr node,
|
xmlAttrPtr xmlSetNsProp (xmlNodePtr node,
|
||||||
@@ -593,6 +595,9 @@ xmlAttrPtr xmlSetNsProp (xmlNodePtr node,
|
|||||||
xmlChar * xmlGetNsProp (xmlNodePtr node,
|
xmlChar * xmlGetNsProp (xmlNodePtr node,
|
||||||
const xmlChar *name,
|
const xmlChar *name,
|
||||||
const xmlChar *nameSpace);
|
const xmlChar *nameSpace);
|
||||||
|
int xmlUnsetNsProp (xmlNodePtr node,
|
||||||
|
xmlNsPtr ns,
|
||||||
|
const xmlChar *name);
|
||||||
xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc,
|
xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc,
|
||||||
const xmlChar *value);
|
const xmlChar *value);
|
||||||
xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc,
|
xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc,
|
||||||
|
Reference in New Issue
Block a user