You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2007/03/22 11:47:31 UTC
svn commit: r521202 - in /webservices/axis2/trunk/c/axiom:
include/axiom_attribute.h include/axiom_element.h include/axiom_namespace.h
src/om/om_attribute.c src/om/om_element.c src/om/om_namespace.c
src/om/om_stax_builder.c
Author: samisa
Date: Thu Mar 22 03:47:28 2007
New Revision: 521202
URL: http://svn.apache.org/viewvc?view=rev&rev=521202
Log:
Added string in place of char*
Modified:
webservices/axis2/trunk/c/axiom/include/axiom_attribute.h
webservices/axis2/trunk/c/axiom/include/axiom_element.h
webservices/axis2/trunk/c/axiom/include/axiom_namespace.h
webservices/axis2/trunk/c/axiom/src/om/om_attribute.c
webservices/axis2/trunk/c/axiom/src/om/om_element.c
webservices/axis2/trunk/c/axiom/src/om/om_namespace.c
webservices/axis2/trunk/c/axiom/src/om/om_stax_builder.c
Modified: webservices/axis2/trunk/c/axiom/include/axiom_attribute.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/include/axiom_attribute.h?view=diff&rev=521202&r1=521201&r2=521202
==============================================================================
--- webservices/axis2/trunk/c/axiom/include/axiom_attribute.h (original)
+++ webservices/axis2/trunk/c/axiom/include/axiom_attribute.h Thu Mar 22 03:47:28 2007
@@ -179,6 +179,30 @@
axiom_attribute_increment_ref(struct axiom_attribute *om_attribute,
const axis2_env_t *env);
+ AXIS2_EXTERN axiom_attribute_t* AXIS2_CALL
+ axiom_attribute_create_str(const axis2_env_t *env,
+ axis2_string_t * localname,
+ axis2_string_t * value,
+ axiom_namespace_t * ns);
+
+ AXIS2_EXTERN axis2_string_t* AXIS2_CALL
+ axiom_attribute_get_localname_str(axiom_attribute_t *attribute,
+ const axis2_env_t *env);
+
+ AXIS2_EXTERN axis2_string_t* AXIS2_CALL
+ axiom_attribute_get_value_str(axiom_attribute_t *attribute,
+ const axis2_env_t *env);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axiom_attribute_set_localname_str(axiom_attribute_t *attribute,
+ const axis2_env_t *env,
+ axis2_string_t *localname);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axiom_attribute_set_value_str(axiom_attribute_t *attribute,
+ const axis2_env_t *env,
+ axis2_string_t *value);
+
/** @} */
#ifdef __cplusplus
Modified: webservices/axis2/trunk/c/axiom/include/axiom_element.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/include/axiom_element.h?view=diff&rev=521202&r1=521201&r2=521202
==============================================================================
--- webservices/axis2/trunk/c/axiom/include/axiom_element.h (original)
+++ webservices/axis2/trunk/c/axiom/include/axiom_element.h Thu Mar 22 03:47:28 2007
@@ -485,6 +485,23 @@
const axis2_env_t *env,
axis2_char_t *attr_name);
+ AXIS2_EXTERN axiom_element_t *AXIS2_CALL
+ axiom_element_create_str(const axis2_env_t *env,
+ axiom_node_t *parent,
+ axis2_string_t *localname,
+ axiom_namespace_t *ns,
+ axiom_node_t **node);
+
+ AXIS2_EXTERN axis2_string_t* AXIS2_CALL
+ axiom_element_get_localname_str(axiom_element_t *om_element,
+ const axis2_env_t *env);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axiom_element_set_localname_str(axiom_element_t *om_element,
+ const axis2_env_t *env,
+ axis2_string_t *localname);
+
+
/** @} */
Modified: webservices/axis2/trunk/c/axiom/include/axiom_namespace.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/include/axiom_namespace.h?view=diff&rev=521202&r1=521201&r2=521202
==============================================================================
--- webservices/axis2/trunk/c/axiom/include/axiom_namespace.h (original)
+++ webservices/axis2/trunk/c/axiom/include/axiom_namespace.h Thu Mar 22 03:47:28 2007
@@ -21,6 +21,7 @@
#include <axis2_utils_defines.h>
#include <axis2_env.h>
#include <axiom_output.h>
+#include <axis2_string.h>
#ifdef __cplusplus
extern "C"
@@ -122,6 +123,24 @@
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_namespace_increment_ref(struct axiom_namespace *om_namespace,
+ const axis2_env_t *env);
+
+ AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL
+ axiom_namespace_create_str(const axis2_env_t *env,
+ axis2_string_t * uri,
+ axis2_string_t * prefix);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axiom_namespace_set_uri_str(axiom_namespace_t *om_namespace,
+ const axis2_env_t *env,
+ axis2_string_t *uri);
+
+ AXIS2_EXTERN axis2_string_t *AXIS2_CALL
+ axiom_namespace_get_uri_str(axiom_namespace_t *om_namespace,
+ const axis2_env_t *env);
+
+ AXIS2_EXTERN axis2_string_t *AXIS2_CALL
+ axiom_namespace_get_prefix_str(axiom_namespace_t *om_namespace,
const axis2_env_t *env);
/** @} */
Modified: webservices/axis2/trunk/c/axiom/src/om/om_attribute.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/om/om_attribute.c?view=diff&rev=521202&r1=521201&r2=521202
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/om/om_attribute.c (original)
+++ webservices/axis2/trunk/c/axiom/src/om/om_attribute.c Thu Mar 22 03:47:28 2007
@@ -22,9 +22,9 @@
struct axiom_attribute
{
/** localname of this attribute */
- axis2_char_t *localname;
+ axis2_string_t *localname;
/** value of this attribute */
- axis2_char_t *value;
+ axis2_string_t *value;
/** attribute namespace */
axiom_namespace_t *ns;
/** store qname here */
@@ -57,7 +57,7 @@
attribute->ns = NULL;
attribute->qname = NULL;
- attribute->localname = (axis2_char_t*) axis2_strdup(localname, env);
+ attribute->localname = axis2_string_create(env, localname);
if (!(attribute->localname))
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
@@ -66,11 +66,11 @@
}
if (value)
{
- attribute->value = (axis2_char_t*) axis2_strdup(value, env);
+ attribute->value = axis2_string_create(env, value);
if (!(attribute->value))
{
AXIS2_ERROR_SET(env->error , AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- AXIS2_FREE(env->allocator, attribute->localname);
+ axis2_string_free(env->allocator, attribute->localname);
AXIS2_FREE(env->allocator, attribute);
return NULL;
}
@@ -96,11 +96,11 @@
if (attribute->localname)
{
- AXIS2_FREE(env->allocator, attribute->localname);
+ axis2_string_free(attribute->localname, env);
}
if (attribute->value)
{
- AXIS2_FREE(env->allocator, attribute->value);
+ axis2_string_free(attribute->value, env);
}
if (attribute->qname)
{
@@ -134,13 +134,14 @@
if (attribute->ns)
{
qname = axis2_qname_create(env,
- attribute->localname,
+ axis2_string_get_buffer(attribute->localname, env),
axiom_namespace_get_uri(attribute->ns, env),
axiom_namespace_get_prefix(attribute->ns, env));
}
else
{
- qname = axis2_qname_create(env, attribute->localname,
+ qname = axis2_qname_create(env,
+ axis2_string_get_buffer(attribute->localname, env),
NULL, NULL);
}
attribute->qname = qname;
@@ -170,20 +171,23 @@
if ((uri) && (NULL != prefix) && (axis2_strcmp(prefix, "") != 0))
{
status = axiom_output_write(om_output, env, AXIOM_ATTRIBUTE, 4,
- attribute->localname,
- attribute->value,
+ axis2_string_get_buffer(attribute->localname, env),
+ axis2_string_get_buffer(attribute->value, env),
uri , prefix);
}
else if (uri)
{
status = axiom_output_write(om_output, env, AXIOM_ATTRIBUTE, 3,
- attribute->localname, attribute->value, uri);
+ axis2_string_get_buffer(attribute->localname, env),
+ axis2_string_get_buffer(attribute->value, env),
+ uri);
}
}
else
{
status = axiom_output_write(om_output, env, AXIOM_ATTRIBUTE, 2,
- attribute->localname, attribute->value);
+ axis2_string_get_buffer(attribute->localname, env),
+ axis2_string_get_buffer(attribute->value, env));
}
return status;
}
@@ -192,16 +196,22 @@
axiom_attribute_get_localname(axiom_attribute_t *attribute,
const axis2_env_t *env)
{
- AXIS2_ENV_CHECK(env, NULL);
- return attribute->localname;
+ if (attribute->localname)
+ {
+ return axis2_string_get_buffer(attribute->localname, env);
+ }
+ return NULL;
}
AXIS2_EXTERN axis2_char_t* AXIS2_CALL
axiom_attribute_get_value(axiom_attribute_t *attribute,
const axis2_env_t *env)
{
- AXIS2_ENV_CHECK(env, NULL);
- return attribute->value;
+ if (attribute->value)
+ {
+ return axis2_string_get_buffer(attribute->value, env);
+ }
+ return NULL;
}
AXIS2_EXTERN axiom_namespace_t* AXIS2_CALL
@@ -220,12 +230,13 @@
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE);
- if ((attribute->localname))
+ if (attribute->localname)
{
- AXIS2_FREE(env->allocator, attribute->localname);
+ axis2_string_free(attribute->localname, env);
+ attribute->localname = NULL;
}
- attribute->localname = (axis2_char_t*)axis2_strdup(localname, env);
+ attribute->localname = axis2_string_create(env, localname);
if (!(attribute->localname))
{
@@ -246,10 +257,11 @@
if (attribute->value)
{
- AXIS2_FREE(env->allocator, attribute->value);
+ axis2_string_free(attribute->value, env);
+ attribute->value = NULL;
}
- attribute->value = (axis2_char_t*)axis2_strdup(value, env);
+ attribute->value = axis2_string_create(env, value);
if (!(attribute->value))
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
@@ -278,7 +290,7 @@
AXIS2_ENV_CHECK(env, NULL);
/** namespace is not cloned since it is a shollow copy*/
- cloned_attr = axiom_attribute_create(env,
+ cloned_attr = axiom_attribute_create_str(env,
attribute->localname,
attribute->value,
attribute->ns);
@@ -295,6 +307,112 @@
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
om_attribute->ref++;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axiom_attribute_t* AXIS2_CALL
+axiom_attribute_create_str(const axis2_env_t *env,
+ axis2_string_t * localname,
+ axis2_string_t * value,
+ axiom_namespace_t * ns)
+{
+ axiom_attribute_t *attribute = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+ /* localname is mandatory */
+ AXIS2_PARAM_CHECK(env->error, localname, NULL);
+
+ attribute = (axiom_attribute_t *) AXIS2_MALLOC(env->allocator,
+ sizeof(axiom_attribute_t));
+ if (!attribute)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+ /** initialize fields */
+ attribute->localname = NULL;
+ attribute->value = NULL;
+ attribute->ns = NULL;
+ attribute->qname = NULL;
+
+ attribute->localname = axis2_string_clone(localname, env);
+ if (!(attribute->localname))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_FREE(env->allocator, attribute);
+ return NULL;
+ }
+ if (value)
+ {
+ attribute->value = axis2_string_clone(value, env);
+ if (!(attribute->value))
+ {
+ AXIS2_ERROR_SET(env->error , AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ axis2_string_free(env->allocator, attribute->localname);
+ AXIS2_FREE(env->allocator, attribute);
+ return NULL;
+ }
+ }
+ attribute->ns = ns;
+
+ attribute->ref = 0;
+
+ return attribute;
+}
+
+AXIS2_EXTERN axis2_string_t* AXIS2_CALL
+axiom_attribute_get_localname_str(axiom_attribute_t *attribute,
+ const axis2_env_t *env)
+{
+ return attribute->localname;
+}
+
+AXIS2_EXTERN axis2_string_t* AXIS2_CALL
+axiom_attribute_get_value_str(axiom_attribute_t *attribute,
+ const axis2_env_t *env)
+{
+ return attribute->value;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axiom_attribute_set_localname_str(axiom_attribute_t *attribute,
+ const axis2_env_t *env,
+ axis2_string_t *localname)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE);
+
+ if (attribute->localname)
+ {
+ axis2_string_free(attribute->localname, env);
+ attribute->localname = NULL;
+ }
+
+ attribute->localname = axis2_string_clone(localname, env);
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axiom_attribute_set_value_str(axiom_attribute_t *attribute,
+ const axis2_env_t *env,
+ axis2_string_t *value)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE);
+
+ if (attribute->value)
+ {
+ axis2_string_free(attribute->value, env);
+ attribute->value = NULL;
+ }
+
+ attribute->value = axis2_string_clone(value, env);
+ if (!(attribute->value))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
return AXIS2_SUCCESS;
}
Modified: webservices/axis2/trunk/c/axiom/src/om/om_element.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/om/om_element.c?view=diff&rev=521202&r1=521201&r2=521202
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/om/om_element.c (original)
+++ webservices/axis2/trunk/c/axiom/src/om/om_element.c Thu Mar 22 03:47:28 2007
@@ -29,7 +29,7 @@
/** Element's namespace */
axiom_namespace_t *ns;
/** Element's local name */
- axis2_char_t *localname;
+ axis2_string_t *localname;
/** List of attributes */
axis2_hash_t *attributes;
/** List of namespaces */
@@ -91,7 +91,7 @@
element->text_value = NULL;
element->next_ns_prefix_number = 0;
- element->localname = (axis2_char_t *) axis2_strdup(localname, env);
+ element->localname = axis2_string_create(env, localname);
if (!element->localname)
{
AXIS2_FREE(env->allocator, element);
@@ -609,7 +609,7 @@
if (om_element->localname)
{
- AXIS2_FREE(env->allocator, om_element->localname);
+ axis2_string_free(om_element->localname, env);
}
if (om_element->ns)
{
@@ -695,19 +695,19 @@
if ((uri) && (prefix) && (axis2_strcmp(prefix, "") != 0))
{
status = axiom_output_write(om_output, env,
- AXIOM_ELEMENT, 3, om_element->localname,
+ AXIOM_ELEMENT, 3, axis2_string_get_buffer(om_element->localname, env),
uri, prefix);
}
else if (uri)
{
status = axiom_output_write(om_output, env,
- AXIOM_ELEMENT, 2, om_element->localname, uri);
+ AXIOM_ELEMENT, 2, axis2_string_get_buffer(om_element->localname, env), uri);
}
}
else
{
status = axiom_output_write(om_output, env,
- AXIOM_ELEMENT, 1, om_element->localname);
+ AXIOM_ELEMENT, 1, axis2_string_get_buffer(om_element->localname, env));
}
if (om_element->attributes)
{
@@ -773,7 +773,10 @@
axiom_element_get_localname(axiom_element_t *om_element,
const axis2_env_t *env)
{
- return om_element->localname;
+ if (om_element->localname)
+ return axis2_string_get_buffer(om_element->localname, env);
+ else
+ return NULL;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -785,10 +788,10 @@
AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE);
if (om_element->localname)
{
- AXIS2_FREE(env->allocator, om_element->localname);
+ axis2_string_free(om_element->localname, env);
om_element->localname = NULL;
}
- om_element->localname = (axis2_char_t*)axis2_strdup(localname, env);
+ om_element->localname = axis2_string_create(env, localname);
if (!(om_element->localname))
{
return AXIS2_FAILURE;
@@ -892,14 +895,14 @@
if (axiom_namespace_get_prefix(ns, env))
{
om_element->qname = axis2_qname_create(env ,
- om_element->localname,
+ axis2_string_get_buffer(om_element->localname, env),
axiom_namespace_get_uri(ns, env),
axiom_namespace_get_prefix(ns, env));
}
else
{
om_element->qname = axis2_qname_create(env,
- om_element->localname,
+ axis2_string_get_buffer(om_element->localname, env),
axiom_namespace_get_uri(ns, env),
NULL);
}
@@ -907,7 +910,7 @@
else
{
om_element->qname = axis2_qname_create(env,
- om_element->localname,
+ axis2_string_get_buffer(om_element->localname, env),
NULL, NULL);
}
}
@@ -1505,5 +1508,118 @@
return NULL;
}
+AXIS2_EXTERN axiom_element_t *AXIS2_CALL
+axiom_element_create_str(const axis2_env_t *env,
+ axiom_node_t *parent,
+ axis2_string_t *localname,
+ axiom_namespace_t *ns,
+ axiom_node_t **node)
+{
+ axiom_element_t *element;
+ AXIS2_ENV_CHECK(env, NULL);
+
+ if (!localname || !node)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ (*node) = axiom_node_create(env);
+ if (!(*node))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+ 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);
+ 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->localname = axis2_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;
+ }
+ if (parent)
+ {
+ AXIOM_NODE_ADD_CHILD(parent, env, (*node));
+ }
+ axiom_node_set_complete((*node), env, AXIS2_FALSE);
+ axiom_node_set_node_type((*node), env, AXIOM_ELEMENT);
+ axiom_node_set_data_element((*node), env, element);
+
+ if (ns)
+ {
+ axis2_char_t *uri = NULL;
+ axis2_char_t *prefix = NULL;
+
+ uri = axiom_namespace_get_uri(ns, env);
+ prefix = axiom_namespace_get_prefix(ns, env);
+
+ element->ns = axiom_element_find_namespace(element,
+ env, *node, uri, prefix);
+ if (!(element->ns))
+ {
+ if (axiom_element_declare_namespace(element,
+ env, *node, ns) == AXIS2_SUCCESS)
+ {
+ element->ns = ns;
+ }
+ }
+ if (prefix && axis2_strcmp(prefix, "") == 0)
+ {
+ element->ns = NULL;
+ }
+ }
+
+ return element;
+}
+
+AXIS2_EXTERN axis2_string_t* AXIS2_CALL
+axiom_element_get_localname_str(axiom_element_t *om_element,
+ const axis2_env_t *env)
+{
+ return om_element->localname;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axiom_element_set_localname_str(axiom_element_t *om_element,
+ const axis2_env_t *env,
+ axis2_string_t *localname)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE);
+
+ if (om_element->localname)
+ {
+ axis2_string_free(om_element->localname, env);
+ om_element->localname = NULL;
+ }
+
+ om_element->localname = axis2_string_clone(localname, env);
+ if (!(om_element->localname))
+ {
+ return AXIS2_FAILURE;
+ }
+ return AXIS2_SUCCESS;
+}
Modified: webservices/axis2/trunk/c/axiom/src/om/om_namespace.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/om/om_namespace.c?view=diff&rev=521202&r1=521201&r2=521202
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/om/om_namespace.c (original)
+++ webservices/axis2/trunk/c/axiom/src/om/om_namespace.c Thu Mar 22 03:47:28 2007
@@ -22,9 +22,9 @@
struct axiom_namespace
{
/** namespace URI */
- axis2_char_t *uri;
+ axis2_string_t *uri;
/** namespace prefix */
- axis2_char_t *prefix;
+ axis2_string_t *prefix;
axis2_char_t *key;
@@ -57,7 +57,7 @@
om_namespace->uri = NULL;
om_namespace->key = NULL;
- om_namespace->uri = (axis2_char_t *) axis2_strdup(uri, env);
+ om_namespace->uri = axis2_string_create(env, uri);
if (!om_namespace->uri)
{
AXIS2_FREE(env->allocator, om_namespace);
@@ -67,7 +67,7 @@
if (prefix)
{
- om_namespace->prefix = (axis2_char_t *) axis2_strdup(prefix, env);
+ om_namespace->prefix = axis2_string_create(env, prefix);
if (!om_namespace->prefix)
{
AXIS2_FREE(env->allocator, om_namespace);
@@ -93,12 +93,12 @@
if (om_namespace->prefix)
{
- AXIS2_FREE(env->allocator, om_namespace->prefix);
+ axis2_string_free(om_namespace->prefix, env);
}
if (om_namespace->uri)
{
- AXIS2_FREE(env->allocator, om_namespace->uri);
+ axis2_string_free(om_namespace->uri, env);
}
if (om_namespace->key)
@@ -130,7 +130,8 @@
if (om_namespace->uri && om_namespace1->uri)
{
- uris_differ = axis2_strcmp(om_namespace->uri, om_namespace1->uri);
+ uris_differ = axis2_strcmp(axis2_string_get_buffer(om_namespace->uri, env),
+ axis2_string_get_buffer(om_namespace1->uri, env));
}
else
{
@@ -140,7 +141,8 @@
if (om_namespace->prefix && om_namespace1->prefix)
{
prefixes_differ =
- axis2_strcmp(om_namespace->prefix, om_namespace1->prefix);
+ axis2_strcmp(axis2_string_get_buffer(om_namespace->prefix, env),
+ axis2_string_get_buffer(om_namespace1->prefix, env));
}
else
{
@@ -165,16 +167,16 @@
AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE);
if (om_namespace->uri && NULL != om_namespace->prefix &&
- axis2_strcmp(om_namespace->prefix, "") != 0)
+ axis2_strcmp(axis2_string_get_buffer(om_namespace->prefix, env), "") != 0)
{
status = axiom_output_write(om_output, env, AXIOM_NAMESPACE,
- 2, om_namespace->prefix,
- om_namespace->uri);
+ 2, axis2_string_get_buffer(om_namespace->prefix, env),
+ axis2_string_get_buffer(om_namespace->uri, env));
}
else if (om_namespace->uri)
{
status = axiom_output_write(om_output, env, AXIOM_NAMESPACE,
- 2, NULL, om_namespace->uri);
+ 2, NULL, axis2_string_get_buffer(om_namespace->uri, env));
}
return status;
}
@@ -183,7 +185,11 @@
axiom_namespace_get_uri(axiom_namespace_t *om_namespace,
const axis2_env_t *env)
{
- return om_namespace->uri;
+ if (om_namespace->uri)
+ {
+ return axis2_string_get_buffer(om_namespace->uri, env);
+ }
+ return NULL;
}
@@ -191,7 +197,11 @@
axiom_namespace_get_prefix(axiom_namespace_t *om_namespace,
const axis2_env_t *env)
{
- return om_namespace->prefix;
+ if (om_namespace->prefix)
+ {
+ return axis2_string_get_buffer(om_namespace->prefix, env);
+ }
+ return NULL;
}
AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL
@@ -202,7 +212,7 @@
AXIS2_ENV_CHECK(env, NULL);
- cloned_ns = axiom_namespace_create(env,
+ cloned_ns = axiom_namespace_create_str(env,
om_namespace->uri, om_namespace->prefix);
if (cloned_ns)
{
@@ -224,8 +234,9 @@
}
if ((om_namespace->uri) && (NULL != om_namespace->prefix))
{
- temp_str = axis2_stracat(om_namespace->uri, "|", env);
- om_namespace->key = axis2_stracat(temp_str, om_namespace->prefix, env);
+ temp_str = axis2_stracat(axis2_string_get_buffer(om_namespace->uri, env), "|", env);
+ om_namespace->key = axis2_stracat(temp_str,
+ axis2_string_get_buffer(om_namespace->prefix, env), env);
if (temp_str)
{
AXIS2_FREE(env->allocator, temp_str);
@@ -234,7 +245,8 @@
}
else if ((om_namespace->uri) && !(om_namespace->prefix))
{
- om_namespace->key = axis2_strdup (om_namespace->uri, env);
+ om_namespace->key = axis2_strdup (
+ axis2_string_get_buffer(om_namespace->uri, env), env);
if (!(om_namespace->key))
{
return NULL;
@@ -254,11 +266,11 @@
if (om_namespace->uri)
{
- AXIS2_FREE(env->allocator, om_namespace->uri);
+ axis2_string_free(om_namespace->uri, env);
om_namespace->uri = NULL;
}
- om_namespace->uri = axis2_strdup(uri, env);
+ om_namespace->uri = axis2_string_create(env, uri);
if (!(om_namespace->uri))
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
@@ -274,5 +286,92 @@
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
om_namespace->ref++;
return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL
+axiom_namespace_create_str(const axis2_env_t *env,
+ axis2_string_t * uri,
+ axis2_string_t * prefix)
+{
+ axiom_namespace_t *om_namespace = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+ if (!uri)
+ {
+ uri = axis2_string_create(env, "");
+ }
+
+ om_namespace = (axiom_namespace_t *) AXIS2_MALLOC(env->allocator,
+ sizeof(axiom_namespace_t));
+ if (!om_namespace)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY , AXIS2_FAILURE);
+ return NULL;
+ }
+
+ om_namespace->ref = 0;
+ om_namespace->prefix = NULL;
+ om_namespace->uri = NULL;
+ om_namespace->key = NULL;
+
+ om_namespace->uri = axis2_string_clone(uri, env);
+ if (!om_namespace->uri)
+ {
+ AXIS2_FREE(env->allocator, om_namespace);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ if (prefix)
+ {
+ om_namespace->prefix = axis2_string_clone(prefix, env);
+ if (!om_namespace->prefix)
+ {
+ AXIS2_FREE(env->allocator, om_namespace);
+ AXIS2_FREE(env->allocator, om_namespace->uri);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+ }
+
+ return om_namespace ;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axiom_namespace_set_uri_str(axiom_namespace_t *om_namespace,
+ const axis2_env_t *env,
+ axis2_string_t *uri)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, uri, AXIS2_FAILURE);
+
+ if (om_namespace->uri)
+ {
+ axis2_string_free(om_namespace->uri, env);
+ om_namespace->uri = NULL;
+ }
+
+ om_namespace->uri = axis2_string_clone(env, uri);
+ if (!(om_namespace->uri))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+ return AXIS2_SUCCESS;
+
+}
+
+AXIS2_EXTERN axis2_string_t *AXIS2_CALL
+axiom_namespace_get_uri_str(axiom_namespace_t *om_namespace,
+ const axis2_env_t *env)
+{
+ return om_namespace->uri;
+}
+
+AXIS2_EXTERN axis2_string_t *AXIS2_CALL
+axiom_namespace_get_prefix_str(axiom_namespace_t *om_namespace,
+ const axis2_env_t *env)
+{
+ return om_namespace->prefix;
}
Modified: webservices/axis2/trunk/c/axiom/src/om/om_stax_builder.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/om/om_stax_builder.c?view=diff&rev=521202&r1=521201&r2=521202
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/om/om_stax_builder.c (original)
+++ webservices/axis2/trunk/c/axiom/src/om/om_stax_builder.c Thu Mar 22 03:47:28 2007
@@ -102,6 +102,9 @@
axis2_char_t *prefix = NULL;
axis2_char_t *attr_name = NULL;
axis2_char_t *attr_value = NULL;
+ axis2_string_t *attr_name_str = NULL;
+ axis2_string_t *attr_value_str = NULL;
+
axis2_status_t status = AXIS2_SUCCESS;
@@ -143,11 +146,16 @@
attr_name = AXIOM_XML_READER_GET_ATTRIBUTE_NAME_BY_NUMBER(
om_builder->parser, env, i);
+ attr_name_str = axis2_string_create_assume_ownership(env, &attr_name);
+
attr_value = AXIOM_XML_READER_GET_ATTRIBUTE_VALUE_BY_NUMBER(
om_builder->parser, env, i);
+
+ attr_value_str = axis2_string_create_assume_ownership(env, &attr_value);
+
if (attr_name)
{
- attribute = axiom_attribute_create(env, attr_name, attr_value, ns);
+ attribute = axiom_attribute_create_str(env, attr_name_str, attr_value_str, ns);
if (!attribute)
{
return AXIS2_FAILURE;
@@ -168,13 +176,13 @@
{
AXIOM_XML_READER_XML_FREE(om_builder->parser, env, prefix);
}
- if (attr_name)
+ if (attr_name_str)
{
- AXIOM_XML_READER_XML_FREE(om_builder->parser, env, attr_name);
+ axis2_string_free(attr_name_str, env);
}
- if (attr_value)
+ if (attr_value_str)
{
- AXIOM_XML_READER_XML_FREE(om_builder->parser, env, attr_value);
+ axis2_string_free(attr_value_str, env);
}
ns = NULL;
}
@@ -206,7 +214,6 @@
}
temp_value_str = axis2_string_create_assume_ownership(env, &temp_value);
- /*temp_value_str = axis2_string_create(env, temp_value);*/
if (AXIOM_NODE_IS_COMPLETE(om_builder->lastnode, env))
{
@@ -223,7 +230,6 @@
axiom_node_set_complete(node , env, AXIS2_TRUE);
om_builder->lastnode = node;
- /*AXIOM_XML_READER_XML_FREE(om_builder->parser , env, temp_value); */
axis2_string_free(temp_value_str, env);
return node;
}
@@ -289,6 +295,8 @@
axis2_char_t *temp_prefix = NULL;
axis2_char_t *temp_ns_prefix = NULL;
axis2_char_t *temp_ns_uri = NULL;
+ axis2_string_t *temp_ns_prefix_str = NULL;
+ axis2_string_t *temp_ns_uri_str = NULL;
int i = 0;
@@ -303,14 +311,19 @@
temp_ns_uri = AXIOM_XML_READER_GET_NAMESPACE_URI_BY_NUMBER(
om_builder->parser, env , i);
+ temp_ns_prefix_str = axis2_string_create_assume_ownership(env, &temp_ns_prefix);
+
+ temp_ns_uri_str = axis2_string_create_assume_ownership(env, &temp_ns_uri);
+
if (!temp_ns_prefix || axis2_strcmp(temp_ns_prefix, "xmlns") == 0)
{
/** default namespace case */
/** !temp_ns_prefix is for guththila */
axiom_element_t *om_ele = NULL;
+ temp_ns_prefix_str = axis2_string_create(env, "");
om_ele = (axiom_element_t *)AXIOM_NODE_GET_DATA_ELEMENT(node, env);
- om_ns = axiom_namespace_create(env, temp_ns_uri, "");
+ om_ns = axiom_namespace_create_str(env, temp_ns_uri_str, temp_ns_prefix_str);
if (!om_ns || !om_ele)
{
return AXIS2_FAILURE;
@@ -330,7 +343,7 @@
axis2_char_t *prefix = NULL;
om_ele = (axiom_element_t *)AXIOM_NODE_GET_DATA_ELEMENT(node, env);
- om_ns = axiom_namespace_create(env, temp_ns_uri, temp_ns_prefix);
+ om_ns = axiom_namespace_create_str(env, temp_ns_uri_str, temp_ns_prefix_str);
if (!om_ns || !om_ele)
{
return AXIS2_FAILURE;
@@ -342,8 +355,8 @@
axis2_hash_set(om_builder->declared_namespaces,
prefix, AXIS2_HASH_KEY_STRING, om_ns);
}
- AXIOM_XML_READER_XML_FREE(om_builder->parser, env, temp_ns_prefix);
- AXIOM_XML_READER_XML_FREE(om_builder->parser, env, temp_ns_uri);
+ axis2_string_free(temp_ns_uri_str, env);
+ axis2_string_free(temp_ns_prefix_str, env);
if (!om_ns)
{
/* something went wrong */
@@ -387,6 +400,7 @@
axiom_node_t *element_node = NULL;
axiom_element_t *om_ele = NULL;
axis2_char_t *temp_localname = NULL;
+ axis2_string_t *temp_localname_str = NULL;
AXIS2_ENV_CHECK(env, NULL);
AXIS2_PARAM_CHECK(env->error, om_builder, NULL);
@@ -399,12 +413,14 @@
AXIS2_FAILURE);
return NULL;
}
-
+
+ temp_localname_str = axis2_string_create_assume_ownership(env, &temp_localname);
+
om_builder->element_level++;
if (!(om_builder->lastnode))
{
- om_ele = axiom_element_create(env , NULL, temp_localname, NULL, &element_node);
+ om_ele = axiom_element_create_str(env , NULL, temp_localname_str, NULL, &element_node);
if (!om_ele)
{
return NULL;
@@ -423,9 +439,9 @@
}
else if (AXIOM_NODE_IS_COMPLETE(om_builder->lastnode, env))
{
- om_ele = axiom_element_create(env,
+ om_ele = axiom_element_create_str(env,
AXIOM_NODE_GET_PARENT(om_builder->lastnode, env),
- temp_localname, NULL, &element_node);
+ temp_localname_str, NULL, &element_node);
if (!om_ele)
{
return NULL;
@@ -445,8 +461,8 @@
}
else
{
- om_ele = axiom_element_create(env, om_builder->lastnode,
- temp_localname, NULL, &element_node);
+ om_ele = axiom_element_create_str(env, om_builder->lastnode,
+ temp_localname_str, NULL, &element_node);
if (element_node)
{
axiom_node_set_first_child(om_builder->lastnode,
@@ -456,10 +472,8 @@
axiom_node_set_builder(element_node, env, om_builder);
}
}
- if (temp_localname)
- {
- AXIOM_XML_READER_XML_FREE(om_builder->parser , env, temp_localname);
- }
+
+ axis2_string_free(temp_localname_str, env);
/** order of processing namespaces first is important */
axiom_stax_builder_process_namespaces(om_builder, env, element_node, 0);
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org