From 81f781c18d59fa5ec822136f9469fd5b6881ca2a Mon Sep 17 00:00:00 2001 From: Nima Talebi Date: Wed, 27 May 2009 12:33:51 +1000 Subject: Fixed WIP from last night (with notes) Note that this will not work as expected for `group mappings' that have unimplemented `type maps', and this is because the linked-list chain will ne broken at the first unimplemented `type map' There is no reason to code a workaround for this as the type do have to be implemented eventually, and hence added code will merely be noise. --- src/xmlpythonizer.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src/xmlpythonizer.c') diff --git a/src/xmlpythonizer.c b/src/xmlpythonizer.c index 86bbb69..34f6947 100644 --- a/src/xmlpythonizer.c +++ b/src/xmlpythonizer.c @@ -349,6 +349,7 @@ ptzMAP *_do_dmitypemap_parsing(xmlNode *node) { value = NULL; key = NULL; } + return retmap; } @@ -377,20 +378,23 @@ ptzMAP *_do_dmimap_parsing(xmlNode *node, xmlDoc *xmlmap) { } // Loop through it's children - xmlNode *typemap = xmlDocGetRootElement(xmlmap); + xmlNode *typemap = dmixml_FindNode(xmlDocGetRootElement(xmlmap), "TypeMapping"); assert( typemap != NULL ); + char *type_id; for( ptr_n = map_n ; ptr_n != NULL; ptr_n = ptr_n->next ) { - char *type_id = NULL; - + //. TODO: Dazo: I had to add this (if() statement), but not sure why I should need to + //. TODO: Needs investigation... type_id = dmixml_GetAttrValue(ptr_n, "id"); - map_n = dmixml_FindNodeByAttr(typemap, "id", type_id); - if( tmp != NULL) { - tmp->next = _do_dmitypemap_parsing(map_n); - tmp = tmp->next; - } else { - tmp = _do_dmitypemap_parsing(map_n); - retmap = tmp; + if(type_id) { + map_n = dmixml_FindNodeByAttr(typemap, "id", type_id); + if( tmp != NULL) { + tmp->next = _do_dmitypemap_parsing(map_n); + tmp = tmp->next; + } else { + retmap = _do_dmitypemap_parsing(map_n); + tmp = retmap; + } } } return retmap; @@ -766,7 +770,7 @@ PyObject *_deep_pythonize(PyObject *retdata, ptzMAP *map_p, xmlNode *data_n, int xpo = _get_xpath_values(xpctx, map_p->value); if( (xpo == NULL) || (xpo->nodesetval == NULL) || (xpo->nodesetval->nodeNr == 0) ) { char msg[8094]; - snprintf(msg, 8092, "Could not locate XML path node: %s (Defining key: %s)%c", + snprintf(msg, 8092, "Could not locate XML path node (e1): %s (Defining key: %s)%c", map_p->value, map_p->key, 0); PyErr_SetString(PyExc_LookupError, msg); @@ -858,7 +862,7 @@ PyObject *pythonizeXMLnode(ptzMAP *in_map, xmlNode *data_n) { xpo = _get_xpath_values(xpctx, map_p->rootpath); if( (xpo == NULL) || (xpo->nodesetval == NULL) || (xpo->nodesetval->nodeNr == 0) ) { char msg[8094]; //XXX - snprintf(msg, 8092, "Could not locate XML path node: %s (Defining key: %s)%c", + snprintf(msg, 8092, "Could not locate XML path node (e2): %s (Defining key: %s)%c", map_p->rootpath, map_p->key, 0); PyErr_SetString(PyExc_LookupError, msg); -- cgit