AXIS2_EXTERN axis2_status_t AXIS2_CALL axiom_namespace_serialize( axiom_namespace_t * om_namespace, const axutil_env_t * env, axiom_output_t * om_output) { int status = AXIS2_SUCCESS; if(!om_namespace) { return AXIS2_FAILURE; } AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); if(om_namespace->uri && NULL != om_namespace->prefix && axutil_strcmp(axutil_string_get_buffer( om_namespace->prefix, env), "") != 0) { status = axiom_output_write(om_output, env, AXIOM_NAMESPACE, 2, axutil_string_get_buffer( om_namespace-> prefix, env), axutil_string_get_buffer(om_namespace->uri, env)); } else if(om_namespace->uri) { status = axiom_output_write(om_output, env, AXIOM_NAMESPACE, 2, NULL, axutil_string_get_buffer(om_namespace->uri, env)); } return status; }
static axis2_status_t AXIS2_CALL axiom_text_serialize_start_part( axiom_text_t * om_text, const axutil_env_t * env, axiom_output_t * om_output) { axis2_char_t *namespace_uri = NULL; axis2_char_t *prefix = NULL; const axis2_char_t *local_name = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); local_name = "Include"; om_text->ns = axiom_namespace_create(env, "http://www.w3.org/2004/08/xop/include", "xop"); if(om_text->ns) { namespace_uri = axiom_namespace_get_uri(om_text->ns, env); if(namespace_uri) { prefix = axiom_namespace_get_prefix(om_text->ns, env); if(prefix) { axiom_output_write(om_output, env, AXIOM_ELEMENT, 3, local_name, namespace_uri, prefix); } else { axiom_output_write(om_output, env, AXIOM_ELEMENT, 2, local_name, namespace_uri); } } else { axiom_output_write(om_output, env, AXIOM_ELEMENT, 1, local_name); } } else { axiom_output_write(om_output, env, AXIOM_TEXT, 1, local_name); } if(om_text->om_attribute) { axiom_attribute_serialize(om_text->om_attribute, env, om_output); } if(om_text->ns) { axiom_namespace_serialize(om_text->ns, env, om_output); axiom_namespace_free(om_text->ns, env); om_text->ns = NULL; } return AXIS2_SUCCESS; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axiom_attribute_serialize( axiom_attribute_t * attribute, const axutil_env_t * env, axiom_output_t * om_output) { int status = AXIS2_SUCCESS; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); if(attribute->ns) { axis2_char_t *uri = NULL; axis2_char_t *prefix = NULL; uri = axiom_namespace_get_uri(attribute->ns, env); prefix = axiom_namespace_get_prefix(attribute->ns, env); if((uri) && (NULL != prefix) && (axutil_strcmp(prefix, "") != 0)) { status = axiom_output_write(om_output, env, AXIOM_ATTRIBUTE, 4, axutil_string_get_buffer(attribute-> localname, env), axutil_string_get_buffer( attribute-> value, env), uri, prefix); } else if(uri) { status = axiom_output_write(om_output, env, AXIOM_ATTRIBUTE, 3, axutil_string_get_buffer(attribute-> localname, env), axutil_string_get_buffer( attribute-> value, env), uri); } } else { status = axiom_output_write(om_output, env, AXIOM_ATTRIBUTE, 2, axutil_string_get_buffer( attribute-> localname, env), axutil_string_get_buffer(attribute->value, env)); } return status; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axiom_text_serialize( axiom_text_t * om_text, const axutil_env_t * env, axiom_output_t * om_output) { int status = AXIS2_SUCCESS; axis2_char_t *attribute_value = NULL; const axis2_char_t *text = NULL; axiom_xml_writer_t *om_output_xml_writer = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); if(!axiom_text_get_is_binary(om_text, env)) { if(om_text->value) { status = axiom_output_write(om_output, env, AXIOM_TEXT, 1, axutil_string_get_buffer( om_text->value, env)); } } else { om_output_xml_writer = axiom_output_get_xml_writer(om_output, env); if(axiom_output_is_optimized(om_output, env) && om_text->optimize) { if(!(axiom_text_get_content_id(om_text, env))) { axis2_char_t *content_id = axiom_output_get_next_content_id(om_output, env); if(content_id) { om_text->content_id = axutil_strdup(env, content_id); } } attribute_value = axutil_stracat(env, "cid:", om_text->content_id); /*send binary as MTOM optimised */ if(om_text->om_attribute) { axiom_attribute_free(om_text->om_attribute, env); om_text->om_attribute = NULL; } om_text->om_attribute = axiom_attribute_create(env, "href", attribute_value, NULL); AXIS2_FREE(env->allocator, attribute_value); attribute_value = NULL; if(!om_text->is_swa) /* This is a hack to get SwA working */ { axiom_text_serialize_start_part(om_text, env, om_output); } else { status = axiom_output_write(om_output, env, AXIOM_TEXT, 1, om_text->content_id); } axiom_output_write_optimized(om_output, env, om_text); axiom_output_write(om_output, env, AXIOM_ELEMENT, 0); } else { text = axiom_text_get_text(om_text, env); axiom_xml_writer_write_characters(om_output_xml_writer, env, (axis2_char_t *)text); } } return status; }