diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2005-04-12 01:02:29 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2005-04-12 01:02:29 +0000 |
commit | f9cf6f5a01527406ed0bcbcf5a180d85b5e771de (patch) | |
tree | 5769339469c55feb02e674e6e13457bed9bffe34 /python/libxml.c | |
parent | d49370e9c5eaf481d1bd49eaab711e743af8de54 (diff) | |
download | libxml2-f9cf6f5a01527406ed0bcbcf5a180d85b5e771de.tar.gz |
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
Diffstat (limited to 'python/libxml.c')
-rw-r--r-- | python/libxml.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/python/libxml.c b/python/libxml.c index b18f887e..8fc63f88 100644 --- a/python/libxml.c +++ b/python/libxml.c @@ -2661,6 +2661,55 @@ libxml_xmlNodeGetNsDefs(ATTRIBUTE_UNUSED PyObject * self, PyObject * args) } 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) { PyObject *py_retval; @@ -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 |