AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL axiom_namespace_clone( axiom_namespace_t * om_namespace, const axutil_env_t * env) { axiom_namespace_t *cloned_ns = NULL; AXIS2_ENV_CHECK(env, NULL); cloned_ns = axiom_namespace_create_str(env, om_namespace->uri, om_namespace->prefix); if(cloned_ns) { return cloned_ns; } return NULL; }
static axis2_status_t axiom_stax_builder_process_namespaces( axiom_stax_builder_t * om_builder, const axutil_env_t * env, axiom_node_t * node, int is_soap_element) { axis2_status_t status = AXIS2_SUCCESS; int namespace_count = 0; axiom_namespace_t *om_ns = NULL; axiom_element_t *om_ele = NULL; /* temp values */ axis2_char_t *tmp_prefix = NULL; axis2_char_t *tmp_ns_prefix = NULL; axis2_char_t *tmp_ns_uri = NULL; axutil_string_t *tmp_ns_prefix_str = NULL; axutil_string_t *tmp_ns_uri_str = NULL; int i = 0; om_ele = (axiom_element_t *)axiom_node_get_data_element(node, env); namespace_count = axiom_xml_reader_get_namespace_count(om_builder->parser, env); for(i = 1; i <= namespace_count; ++i) { tmp_ns_prefix = axiom_xml_reader_get_namespace_prefix_by_number(om_builder->parser, env, i); tmp_ns_uri = axiom_xml_reader_get_namespace_uri_by_number(om_builder->parser, env, i); #ifdef AXIS2_LIBXML2_ENABLED tmp_ns_prefix_str = axutil_string_create(env, tmp_ns_prefix); tmp_ns_uri_str = axutil_string_create(env, tmp_ns_uri); #else tmp_ns_prefix_str = axutil_string_create_assume_ownership(env, &tmp_ns_prefix); tmp_ns_uri_str = axutil_string_create_assume_ownership(env, &tmp_ns_uri); #endif if(!tmp_ns_prefix || axutil_strcmp(tmp_ns_prefix, "xmlns") == 0) { /* default namespace case. !temp_ns_prefix is for guththila */ if(tmp_ns_prefix_str) { axutil_string_free(tmp_ns_prefix_str, env); } tmp_ns_prefix_str = axutil_string_create(env, ""); om_ns = axiom_namespace_create_str(env, tmp_ns_uri_str, tmp_ns_prefix_str); if(!om_ns) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create namespace"); return AXIS2_FAILURE; } status = axiom_element_declare_namespace(om_ele, env, node, om_ns); if(!status) { axiom_namespace_free(om_ns, env); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error when declaring namespace"); return AXIS2_FAILURE; } } else { axis2_char_t *prefix = NULL; om_ns = axiom_namespace_create_str(env, tmp_ns_uri_str, tmp_ns_prefix_str); if(!om_ns) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create namespace"); return AXIS2_FAILURE; } status = axiom_element_declare_namespace(om_ele, env, node, om_ns); prefix = axiom_namespace_get_prefix(om_ns, env); axutil_hash_set(om_builder->declared_namespaces, prefix, AXIS2_HASH_KEY_STRING, om_ns); } axutil_string_free(tmp_ns_uri_str, env); axutil_string_free(tmp_ns_prefix_str, env); #ifdef AXIS2_LIBXML2_ENABLED axiom_xml_reader_xml_free(om_builder->parser, env, tmp_ns_uri); axiom_xml_reader_xml_free(om_builder->parser, env, tmp_ns_prefix); #endif } /* set own namespace */ tmp_prefix = axiom_xml_reader_get_prefix(om_builder->parser, env); if(tmp_prefix) { om_ns = axutil_hash_get(om_builder->declared_namespaces, tmp_prefix, AXIS2_HASH_KEY_STRING); if(om_ns) { axiom_element_set_namespace(om_ele, env, om_ns, node); } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_DOCUMENT_STATE_UNDEFINED_NAMESPACE, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error when setting namespace"); return AXIS2_FAILURE; } axiom_xml_reader_xml_free(om_builder->parser, env, tmp_prefix); } return status; }