1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-18 16:08:59 +03:00

applied patch from Brent Hendricks adding namespace removal at the python

* python/libxml.c python/libxml.py: applied patch from Brent Hendricks
  adding namespace removal at the python level #300209
* python/tests/Makefile.am python/tests/nsdel.py: added the regression
  test
Daniel
This commit is contained in:
Daniel Veillard
2005-04-12 01:02:29 +00:00
parent d49370e9c5
commit f9cf6f5a01
5 changed files with 141 additions and 0 deletions

View File

@@ -2660,6 +2660,55 @@ libxml_xmlNodeGetNsDefs(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
return (py_retval);
}
PyObject *
libxml_xmlNodeRemoveNsDef(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
{
PyObject *py_retval;
xmlNsPtr ns, prev;
xmlNodePtr node;
PyObject *pyobj_node;
xmlChar *href;
xmlNsPtr c_retval;
if (!PyArg_ParseTuple
(args, (char *) "Oz:xmlNodeRemoveNsDef", &pyobj_node, &href))
return (NULL);
node = (xmlNodePtr) PyxmlNode_Get(pyobj_node);
ns = NULL;
if ((node == NULL) || (node->type != XML_ELEMENT_NODE)) {
Py_INCREF(Py_None);
return (Py_None);
}
if (href == NULL) {
ns = node->nsDef;
node->nsDef = NULL;
c_retval = 0;
}
else {
prev = NULL;
ns = node->nsDef;
while (ns != NULL) {
if (xmlStrEqual(ns->href, href)) {
if (prev != NULL)
prev->next = ns->next;
else
node->nsDef = ns->next;
ns->next = NULL;
c_retval = 0;
break;
}
prev = ns;
ns = ns->next;
}
}
c_retval = ns;
py_retval = libxml_xmlNsPtrWrap((xmlNsPtr) c_retval);
return (py_retval);
}
PyObject *
libxml_xmlNodeGetNs(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
{
@@ -3640,6 +3689,7 @@ static PyMethodDef libxmlMethods[] = {
{(char *) "type", libxml_type, METH_VARARGS, NULL},
{(char *) "doc", libxml_doc, METH_VARARGS, NULL},
{(char *) "xmlNewNode", libxml_xmlNewNode, METH_VARARGS, NULL},
{(char *) "xmlNodeRemoveNsDef", libxml_xmlNodeRemoveNsDef, METH_VARARGS, NULL},
{(char *)"xmlSetValidErrors", libxml_xmlSetValidErrors, METH_VARARGS, NULL},
{(char *)"xmlFreeValidCtxt", libxml_xmlFreeValidCtxt, METH_VARARGS, NULL},
#ifdef LIBXML_OUTPUT_ENABLED