diff options
-rw-r--r-- | axiom/include/axiom_stax_builder.h | 3 | ||||
-rw-r--r-- | axiom/src/om/axiom_node_internal.h | 20 | ||||
-rw-r--r-- | axiom/src/om/axiom_stax_builder_internal.h | 4 | ||||
-rw-r--r-- | axiom/src/om/om_element.c | 26 | ||||
-rw-r--r-- | axiom/src/om/om_node.c | 65 | ||||
-rw-r--r-- | axiom/src/om/om_stax_builder.c | 68 | ||||
-rw-r--r-- | axiom/src/parser/libxml2/libxml2_reader_wrapper.c | 57 |
7 files changed, 89 insertions, 154 deletions
diff --git a/axiom/include/axiom_stax_builder.h b/axiom/include/axiom_stax_builder.h index 8ec8af1..04115ac 100644 --- a/axiom/include/axiom_stax_builder.h +++ b/axiom/include/axiom_stax_builder.h @@ -70,7 +70,8 @@ extern "C" axiom_stax_builder_t *builder, const axutil_env_t * env); - /** Gets the document associated with the builder + /** + * Gets the document associated with the builder * @param builder axiom_stax_builder * @param env environment * @return pointer to document struct associated with builder NULL if an error occurred. diff --git a/axiom/src/om/axiom_node_internal.h b/axiom/src/om/axiom_node_internal.h index b266bb5..abfb919 100644 --- a/axiom/src/om/axiom_node_internal.h +++ b/axiom/src/om/axiom_node_internal.h @@ -61,7 +61,7 @@ extern "C" * @param env environment, MUST NOT be NULL. * @param first_child child to be set as first child */ - axis2_status_t AXIS2_CALL + void AXIS2_CALL axiom_node_set_first_child( axiom_node_t * om_node, const axutil_env_t * env, @@ -72,10 +72,8 @@ extern "C" * @param om_node * @param env environment, MUST NOT be NULL. * @param prev_sibling - * @return status of the op, AXIS2_SUCCESS on success - * AXIS2_FAILURE on error */ - axis2_status_t AXIS2_CALL + void AXIS2_CALL axiom_node_set_previous_sibling( axiom_node_t * om_node, const axutil_env_t * env, @@ -86,10 +84,8 @@ extern "C" * @param om_node * @param env environment, MUST NOT be NULL. * @param last_sibling - * @return status of the op, AXIS2_SUCCESS on success, - * AXIS2_FAILURE on error */ - axis2_status_t AXIS2_CALL + void AXIS2_CALL axiom_node_set_next_sibling( axiom_node_t * om_node, const axutil_env_t * env, @@ -100,8 +96,6 @@ extern "C" * @param om_node * @param env environment, MUST NOT be NULL. * @param type type of the node - * @return status code of the op AXIS2_SUCCESS on success, - * AXIS2_FAILURE on error */ axis2_status_t AXIS2_CALL axiom_node_set_node_type( @@ -114,10 +108,8 @@ extern "C" * @param om_node node struct * @param env environment, MUST NOT be NULL. * @param data_element - * @return status code of the op AXIS2_SUCCESS on success, - * AXIS2_FAILURE on error */ - axis2_status_t AXIS2_CALL + void AXIS2_CALL axiom_node_set_data_element( axiom_node_t * om_node, const axutil_env_t * env, @@ -130,7 +122,7 @@ extern "C" * @param env environment, MUST NOT be NULL. * @param done */ - axis2_status_t AXIS2_CALL + void AXIS2_CALL axiom_node_set_complete( axiom_node_t * om_node, const axutil_env_t * env, @@ -139,7 +131,7 @@ extern "C" /** * Sets the builder */ - axis2_status_t AXIS2_CALL + void AXIS2_CALL axiom_node_set_builder( axiom_node_t * om_node, const axutil_env_t * env, diff --git a/axiom/src/om/axiom_stax_builder_internal.h b/axiom/src/om/axiom_stax_builder_internal.h index 7bb9abe..12fcb53 100644 --- a/axiom/src/om/axiom_stax_builder_internal.h +++ b/axiom/src/om/axiom_stax_builder_internal.h @@ -44,7 +44,7 @@ extern "C" axiom_stax_builder_t * builder, const axutil_env_t * env); - axis2_status_t AXIS2_CALL + void AXIS2_CALL axiom_stax_builder_set_lastnode( axiom_stax_builder_t * builder, const axutil_env_t * env, @@ -55,7 +55,7 @@ extern "C" axiom_stax_builder_t * builder, const axutil_env_t * env); - axis2_status_t AXIS2_CALL + void AXIS2_CALL axiom_stax_builder_set_element_level( axiom_stax_builder_t * builder, const axutil_env_t * env, diff --git a/axiom/src/om/om_element.c b/axiom/src/om/om_element.c index c704cd0..7885c83 100644 --- a/axiom/src/om/om_element.c +++ b/axiom/src/om/om_element.c @@ -1518,7 +1518,6 @@ axiom_element_create_str( axiom_node_t ** node) { axiom_element_t *element; - AXIS2_ENV_CHECK(env, NULL); if(!localname || !node) { @@ -1531,36 +1530,23 @@ axiom_element_create_str( if(!(*node)) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create axiom node"); return NULL; } - element = (axiom_element_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_element_t)); + element = (axiom_element_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_element_t)); if(!element) { AXIS2_FREE(env->allocator, (*node)); AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Insufficient memory to create axiom element"); return NULL; } - element->ns = NULL; - element->localname = NULL; - element->attributes = NULL; - element->namespaces = NULL; - element->qname = NULL; - element->child_ele_iter = NULL; - element->children_iter = NULL; - element->children_qname_iter = NULL; - element->text_value = NULL; - element->next_ns_prefix_number = 0; - element->is_empty = AXIS2_FALSE; + memset(element, 0, sizeof(axiom_element_t)); element->localname = axutil_string_clone(localname, env); - if(!element->localname) - { - AXIS2_FREE(env->allocator, element); - AXIS2_FREE(env->allocator, (*node)); - AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); - return NULL; - } + /* clone can't be null so, no need to check for null validity*/ + if(parent) { axiom_node_add_child(parent, env, (*node)); diff --git a/axiom/src/om/om_node.c b/axiom/src/om/om_node.c index 70fb8aa..6566a1c 100644 --- a/axiom/src/om/om_node.c +++ b/axiom/src/om/om_node.c @@ -226,7 +226,6 @@ axiom_node_add_child( const axutil_env_t * env, axiom_node_t * child) { - AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, child, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); @@ -235,19 +234,15 @@ axiom_node_add_child( child = axiom_node_detach(child, env); } - if(!(om_node->first_child)) + if(!om_node->first_child) { om_node->first_child = child; } else { - axiom_node_t *last_sib = NULL; - last_sib = om_node->last_child; - if(last_sib) - { - last_sib->next_sibling = child; - child->prev_sibling = last_sib; - } + axiom_node_t *last_sib = om_node->last_child; + last_sib->next_sibling = child; + child->prev_sibling = last_sib; } child->parent = om_node; @@ -382,24 +377,17 @@ axiom_node_set_parent( const axutil_env_t * env, axiom_node_t * parent) { - AXIS2_ENV_CHECK(env, AXIS2_FAILURE); - if(!om_node) - { - return AXIS2_FAILURE; - } - - AXIS2_PARAM_CHECK(env->error, parent, AXIS2_FAILURE); if(parent == om_node->parent) { /* same parent already exist */ return AXIS2_SUCCESS; } - /* if a new parent is assigned in place of existing - one first the node should be detached + + /* if a new parent is assigned in place of existing one first the node should be detached */ if(om_node->parent) { - om_node = axiom_node_detach_without_namespaces(om_node, env); + om_node = axiom_node_detach(om_node, env); } om_node->parent = parent; @@ -1208,21 +1196,15 @@ axiom_node_get_data_element( internal function , not to be used by users only sets the first_child link because this is needed by builder */ -axis2_status_t AXIS2_CALL +void AXIS2_CALL axiom_node_set_first_child( axiom_node_t * om_node, const axutil_env_t * env, axiom_node_t * first_child) { - AXIS2_ENV_CHECK(env, AXIS2_FAILURE); - AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); - AXIS2_PARAM_CHECK(env->error, first_child, AXIS2_FAILURE); - /** set the parent */ axiom_node_set_parent(first_child, env, om_node); - om_node->first_child = first_child; - return AXIS2_SUCCESS; } /** @@ -1230,36 +1212,26 @@ axiom_node_set_first_child( only sets the previous sibling link as it is needed by builders */ -axis2_status_t AXIS2_CALL +void AXIS2_CALL axiom_node_set_previous_sibling( axiom_node_t * om_node, const axutil_env_t * env, axiom_node_t * prev_sibling) { - - AXIS2_ENV_CHECK(env, AXIS2_FAILURE); - AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); - AXIS2_PARAM_CHECK(env->error, prev_sibling, AXIS2_FAILURE); - om_node->prev_sibling = prev_sibling; - return AXIS2_SUCCESS; } /** internal function, not to be used by users only sets the next sibling link; */ -axis2_status_t AXIS2_CALL +void AXIS2_CALL axiom_node_set_next_sibling( axiom_node_t * om_node, const axutil_env_t * env, axiom_node_t * next_sibling) { - AXIS2_ENV_CHECK(env, AXIS2_FAILURE); - AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); - AXIS2_PARAM_CHECK(env->error, next_sibling, AXIS2_FAILURE); om_node->next_sibling = next_sibling; - return AXIS2_SUCCESS; } /** @@ -1273,9 +1245,6 @@ axiom_node_set_node_type( const axutil_env_t * env, axiom_types_t type) { - - AXIS2_ENV_CHECK(env, AXIS2_FAILURE); - AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); om_node->node_type = type; return AXIS2_SUCCESS; } @@ -1284,17 +1253,13 @@ axiom_node_set_node_type( internal function , not to be used by users only used in om and soap */ -axis2_status_t AXIS2_CALL +void AXIS2_CALL axiom_node_set_data_element( axiom_node_t * om_node, const axutil_env_t * env, void *data_element) { - AXIS2_ENV_CHECK(env, AXIS2_FAILURE); - AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); - AXIS2_PARAM_CHECK(env->error, data_element, AXIS2_FAILURE); om_node->data_element = data_element; - return AXIS2_SUCCESS; } /** @@ -1302,23 +1267,20 @@ axiom_node_set_data_element( only sets the build status */ -axis2_status_t AXIS2_CALL +void AXIS2_CALL axiom_node_set_complete( axiom_node_t * om_node, const axutil_env_t * env, axis2_bool_t done) { - AXIS2_ENV_CHECK(env, AXIS2_FAILURE); - AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); om_node->done = done; - return AXIS2_SUCCESS; } /** internal function only sets the builder reference , should not be used by user */ -axis2_status_t AXIS2_CALL +void AXIS2_CALL axiom_node_set_builder( axiom_node_t * om_node, const axutil_env_t * env, @@ -1326,7 +1288,6 @@ axiom_node_set_builder( { /* builder == NULL is a valid case */ om_node->builder = builder; - return AXIS2_SUCCESS; } void AXIS2_CALL diff --git a/axiom/src/om/om_stax_builder.c b/axiom/src/om/om_stax_builder.c index 60d4fcc..0052338 100644 --- a/axiom/src/om/om_stax_builder.c +++ b/axiom/src/om/om_stax_builder.c @@ -155,7 +155,8 @@ axiom_stax_builder_free_self( } } -/** Gets the document associated with the builder +/** + * Gets the document associated with the builder * @param builder axiom_stax_builder * @param env environment * @return pointer to document struct associated with builder NULL if an error occurred. @@ -418,9 +419,9 @@ axiom_stax_builder_create_om_element( axiom_element_t *om_ele = NULL; axis2_char_t *temp_localname = NULL; axutil_string_t *temp_localname_str = NULL; + axiom_node_t *parent = NULL; temp_localname = axiom_xml_reader_get_name(om_builder->parser, env); - if(!temp_localname) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_XML_READER_ELEMENT_NULL, AXIS2_FAILURE); @@ -436,56 +437,37 @@ axiom_stax_builder_create_om_element( #endif om_builder->element_level++; - - if(!om_builder->lastnode) + if(om_builder->lastnode) { - /* since last node is null, this should be the root node */ - om_ele = axiom_element_create_str(env, NULL, temp_localname_str, NULL, &element_node); - if(!element_node) + if(axiom_node_is_complete(om_builder->lastnode, env)) { - AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create element"); - return NULL; + /*previous node building is finished. This node should be a sibling of previous node */ + parent = axiom_node_get_parent(om_builder->lastnode, env); } - om_builder->root_node = element_node; - if(om_builder->document) - { - axiom_document_set_root_element(om_builder->document, env, element_node); - } - } - else if(axiom_node_is_complete(om_builder->lastnode, env)) - { - /* previous node building is finished. So, this node should be a sibling of previous node */ - axiom_node_t *parent = axiom_node_get_parent(om_builder->lastnode, env); - om_ele = axiom_element_create_str(env, parent, temp_localname_str, NULL, &element_node); - if(element_node) - { - axiom_node_set_next_sibling(om_builder->lastnode, env, element_node); - axiom_node_set_previous_sibling(element_node, env, om_builder->lastnode); - } - } - else - { - /* previous node building is not finished. This should be first child of previous node */ - om_ele = axiom_element_create_str( - env, om_builder->lastnode, temp_localname_str, NULL, &element_node); - if(element_node) + else { - axiom_node_set_first_child(om_builder->lastnode, env, element_node); - axiom_node_set_parent(element_node, env, om_builder->lastnode); + /*previous node building is not finished. This should be child of previous node */ + parent = om_builder->lastnode; } } + om_ele = axiom_element_create_str(env, parent, temp_localname_str, NULL, &element_node); axutil_string_free(temp_localname_str, env); - if((!om_ele) || (!element_node)) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create axiom element"); return NULL; } - axiom_node_set_builder(element_node, env, om_builder); axiom_element_set_is_empty(om_ele, env, is_empty); + if(!om_builder->lastnode) + { + /* since last node is null, this should be the root node */ + om_builder->root_node = element_node; + axiom_document_set_root_element(om_builder->document, env, element_node); + } + /* order of processing name spaces first (before processing attributes) is important */ axiom_stax_builder_process_namespaces(om_builder, env, element_node, 0); axiom_stax_builder_process_attributes(om_builder, env, element_node); @@ -649,12 +631,6 @@ axiom_stax_builder_next_with_token( { int token = 0; - if((!om_builder) || (!om_builder->parser)) - { - AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid OM builder"); - return -1; - } - if(om_builder->done) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_BUILDER_DONE_CANNOT_PULL, AXIS2_FAILURE); @@ -668,6 +644,7 @@ axiom_stax_builder_next_with_token( if(token == -1) { om_builder->done = AXIS2_TRUE; + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_BUILDER_DONE_CANNOT_PULL, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error when reading xml"); return -1; } @@ -684,6 +661,7 @@ axiom_stax_builder_next_with_token( if(!axiom_stax_builder_create_om_element(om_builder, env, AXIS2_FALSE)) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in creating start element"); + /* error is set in the create_om_element method. No need to set here */ return -1; } break; @@ -797,14 +775,13 @@ axiom_stax_builder_is_complete( /** internal function for soap om_builder only */ -axis2_status_t AXIS2_CALL +void AXIS2_CALL axiom_stax_builder_set_lastnode( axiom_stax_builder_t * om_builder, const axutil_env_t * env, axiom_node_t * om_node) { om_builder->lastnode = om_node; - return AXIS2_SUCCESS; } /** @@ -821,14 +798,13 @@ axiom_stax_builder_get_element_level( /** internal function for soap om_builder only */ -axis2_status_t AXIS2_CALL +void AXIS2_CALL axiom_stax_builder_set_element_level( axiom_stax_builder_t * om_builder, const axutil_env_t * env, int element_level) { om_builder->element_level = element_level; - return AXIS2_SUCCESS; } #if 0 diff --git a/axiom/src/parser/libxml2/libxml2_reader_wrapper.c b/axiom/src/parser/libxml2/libxml2_reader_wrapper.c index 2510d49..66488d0 100644 --- a/axiom/src/parser/libxml2/libxml2_reader_wrapper.c +++ b/axiom/src/parser/libxml2/libxml2_reader_wrapper.c @@ -24,15 +24,18 @@ #include <axutil_string.h> -int AXIS2_CALL axis2_libxml2_reader_wrapper_next( +int AXIS2_CALL +axis2_libxml2_reader_wrapper_next( axiom_xml_reader_t * parser, const axutil_env_t * env); -void AXIS2_CALL axis2_libxml2_reader_wrapper_free( +void AXIS2_CALL +axis2_libxml2_reader_wrapper_free( axiom_xml_reader_t * parser, const axutil_env_t * env); -int AXIS2_CALL axis2_libxml2_reader_wrapper_get_attribute_count( +int AXIS2_CALL +axis2_libxml2_reader_wrapper_get_attribute_count( axiom_xml_reader_t * parser, const axutil_env_t * env); @@ -60,11 +63,13 @@ axis2_libxml2_reader_wrapper_get_attribute_namespace_by_number( const axutil_env_t * env, int i); -axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_value( +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_value( axiom_xml_reader_t * parser, const axutil_env_t * env); -int AXIS2_CALL axis2_libxml2_reader_wrapper_get_namespace_count( +int AXIS2_CALL +axis2_libxml2_reader_wrapper_get_namespace_count( axiom_xml_reader_t * parser, const axutil_env_t * env); @@ -80,36 +85,44 @@ axis2_libxml2_reader_wrapper_get_namespace_prefix_by_number( const axutil_env_t * env, int i); -axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_prefix( +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_prefix( axiom_xml_reader_t * parser, const axutil_env_t * env); -axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_name( +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_name( axiom_xml_reader_t * parser, const axutil_env_t * env); -axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_pi_target( +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_pi_target( axiom_xml_reader_t * parser, const axutil_env_t * env); -axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_pi_data( +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_pi_data( axiom_xml_reader_t * parser, const axutil_env_t * env); -axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_dtd( +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_dtd( axiom_xml_reader_t * parser, const axutil_env_t * env); -void AXIS2_CALL axis2_libxml2_reader_wrapper_xml_free( +void AXIS2_CALL +axis2_libxml2_reader_wrapper_xml_free( axiom_xml_reader_t * parser, const axutil_env_t * env, void *data); -axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_char_set_encoding( +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_char_set_encoding( axiom_xml_reader_t * parser, const axutil_env_t * env); -axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_namespace_uri( +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_namespace_uri( axiom_xml_reader_t * parser, const axutil_env_t * env); @@ -167,18 +180,24 @@ typedef struct axis2_libxml2_reader_wrapper_impl_t #define AXIS2_INTF_TO_IMPL(p) ((axis2_libxml2_reader_wrapper_impl_t*)p) #define AXIS2_IMPL_TO_INTF(p) &(p->parser) -static const axiom_xml_reader_ops_t axiom_xml_reader_ops_var = { axis2_libxml2_reader_wrapper_next, - axis2_libxml2_reader_wrapper_free, axis2_libxml2_reader_wrapper_get_attribute_count, +static const axiom_xml_reader_ops_t axiom_xml_reader_ops_var = { + axis2_libxml2_reader_wrapper_next, + axis2_libxml2_reader_wrapper_free, + axis2_libxml2_reader_wrapper_get_attribute_count, axis2_libxml2_reader_wrapper_get_attribute_name_by_number, axis2_libxml2_reader_wrapper_get_attribute_prefix_by_number, axis2_libxml2_reader_wrapper_get_attribute_value_by_number, axis2_libxml2_reader_wrapper_get_attribute_namespace_by_number, - axis2_libxml2_reader_wrapper_get_value, axis2_libxml2_reader_wrapper_get_namespace_count, + axis2_libxml2_reader_wrapper_get_value, + axis2_libxml2_reader_wrapper_get_namespace_count, axis2_libxml2_reader_wrapper_get_namespace_uri_by_number, axis2_libxml2_reader_wrapper_get_namespace_prefix_by_number, - axis2_libxml2_reader_wrapper_get_prefix, axis2_libxml2_reader_wrapper_get_name, - axis2_libxml2_reader_wrapper_get_pi_target, axis2_libxml2_reader_wrapper_get_pi_data, - axis2_libxml2_reader_wrapper_get_dtd, axis2_libxml2_reader_wrapper_xml_free, + axis2_libxml2_reader_wrapper_get_prefix, + axis2_libxml2_reader_wrapper_get_name, + axis2_libxml2_reader_wrapper_get_pi_target, + axis2_libxml2_reader_wrapper_get_pi_data, + axis2_libxml2_reader_wrapper_get_dtd, + axis2_libxml2_reader_wrapper_xml_free, axis2_libxml2_reader_wrapper_get_char_set_encoding, axis2_libxml2_reader_wrapper_get_namespace_uri, axis2_libxml2_reader_wrapper_get_namespace_uri_by_prefix }; |