Index: project.properties =================================================================== --- project.properties (revision 292630) +++ project.properties (working copy) @@ -17,5 +17,5 @@ freehep.nar.src=src freehep.nar.outtype=shared freehep.nar.test.src=test -freehep.nar.tests=om_test +freehep.nar.tests= freehep.nar.linker.test.arg.end=-Ltarget/nar/lib/i386-Linux-g++ -laxis2c-xml-om-nar-0.0 Index: src/axis2c_node.c =================================================================== --- src/axis2c_node.c (revision 292630) +++ src/axis2c_node.c (working copy) @@ -61,43 +61,108 @@ -axis2c_node_t *axis2c_detach_node(axis2c_node_t * axis2c_node_to_detach) +axis2c_node_t *axis2c_node_detach(axis2c_node_t * node_to_detach) { axis2c_node_t *parent = NULL; axis2c_node_t *next_sibling = NULL; - if (!axis2c_node_to_detach) + if (!node_to_detach) { - return NULL; + return NULL; } - if (!(axis2c_node_to_detach->parent)) + if (!(node_to_detach->parent)) { /* nodes that do not have a parent can't be detached */ - return NULL; + return NULL; } - parent = axis2c_node_to_detach->parent; - if ((axis2c_node_to_detach->prev_sibling) == NULL) + parent = node_to_detach->parent; + + if ((node_to_detach->prev_sibling) == NULL) { - parent->first_child = axis2c_node_to_detach->next_sibling; - } else + parent->first_child = node_to_detach->next_sibling; + } + else { - axis2c_node_to_detach->prev_sibling->next_sibling = - axis2c_node_to_detach->next_sibling; + node_to_detach->prev_sibling->next_sibling = + node_to_detach->next_sibling; } - if (!(axis2c_node_to_detach->next_sibling)) + if (!(node_to_detach->next_sibling)) { - axis2c_node_to_detach->next_sibling->prev_sibling = - axis2c_node_to_detach->prev_sibling; + node_to_detach->next_sibling->prev_sibling = + node_to_detach->prev_sibling; } - axis2c_node_to_detach->parent = NULL; + node_to_detach->parent = NULL; - return axis2c_node_to_detach; + return node_to_detach; } -void axis2c_node_set_parent(axis2c_node_t * node) +void axis2c_node_set_parent(axis2c_node_t * node,axis2c_node_t *parent) { + if(!parent || !node) + {/*null pointers */ + return ; + } + if(parent == node->parent ) + {/* same parent already exist */ + return ; + } + /* if a new parent is assigned in place of existing one first the node should be detached */ + + if(!(node->parent)) + { + axis2c_node_detach(node); + } + node->parent = parent; } +/** + * This will insert a sibling just after the current information item + *@param node the node in consideration + *@param nodeto_insert the node that will be inserted + */ +void axis2c_node_insert_sibling_after(axis2c_node_t *node,axis2c_node_t *nodeto_insert) +{ + if(!node || !nodeto_insert ) + { + return ; + } + nodeto_insert->parent = node->parent; + nodeto_insert->prev_sibling = node; + + if(node->next_sibling) + { + node->next_sibling->prev_sibling = nodeto_insert; + } + nodeto_insert->next_sibling = node->next_sibling; + node->next_sibling = nodeto_insert; +} + + +void axis2c_node_insert_sibling_before(axis2c_node_t *node,axis2c_node_t *nodeto_insert) +{ + if(!node || !nodeto_insert ) + { + return; + } + + nodeto_insert->parent = node->parent; + + nodeto_insert->prev_sibling = node->prev_sibling; + nodeto_insert->next_sibling = node; + + if(!(node->prev_sibling)) + { + node->parent->first_child = nodeto_insert; + } + else + { + node->prev_sibling->next_sibling = nodeto_insert; + + } + node->prev_sibling = nodeto_insert; +} + +