diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2008-03-13 08:39:24 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2008-03-13 08:39:24 +0000 |
commit | 3c0b01fbdc3797e37100ee914c0a79d8094c8f77 (patch) | |
tree | 6180cebc0c36ec259086c6a3136eec37639016fe /python | |
parent | 15964811dce33c00baea4fca289a9bba1ddb6e29 (diff) | |
download | libxslt-3c0b01fbdc3797e37100ee914c0a79d8094c8f77.tar.gz libxslt-3c0b01fbdc3797e37100ee914c0a79d8094c8f77.tar.bz2 libxslt-3c0b01fbdc3797e37100ee914c0a79d8094c8f77.zip |
patch from Rob Richards for VS 2008 fix a problem with namespace nodes
* libxslt/win32config.h: patch from Rob Richards for VS 2008
* python/types.c: fix a problem with namespace nodes coming from
XPath nodesets.
Daniel
svn path=/trunk/; revision=1458
Diffstat (limited to 'python')
-rw-r--r-- | python/types.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/python/types.c b/python/types.c index 64163543..621891ec 100644 --- a/python/types.c +++ b/python/types.c @@ -11,6 +11,7 @@ xmlParserInputPtr xmlNoNetExternalEntityLoader(const char *URL, * daniel@veillard.com */ #include "libxml_wrap.h" +#include <libxml/xpathInternals.h> PyObject * libxml_intWrap(int val) @@ -333,6 +334,24 @@ libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt) return (ret); } +/** + * libxml_xmlXPathDestructNsNode: + * cobj: xmlNsPtr namespace node + * desc: ignored string + * + * This function is called if and when a namespace node returned in + * an XPath node set is to be destroyed. That's the only kind of + * object returned in node set not directly linked to the original + * xmlDoc document, see xmlXPathNodeSetDupNs. + */ +static void +libxml_xmlXPathDestructNsNode(void *cobj, void *desc ATTRIBUTE_UNUSED) { +#ifdef DEBUG + fprintf(stderr, "libxml_xmlXPathDestructNsNode called %p\n", cobj); +#endif + xmlXPathNodeSetFreeNs((xmlNsPtr) cobj); +} + PyObject * libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj) { @@ -383,8 +402,17 @@ libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj) ret = PyList_New(obj->nodesetval->nodeNr); for (i = 0; i < obj->nodesetval->nodeNr; i++) { node = obj->nodesetval->nodeTab[i]; - /* TODO: try to cast directly to the proper node type */ - PyList_SetItem(ret, i, libxml_xmlNodePtrWrap(node)); + if (node->type == XML_NAMESPACE_DECL) { + PyObject *ns = + PyCObject_FromVoidPtrAndDesc((void *) node, + (char *) "xmlNsPtr", + libxml_xmlXPathDestructNsNode); + PyList_SetItem(ret, i, ns); + /* make sure the xmlNsPtr is not destroyed now */ + obj->nodesetval->nodeTab[i] = NULL; + } else { + PyList_SetItem(ret, i, libxml_xmlNodePtrWrap(node)); + } } } break; |