From: <svn...@op...> - 2009-04-22 11:55:26
|
Author: bellmich Date: Wed Apr 22 13:55:16 2009 New Revision: 209 URL: http://libwbxml.opensync.org/changeset/209 Log: EXPAT splits <html> into three separate text nodes. Therefore it is necessary to scan for splitted text nodes and join them to get consistent text nodes. Modified: wbxml2/trunk/src/wbxml_tree.c Modified: wbxml2/trunk/src/wbxml_tree.c ============================================================================== --- wbxml2/trunk/src/wbxml_tree.c Wed Apr 22 13:53:37 2009 (r208) +++ wbxml2/trunk/src/wbxml_tree.c Wed Apr 22 13:55:16 2009 (r209) @@ -989,11 +989,38 @@ /* Add this Node to end of Sibbling Node list of Parent */ tmp = parent->children; + /* !!! WARNING !!! + * EXPAT splits <html> into three separate text nodes. + * Therefore it is necessary to scan for splitted text nodes and + * join them to get consistent text nodes. + */ + + /* If the handled node is a text node and the last node is a text node + * then the last node must be replace. + * Otherwise the node will be appended. + */ while (tmp->next != NULL) tmp = tmp->next; - node->prev = tmp; - tmp->next = node; + if (node->type == WBXML_TREE_TEXT_NODE && + tmp->type == WBXML_TREE_TEXT_NODE) { + /* join the two text nodes and replace the present text node */ + if (!wbxml_buffer_insert(node->content, tmp->content, 0)) + return FALSE; + if (tmp->prev == NULL) { + /* tmp is first child */ + parent->children = node; + } else { + /* tmp is not first child */ + tmp->prev->next = node; + node->prev = tmp->prev; + } + wbxml_tree_node_destroy(tmp); + } else { + /* normal situation => append node */ + node->prev = tmp; + tmp->next = node; + } } else { /* No previous sibbling element */ |