示例#1
0
AXIS2_EXTERN axutil_qname_t *AXIS2_CALL
axiom_attribute_get_qname(
    axiom_attribute_t * attribute,
    const axutil_env_t * env)
{
    axutil_qname_t *qname = NULL;
    AXIS2_ENV_CHECK(env, NULL);
    if(!(attribute->qname))
    {
        if(attribute->ns)
        {
            qname = axutil_qname_create(env, axutil_string_get_buffer(attribute-> localname, env),
                axiom_namespace_get_uri(attribute->ns, env), axiom_namespace_get_prefix(
                    attribute-> ns, env));
        }
        else
        {
            qname = axutil_qname_create(env, axutil_string_get_buffer(attribute-> localname, env),
                NULL, NULL);
        }
        attribute->qname = qname;
        return qname;
    }
    return attribute->qname;
}
示例#2
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_text_serialize_namespace(
    axiom_text_t * om_text,
    const axutil_env_t * env,
    const axiom_namespace_t * om_namespace,
    axiom_output_t * om_output)
{
    axiom_xml_writer_t *xml_writer = NULL;
    axis2_char_t *namespace_uri = NULL;
    axis2_char_t *namespace_prefix = NULL;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    (void)om_output;

    xml_writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0,
        AXIS2_XML_PARSER_TYPE_BUFFER);
    /* What does this code do? */
    /*
    om_namespace = axiom_namespace_create(env, "", "");

    if(om_namespace)
    */
    {
        namespace_uri = axiom_namespace_get_uri(om_text->ns, env);
        namespace_prefix = axiom_namespace_get_prefix(om_text->ns, env);
        axiom_xml_writer_write_namespace(xml_writer, env, namespace_prefix, namespace_uri);
        axiom_xml_writer_set_prefix(xml_writer, env, namespace_prefix, namespace_uri);
    }
    return AXIS2_SUCCESS;
}
示例#3
0
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;
}
示例#4
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_text_serialize_attribute(
    axiom_text_t * om_text,
    const axutil_env_t * env,
    axiom_output_t * om_output,
    axiom_attribute_t * om_attribute)
{
    axiom_xml_writer_t *xml_writer = NULL;
    axiom_namespace_t *om_namespace = NULL;

    axis2_char_t *namespace_uri = NULL;
    axis2_char_t *prefix = NULL;
    axis2_char_t *attribute_local_name = NULL;
    axis2_char_t *attribute_value = NULL;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    (void)om_output;

    xml_writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0,
        AXIS2_XML_PARSER_TYPE_BUFFER);
    om_namespace = axiom_namespace_create(env, "", "");

    namespace_uri = axiom_namespace_get_uri(om_text->ns, env);
    attribute_local_name = axiom_attribute_get_localname(om_attribute, env);

    if(om_namespace)
    {
        prefix = axiom_namespace_get_prefix(om_text->ns, env);
        attribute_value = axiom_attribute_get_value(om_attribute, env);
        if(prefix)
        {
            axiom_xml_writer_write_attribute(xml_writer, env, attribute_local_name, attribute_value);
        }
        else
        {
            axiom_xml_writer_write_attribute_with_namespace(xml_writer, env, attribute_local_name,
                attribute_value, namespace_uri);
        }
    }
    else
    {
        axiom_xml_writer_write_attribute(xml_writer, env, attribute_local_name, attribute_value);
    }
    axiom_namespace_free(om_namespace, env);
    return AXIS2_SUCCESS;
}
示例#5
0
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;
}
static void
ngx_squ_xml_parse_children(squ_State *l, axutil_env_t *env,
    axiom_node_t *parent, axiom_element_t *parent_elem)
{
    int                              n;
    char                            *uri, *prefix, *name, *text, *value;
    axiom_node_t                    *node;
    axutil_hash_t                   *attrs;
    axiom_element_t                 *elem;
    ngx_squ_thread_t                *thr;
    axiom_attribute_t               *attr;
    axiom_namespace_t               *ns;
    axutil_hash_index_t             *hi;
    axiom_child_element_iterator_t  *it;

    thr = ngx_squ_thread(l);

    ngx_log_debug0(NGX_LOG_DEBUG_CORE, thr->log, 0, "squ xml parse children");

    it = axiom_element_get_child_elements(parent_elem, env, parent);
    if (it == NULL) {
        return;
    }

    n = 1;

    do {

        node = axiom_child_element_iterator_next(it, env);
        elem = axiom_node_get_data_element(node, env);
        name = axiom_element_get_localname(elem, env);

        squ_createtable(l, 2, 4);

        squ_pushstring(l, name);
        squ_setfield(l, -2, "name");

        ns = axiom_element_get_namespace(elem, env, node);
        if (ns != NULL) {
            uri = axiom_namespace_get_uri(ns, env);
            if (uri != NULL) {
                squ_pushstring(l, uri);
                squ_setfield(l, -2, "uri");
            }

            prefix = axiom_namespace_get_prefix(ns, env);
            if (prefix != NULL) {
                squ_pushstring(l, prefix);
                squ_setfield(l, -2, "prefix");
            }
        }

        attrs = axiom_element_get_all_attributes(elem, env);
        if (attrs != NULL) {
            squ_newtable(l);

            hi = axutil_hash_first(attrs, env);

            do {
                if (hi == NULL) {
                    break;
                }

                axutil_hash_this(hi, NULL, NULL, (void **) &attr);

                name = axiom_attribute_get_localname(attr, env);
                value = axiom_attribute_get_value(attr, env);

                squ_pushstring(l, value);
                squ_setfield(l, -2, name);

                hi = axutil_hash_next(env, hi);
            } while (1);

            squ_setfield(l, -2, "attributes");
        }

        text = axiom_element_get_text(elem, env, node);
        if (text != NULL) {
            squ_pushstring(l, text);
            squ_setfield(l, -2, "text");

        } else {
            squ_newtable(l);

            ngx_squ_xml_parse_children(l, env, node, elem);

            squ_setfield(l, -2, "children");
        }

        squ_setfield(l, -2, name);

        squ_getfield(l, -1, name);
        squ_rawseti(l, -2, n++);

    } while (axiom_child_element_iterator_has_next(it, env) == AXIS2_TRUE);
}
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;
}