diff options
author | Jacek Konieczny <jajcus@jajcus.net> | 2005-06-26 20:56:58 +0400 |
---|---|---|
committer | Jacek Konieczny <jajcus@jajcus.net> | 2005-06-26 20:56:58 +0400 |
commit | e2e0417cfd4f16f1fa8b7fcd41bd25da19f17886 (patch) | |
tree | 60ecc83cf301a089a5bcd77c532116cbd58725d5 /ext | |
parent | ed8c7efb2eb63bb7e31522a3955f10e852b69122 (diff) |
- workaround for strange replace_ns() behaviour (it seems libxml2 sometimes uses NULL instead of the default namespace in the tree)
Diffstat (limited to 'ext')
-rw-r--r-- | ext/xmlextra.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/ext/xmlextra.c b/ext/xmlextra.c index 8ee4b52..ae965cd 100644 --- a/ext/xmlextra.c +++ b/ext/xmlextra.c @@ -169,14 +169,31 @@ PyObject *pyobj_tree,*pyobj_old_ns,*pyobj_new_ns; xmlNodePtr tree,node; xmlAttrPtr attr; xmlNsPtr new_ns,old_ns; +xmlNsPtr nsDef; if (!PyArg_ParseTuple(args, "OOO", &pyobj_tree,&pyobj_old_ns,&pyobj_new_ns)) return NULL; tree = (xmlNodePtr) PyxmlNode_Get(pyobj_tree); old_ns = (xmlNsPtr) PyxmlNode_Get(pyobj_old_ns); new_ns = (xmlNsPtr) PyxmlNode_Get(pyobj_new_ns); node = tree; - + while (node != NULL) { + + /* + * If old_ns is None and default namespace is redefined here, then skip this node and its children. + */ + if (old_ns == NULL) { + nsDef=node->nsDef; + while(nsDef != NULL) { + if (nsDef->prefix == NULL) break; + nsDef=nsDef->next; + } + if (nsDef != NULL) { + node = node->next; + continue; + } + } + /* * Check if the namespace is in use by the node */ |