AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_soap11_builder_helper_handle_event(
    axiom_soap11_builder_helper_t * builder_helper,
    const axutil_env_t * env,
    axiom_node_t * om_element_node,
    int element_level)
{
    axiom_element_t *om_ele = NULL;
    axis2_char_t *ele_localname = NULL;
    axiom_soap_envelope_t *soap_envelope = NULL;
    axiom_soap_body_t *soap_body = NULL;
    axiom_soap_fault_t *soap_fault = NULL;

    AXIS2_PARAM_CHECK(env->error, om_element_node, AXIS2_FAILURE);

    om_ele = (axiom_element_t *)axiom_node_get_data_element(om_element_node, env);

    ele_localname = axiom_element_get_localname(om_ele, env);
    if(!ele_localname)
    {
        return AXIS2_FAILURE;
    }

    soap_envelope = axiom_soap_builder_get_soap_envelope(builder_helper->soap_builder, env);

    if(!soap_envelope)
    {
        return AXIS2_FAILURE;
    }

    soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
    if(!soap_body)
    {
        return AXIS2_FAILURE;
    }

    soap_fault = axiom_soap_body_get_fault(soap_body, env);
    if(!soap_fault)
    {
        return AXIS2_FAILURE;
    }

    if(element_level == 4)
    {
        axiom_soap_fault_code_t *fault_code = NULL;
        axiom_soap_fault_value_t *fault_value = NULL;
        axiom_node_t *fault_value_node = NULL;
        axiom_element_t *fault_value_ele = NULL;

        if(axutil_strcmp(ele_localname, AXIOM_SOAP11_SOAP_FAULT_CODE_LOCAL_NAME) == 0)
        {
            axis2_status_t status = AXIS2_SUCCESS;

            if(builder_helper->fault_string_present)
            {
                axiom_soap_builder_set_bool_processing_mandatory_fault_elements(
                    builder_helper->soap_builder, env, AXIS2_FALSE);
            }

            fault_code = axiom_soap_fault_code_create(env);
            if(!fault_code)
            {
                return AXIS2_FAILURE;
            }
            axiom_soap_fault_code_set_base_node(fault_code, env, om_element_node);

            axiom_soap_fault_set_code(soap_fault, env, fault_code);

            axiom_soap_fault_code_set_builder(fault_code, env, builder_helper->soap_builder);

            axiom_element_set_localname(om_ele, env, AXIOM_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME);

            fault_value = axiom_soap_fault_value_create_with_code(env, fault_code);
            if(!fault_value)
            {
                return AXIS2_FAILURE;
            }
            fault_value_node = axiom_soap_fault_value_get_base_node(fault_value, env);
            if(!fault_value_node)
            {
                return AXIS2_FAILURE;
            }
            fault_value_ele = (axiom_element_t *)axiom_node_get_data_element(fault_value_node, env);

            axiom_stax_builder_set_lastnode(builder_helper->om_builder, env, fault_value_node);

            status = axiom_soap11_builder_helper_process_text(builder_helper, env);
            if(status == AXIS2_FAILURE)
            {
                return AXIS2_FAILURE;
            }
            axiom_stax_builder_set_lastnode(builder_helper->om_builder, env, om_element_node);
            axiom_node_set_complete(om_element_node, env, AXIS2_TRUE);

            axiom_stax_builder_set_element_level(builder_helper->om_builder, env, (element_level
                - 1));
            builder_helper->fault_code_present = AXIS2_TRUE;
        }
        else if(axutil_strcmp(AXIOM_SOAP11_SOAP_FAULT_STRING_LOCAL_NAME, ele_localname) == 0)
        {

            axiom_soap_fault_reason_t *fault_reason = NULL;
            axiom_soap_fault_text_t *fault_text = NULL;
            axiom_node_t *fault_text_node = NULL;
            int status = AXIS2_SUCCESS;
            if(builder_helper->fault_code_present)
            {
                axiom_soap_builder_set_bool_processing_mandatory_fault_elements(
                    builder_helper->soap_builder, env, AXIS2_FALSE);
            }

            axiom_element_set_localname(om_ele, env, AXIOM_SOAP12_SOAP_FAULT_REASON_LOCAL_NAME);

            fault_reason = axiom_soap_fault_reason_create(env);
            if(!fault_reason)
            {
                return AXIS2_FAILURE;
            }
            axiom_soap_fault_reason_set_base_node(fault_reason, env, om_element_node);

            axiom_soap_fault_set_reason(soap_fault, env, fault_reason);

            fault_text = axiom_soap_fault_text_create_with_parent(env, fault_reason);
            if(!fault_text)
            {
                return AXIS2_FAILURE;
            }
            fault_text_node = axiom_soap_fault_text_get_base_node(fault_text, env);
            if(!fault_text_node)
            {
                return AXIS2_FAILURE;
            }
            axiom_stax_builder_set_lastnode(builder_helper->om_builder, env, fault_text_node);

            status = axiom_soap11_builder_helper_process_text(builder_helper, env);
            if(status == AXIS2_FAILURE)
            {
                return AXIS2_FAILURE;
            }
            axiom_stax_builder_set_lastnode(builder_helper->om_builder, env, om_element_node);

            axiom_node_set_complete(om_element_node, env, AXIS2_TRUE);

            axiom_stax_builder_set_element_level(builder_helper->om_builder, env, (element_level
                - 1));

            builder_helper->fault_string_present = AXIS2_TRUE;

        }
        else if(axutil_strcmp(AXIOM_SOAP11_SOAP_FAULT_ACTOR_LOCAL_NAME, ele_localname) == 0)
        {
            axiom_soap_fault_role_t *fault_role = NULL;
            fault_role = axiom_soap_fault_role_create(env);
            if(!fault_role)
            {
                return AXIS2_FAILURE;
            }
            axiom_element_set_localname(om_ele, env, AXIOM_SOAP12_SOAP_FAULT_ROLE_LOCAL_NAME);

            axiom_soap_fault_role_set_base_node(fault_role, env, om_element_node);

            axiom_soap_fault_set_role(soap_fault, env, fault_role);
            /*
             Role element may not have a namespace associated, hence commented, else it segfaults here - Samisa
             status = axiom_soap_builder_process_namespace_data(
             builder_helper->soap_builder, env, om_element_node, AXIS2_TRUE);
             if(status == AXIS2_FAILURE)
             return AXIS2_FAILURE; */
        }
        else if(axutil_strcmp(AXIOM_SOAP11_SOAP_FAULT_DETAIL_LOCAL_NAME, ele_localname) == 0)
        {
            axiom_soap_fault_detail_t *fault_detail = NULL;
            fault_detail = axiom_soap_fault_detail_create(env);
            if(!fault_detail)
            {
                return AXIS2_FAILURE;
            }
            axiom_element_set_localname(om_ele, env, AXIOM_SOAP12_SOAP_FAULT_DETAIL_LOCAL_NAME);

            axiom_soap_fault_detail_set_base_node(fault_detail, env, om_element_node);

            axiom_soap_fault_set_detail(soap_fault, env, fault_detail);
        }
        else
        {
            return AXIS2_SUCCESS;
        }
    }
    else if(element_level == 5)
    {
        axiom_node_t *parent_node = NULL;
        axiom_element_t *parent_element = NULL;
        axis2_char_t *parent_localname = NULL;

        parent_node = axiom_node_get_parent(om_element_node, env);
        if(!parent_node)
        {
            return AXIS2_FAILURE;
        }
        parent_element = (axiom_element_t *)axiom_node_get_data_element(om_element_node, env);
        parent_localname = axiom_element_get_localname(parent_element, env);

        if(!parent_localname)
        {
            return AXIS2_FAILURE;
        }
        if(axutil_strcmp(parent_localname, AXIOM_SOAP12_SOAP_FAULT_ROLE_LOCAL_NAME) == 0)
        {
            AXIS2_ERROR_SET(env->error,
                AXIS2_ERROR_SOAP11_FAULT_ACTOR_SHOULD_NOT_HAVE_CHILD_ELEMENTS, AXIS2_FAILURE);
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "SOAP 1.1 Actor should not have child elements");
            return AXIS2_FAILURE;
        }
    }
    return AXIS2_SUCCESS;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_soap12_builder_helper_handle_event(
    axiom_soap12_builder_helper_t * builder_helper,
    const axutil_env_t * env,
    axiom_node_t * om_ele_node,
    int element_level)
{
    axis2_char_t *ele_localname = NULL;
    axiom_element_t *om_ele = NULL;

    axiom_soap_body_t *soap_body = NULL;
    axiom_soap_fault_t *soap_fault = NULL;
    axiom_soap_envelope_t *soap_envelope = NULL;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, om_ele_node, AXIS2_FAILURE);

    om_ele = (axiom_element_t *) axiom_node_get_data_element(om_ele_node, env);
    if (!om_ele)
    {
        return AXIS2_FAILURE;
    }

    ele_localname = axiom_element_get_localname(om_ele, env);
    if (!ele_localname)
    {
        return AXIS2_FAILURE;
    }

    soap_envelope =
        axiom_soap_builder_get_soap_envelope(builder_helper->soap_builder, env);
    if (!soap_envelope)
    {
        return AXIS2_FAILURE;
    }

    soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
    if (!soap_body)
    {
        return AXIS2_FAILURE;
    }

    soap_fault = axiom_soap_body_get_fault(soap_body, env);
    if (!soap_fault)
    {
        return AXIS2_FAILURE;
    }

    if (element_level == 4)
    {
        if (axutil_strcmp
            (AXIOM_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME, ele_localname) == 0)
        {
            if (builder_helper->code_present)
            {
                AXIS2_ERROR_SET(env->error,
                                AXIS2_ERROR_MULTIPLE_CODE_ELEMENTS_ENCOUNTERED,
                                AXIS2_FAILURE);
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                       "Multiple  fault code elements encountered in SOAP fault");
                return AXIS2_FAILURE;
            }
            else
            {
                axiom_soap_fault_code_t *soap_fault_code = NULL;
                soap_fault_code = axiom_soap_fault_code_create(env);
                if (!soap_fault_code)
                {
                    return AXIS2_FAILURE;
                }
                axiom_soap_fault_code_set_base_node(soap_fault_code, env,
                                                    om_ele_node);

                axiom_soap_fault_code_set_builder(soap_fault_code, env,
                                                  builder_helper->soap_builder);

                axiom_soap_fault_set_code(soap_fault, env, soap_fault_code);

                builder_helper->code_present = AXIS2_TRUE;
                builder_helper->code_processing = AXIS2_TRUE;
            }
        }
        else if (axutil_strcmp
                 (AXIOM_SOAP12_SOAP_FAULT_REASON_LOCAL_NAME,
                  ele_localname) == 0)
        {
            if (!(builder_helper->code_processing) &&
                !(builder_helper->sub_code_processing))
            {
                if (builder_helper->code_present)
                {
                    if (builder_helper->reason_present)
                    {
                        AXIS2_ERROR_SET(env->error,
                                        AXIS2_ERROR_MULTIPLE_REASON_ELEMENTS_ENCOUNTERED,
                                        AXIS2_FAILURE);
                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                            "Multiple fault reason elements encountered in SOAP fault");

                        return AXIS2_FAILURE;
                    }
                    else
                    {
                        axiom_soap_fault_reason_t *fault_reason = NULL;
                        fault_reason = axiom_soap_fault_reason_create(env);
                        if (!fault_reason)
                        {
                            return AXIS2_FAILURE;
                        }

                        axiom_soap_fault_reason_set_base_node(fault_reason, env,
                                                              om_ele_node);

                        axiom_soap_fault_set_reason(soap_fault, env,
                                                    fault_reason);

                        axiom_soap_fault_reason_set_builder(fault_reason, env,
                                                            builder_helper->
                                                            soap_builder);

                        builder_helper->reason_present = AXIS2_TRUE;
                        builder_helper->reason_processing = AXIS2_TRUE;
                    }
                }
                else
                {
                    AXIS2_ERROR_SET(env->error,
                                    AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED,
                                    AXIS2_FAILURE);
                    return AXIS2_FAILURE;
                }
            }
            else
            {
                if (builder_helper->code_processing)
                {
                    AXIS2_ERROR_SET(env->error,
                                    AXIS2_ERROR_SOAP_FAULT_CODE_DOES_NOT_HAVE_A_VALUE,
                                    AXIS2_FAILURE);
                    return AXIS2_FAILURE;
                }
                else
                {
                    AXIS2_ERROR_SET(env->error,
                                    AXIS2_ERROR_SOAP_FAULT_CODE_DOES_NOT_HAVE_A_VALUE,
                                    AXIS2_FAILURE);
                    return AXIS2_FAILURE;
                }
            }
        }
        else if (axutil_strcmp
                 (ele_localname, AXIOM_SOAP12_SOAP_FAULT_NODE_LOCAL_NAME) == 0)
        {
            if (!(builder_helper->reason_processing))
            {
                if (builder_helper->reason_present &&
                    !(builder_helper->role_present) &&
                    !(builder_helper->detail_present))
                {
                    if (builder_helper->node_present)
                    {
                        AXIS2_ERROR_SET(env->error,
                                        AXIS2_ERROR_MULTIPLE_NODE_ELEMENTS_ENCOUNTERED,
                                        AXIS2_FAILURE);
                        return AXIS2_FAILURE;
                    }
                    else
                    {
                        axiom_soap_fault_node_t *soap_fault_node = NULL;
                        soap_fault_node = axiom_soap_fault_node_create(env);
                        if (!soap_fault_node)
                        {
                            return AXIS2_FAILURE;
                        }

                        axiom_soap_fault_node_set_base_node(soap_fault_node,
                                                            env, om_ele_node);

                        axiom_soap_fault_set_node(soap_fault, env,
                                                  soap_fault_node);

                        builder_helper->node_present = AXIS2_TRUE;
                    }
                }
                else
                {
                    AXIS2_ERROR_SET(env->error,
                                    AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED,
                                    AXIS2_FALSE);

                    return AXIS2_FAILURE;
                }
            }
            else
            {
                AXIS2_ERROR_SET(env->error,
                                AXIS2_ERROR_SOAP_FAULT_REASON_ELEMENT_SHOULD_HAVE_A_TEXT,
                                AXIS2_FALSE);
                return AXIS2_FAILURE;
            }

        }
        else if (axutil_strcmp
                 (ele_localname, AXIOM_SOAP12_SOAP_FAULT_ROLE_LOCAL_NAME) == 0)
        {
            if (!(builder_helper->reason_processing))
            {
                if (builder_helper->reason_present &&
                    !(builder_helper->detail_present))
                {
                    if (builder_helper->role_present)
                    {
                        AXIS2_ERROR_SET(env->error,
                                        AXIS2_ERROR_MULTIPLE_ROLE_ELEMENTS_ENCOUNTERED,
                                        AXIS2_FAILURE);

                        return AXIS2_FAILURE;
                    }
                    else
                    {
                        axiom_soap_fault_role_t *soap_fault_role = NULL;
                        soap_fault_role = axiom_soap_fault_role_create(env);
                        if (!soap_fault_role)
                            return AXIS2_FAILURE;

                        axiom_soap_fault_role_set_base_node(soap_fault_role,
                                                            env, om_ele_node);

                        axiom_soap_fault_set_role(soap_fault, env,
                                                  soap_fault_role);
                        builder_helper->role_present = AXIS2_TRUE;
                    }
                }
                else
                {
                    AXIS2_ERROR_SET(env->error,
                                    AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED,
                                    AXIS2_FAILURE);
                    return AXIS2_FAILURE;
                }
            }
            else
            {

                AXIS2_ERROR_SET(env->error,
                                AXIS2_ERROR_SOAP_FAULT_ROLE_ELEMENT_SHOULD_HAVE_A_TEXT,
                                AXIS2_FAILURE);
                return AXIS2_FAILURE;
            }
        }
        else if (axutil_strcmp
                 (ele_localname,
                  AXIOM_SOAP12_SOAP_FAULT_DETAIL_LOCAL_NAME) == 0)
        {
            if (!(builder_helper->reason_processing))
            {
                if (builder_helper->reason_present)
                {
                    if (builder_helper->detail_present)
                    {
                        AXIS2_ERROR_SET(env->error,
                                        AXIS2_ERROR_MULTIPLE_DETAIL_ELEMENTS_ENCOUNTERED,
                                        AXIS2_FAILURE);
                        return AXIS2_FAILURE;
                    }
                    else
                    {

                        axiom_soap_fault_detail_t *soap_fault_detail = NULL;
                        soap_fault_detail = axiom_soap_fault_detail_create(env);
                        if (!soap_fault_detail)
                            return AXIS2_FAILURE;

                        axiom_soap_fault_detail_set_base_node(soap_fault_detail,
                                                              env, om_ele_node);

                        axiom_soap_fault_set_detail(soap_fault, env,
                                                    soap_fault_detail);
                        builder_helper->detail_present = AXIS2_TRUE;
                    }
                }
                else
                {
                    AXIS2_ERROR_SET(env->error,
                                    AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED,
                                    AXIS2_FAILURE);

                    return AXIS2_FAILURE;

                }
            }
            else
            {
                AXIS2_ERROR_SET(env->error,
                                AXIS2_ERROR_SOAP_FAULT_REASON_ELEMENT_SHOULD_HAVE_A_TEXT,
                                AXIS2_FAILURE);
                return AXIS2_FAILURE;
            }

        }
        else
        {
            AXIS2_ERROR_SET(env->error,
                            AXIS2_ERROR_UNSUPPORTED_ELEMENT_IN_SOAP_FAULT_ELEMENT,
                            AXIS2_FAILURE);
            return AXIS2_FAILURE;
        }
    }
    else if (element_level == 5)
    {
        axiom_node_t *parent_node = NULL;
        axiom_element_t *parent_ele = NULL;
        axis2_char_t *parent_localname = NULL;
        parent_node = axiom_node_get_parent(om_ele_node, env);
        if (!parent_node)
        {
            return AXIS2_FAILURE;
        }
        parent_ele =
            (axiom_element_t *) axiom_node_get_data_element(parent_node, env);
        if (!parent_ele)
        {
            return AXIS2_FAILURE;
        }
        parent_localname = axiom_element_get_localname(parent_ele, env);
        if (!parent_localname)
        {
            return AXIS2_FAILURE;
        }

        if (axutil_strcmp(parent_localname,
                          AXIOM_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME) == 0)
        {
            if (axutil_strcmp
                (ele_localname, AXIOM_SOAP12_SOAP_FAULT_VALUE_LOCAL_NAME) == 0)
            {
                if (!(builder_helper->value_present))
                {
                    axiom_soap_fault_value_t *soap_fault_value = NULL;
                    axiom_soap_fault_code_t *parent_fcode = NULL;

                    soap_fault_value = axiom_soap_fault_value_create(env);
                    if (!soap_fault_value)
                    {
                        return AXIS2_FAILURE;
                    }
                    axiom_soap_fault_value_set_base_node(soap_fault_value, env,
                                                         om_ele_node);

                    parent_fcode = axiom_soap_fault_get_code(soap_fault, env);
                    if (!parent_fcode)
                    {
                        return AXIS2_FAILURE;
                    }
                    axiom_soap_fault_code_set_value(parent_fcode, env,
                                                    soap_fault_value);

                    builder_helper->value_present = AXIS2_TRUE;
                    builder_helper->code_processing = AXIS2_FALSE;

                }
                else
                {
                    AXIS2_ERROR_SET(env->error,
                                    AXIS2_ERROR_MULTIPLE_VALUE_ENCOUNTERED_IN_CODE_ELEMENT,
                                    AXIS2_FAILURE);
                    return AXIS2_FAILURE;
                }
            }
            else if (axutil_strcmp(ele_localname,
                                   AXIOM_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME)
                     == 0)
            {
                if (!(builder_helper->sub_code_present))
                {
                    if (builder_helper->value_present)
                    {

                        axiom_soap_fault_sub_code_t *fault_subcode = NULL;
                        axiom_soap_fault_code_t *fault_code = NULL;

                        fault_subcode = axiom_soap_fault_sub_code_create(env);
                        if (!fault_subcode)
                        {
                            return AXIS2_FAILURE;
                        }
                        axiom_soap_fault_sub_code_set_base_node(fault_subcode,
                                                                env,
                                                                om_ele_node);

                        fault_code = axiom_soap_fault_get_code(soap_fault, env);
                        if (!fault_code)
                        {
                            return AXIS2_FAILURE;
                        }
                        axiom_soap_fault_code_set_sub_code(fault_code, env,
                                                           fault_subcode);

                        axiom_soap_fault_sub_code_set_builder(fault_subcode,
                                                              env,
                                                              builder_helper->
                                                              soap_builder);

                        builder_helper->sub_code_present = AXIS2_TRUE;
                        builder_helper->sub_code_processing = AXIS2_TRUE;
                    }
                    else
                    {
                        AXIS2_ERROR_SET(env->error,
                                        AXIS2_ERROR_SOAP_FAULT_VALUE_SHOULD_BE_PRESENT_BEFORE_SUB_CODE,
                                        AXIS2_FAILURE);
                        return AXIS2_FAILURE;
                    }
                }
                else
                {
                    AXIS2_ERROR_SET(env->error,
                                    AXIS2_ERROR_MULTIPLE_SUB_CODE_VALUES_ENCOUNTERED,
                                    AXIS2_FAILURE);
                    return AXIS2_FAILURE;
                }
            }
            else
            {
                AXIS2_ERROR_SET(env->error,
                                AXIS2_ERROR_THIS_LOCALNAME_NOT_SUPPORTED_INSIDE_THE_CODE_ELEMENT,
                                AXIS2_FAILURE);
                return AXIS2_FAILURE;
            }
        }
        else if (axutil_strcmp
                 (parent_localname,
                  AXIOM_SOAP12_SOAP_FAULT_REASON_LOCAL_NAME) == 0)
        {
            if (axutil_strcmp
                (ele_localname, AXIOM_SOAP12_SOAP_FAULT_TEXT_LOCAL_NAME) == 0)
            {
                axiom_soap_fault_text_t *soap_fault_text = NULL;
                axiom_soap_fault_reason_t *fault_reason = NULL;

                soap_fault_text = axiom_soap_fault_text_create(env);
                if (!soap_fault_text)
                {
                    return AXIS2_FAILURE;
                }
                axiom_soap_fault_text_set_base_node(soap_fault_text, env,
                                                    om_ele_node);

                fault_reason = axiom_soap_fault_get_reason(soap_fault, env);
                if (!fault_reason)
                {
                    return AXIS2_FAILURE;
                }

                axiom_soap_fault_reason_add_soap_fault_text(fault_reason, env,
                                                            soap_fault_text);
                builder_helper->reason_processing = AXIS2_FALSE;

                axiom_soap_builder_set_bool_processing_mandatory_fault_elements
                    (builder_helper->soap_builder, env, AXIS2_FALSE);

            }
            else
            {
                AXIS2_ERROR_SET(env->error,
                                AXIS2_ERROR_THIS_LOCALNAME_IS_NOT_SUPPORTED_INSIDE_THE_REASON_ELEMENT,
                                AXIS2_FAILURE);
                return AXIS2_FAILURE;
            }

        }
        else if (axutil_strcmp
                 (parent_localname,
                  AXIOM_SOAP12_SOAP_FAULT_DETAIL_LOCAL_NAME) == 0)
        {
            axiom_soap_builder_set_processing_detail_elements(builder_helper->
                                                              soap_builder, env,
                                                              AXIS2_TRUE);

            if (!(builder_helper->detail_element_names))
            {
                builder_helper->detail_element_names =
                    axutil_array_list_create(env, 20);
            }

            axutil_array_list_add(builder_helper->detail_element_names, env,
                                  ele_localname);

        }
        else
        {

            return AXIS2_FAILURE;
        }

    }
    else if (element_level > 5)
    {
        axiom_node_t *parent_node = NULL;
        axiom_element_t *parent_ele = NULL;
        axis2_char_t *parent_localname = NULL;

        parent_node = axiom_node_get_parent(om_ele_node, env);
        if (!parent_node)
        {
            return AXIS2_FAILURE;
        }
        parent_ele =
            (axiom_element_t *) axiom_node_get_data_element(parent_node, env);
        if (!parent_ele)
        {
            return AXIS2_FAILURE;
        }

        parent_localname = axiom_element_get_localname(parent_ele, env);
        if (!parent_localname)
        {
            return AXIS2_FAILURE;
        }
        if (axutil_strcmp
            (parent_localname,
             AXIOM_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME) == 0)
        {
            if (axutil_strcmp
                (ele_localname, AXIOM_SOAP12_SOAP_FAULT_VALUE_LOCAL_NAME) == 0)
            {
                if (builder_helper->subcode_value_present)
                {
                    AXIS2_ERROR_SET(env->error,
                                    AXIS2_ERROR_MULTIPLE_SUB_CODE_VALUES_ENCOUNTERED,
                                    AXIS2_FAILURE);
                    return AXIS2_FAILURE;
                }
                else
                {

                    axiom_soap_fault_sub_code_t *sub_code = NULL;
                    axiom_soap_fault_code_t *code = NULL;
                    axiom_soap_fault_value_t *value = NULL;
                    code = axiom_soap_fault_get_code(soap_fault, env);

                    if (!code)
                    {
                        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                                        "fault code null when it should not be null");
                        return AXIS2_FAILURE;
                    }

                    sub_code = axiom_soap_fault_code_get_sub_code(code, env);
                    if (!sub_code)
                    {
                        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                                        "fault subcode null when it should not be null");
                        return AXIS2_FAILURE;
                    }
                    value = axiom_soap_fault_value_create(env);
                    if (!value)
                    {
                        return AXIS2_FAILURE;
                    }

                    axiom_soap_fault_value_set_base_node(value, env,
                                                         om_ele_node);

                    axiom_soap_fault_sub_code_set_value(sub_code, env, value);

                    builder_helper->subcode_value_present = AXIS2_TRUE;
                    builder_helper->sub_sub_code_present = AXIS2_FALSE;
                    builder_helper->sub_code_processing = AXIS2_FALSE;
                }
            }
            else if (axutil_strcmp
                     (ele_localname,
                      AXIOM_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME) == 0)
            {
                if (builder_helper->subcode_value_present)
                {
                    if (!(builder_helper->sub_sub_code_present))
                    {
                        axiom_soap_fault_code_t *fault_code = NULL;
                        axiom_soap_fault_sub_code_t *parent_subcode = NULL;
                        axiom_soap_fault_sub_code_t *subcode = NULL;

                        subcode = axiom_soap_fault_sub_code_create(env);
                        if (!subcode)
                        {
                            return AXIS2_FAILURE;
                        }

                        axiom_soap_fault_sub_code_set_base_node(subcode, env,
                                                                om_ele_node);

                        fault_code = axiom_soap_fault_get_code(soap_fault, env);
                        if (!fault_code)
                        {
                            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                                            "fault code null when it should not be null");
                            return AXIS2_FAILURE;
                        }
                        parent_subcode =
                            axiom_soap_fault_code_get_sub_code(fault_code, env);
                        if (!parent_subcode)
                        {
                            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                                            "fault subcode null when it should not be null");
                            return AXIS2_FAILURE;
                        }

                        axiom_soap_fault_sub_code_set_sub_code(parent_subcode,
                                                               env, subcode);

                        builder_helper->subcode_value_present = AXIS2_FALSE;
                        builder_helper->sub_sub_code_present = AXIS2_TRUE;
                        builder_helper->sub_code_processing = AXIS2_TRUE;
                    }
                    else
                    {
                        AXIS2_ERROR_SET(env->error,
                                        AXIS2_ERROR_MULTIPLE_SUB_CODE_VALUES_ENCOUNTERED,
                                        AXIS2_FAILURE);

                        return AXIS2_FAILURE;
                    }
                }
                else
                {
                    AXIS2_ERROR_SET(env->error,
                                    AXIS2_ERROR_SOAP_FAULT_VALUE_SHOULD_BE_PRESENT_BEFORE_SUB_CODE,
                                    AXIS2_FAILURE);

                    return AXIS2_FAILURE;

                }
            }
            else
            {
                AXIS2_ERROR_SET(env->error,
                                AXIS2_ERROR_THIS_LOCALNAME_IS_NOT_SUPPORTED_INSIDE_THE_SUB_CODE_ELEMENT,
                                AXIS2_FAILURE);

                return AXIS2_FAILURE;
            }
        }
        else if (axiom_soap_builder_is_processing_detail_elements
                 (builder_helper->soap_builder, env))
        {

            int detail_element_level = 0;
            axis2_bool_t local_name_exists = AXIS2_FALSE;
            int i = 0;
            if (!(builder_helper->detail_element_names))
            {
                return AXIS2_FAILURE;
            }

            for (i = 0;
                 i <
                 axutil_array_list_size(builder_helper->detail_element_names,
                                        env); i++)
            {
                if (axutil_strcmp
                    (parent_localname,
                     axutil_array_list_get(builder_helper->detail_element_names,
                                           env, i)) == 0)
                {
                    local_name_exists = AXIS2_TRUE;
                    detail_element_level = i + 1;
                }
            }
            if (local_name_exists)
            {
                axutil_array_list_add(builder_helper->detail_element_names, env,
                                      ele_localname);
            }
            else
            {
                return AXIS2_FAILURE;
            }
        }
    }
    return AXIS2_SUCCESS;
}