axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r331946 [2/4] - in /webservices/axis2/trunk/c: include/ modules/xml/om/src/
Date Wed, 09 Nov 2005 04:30:26 GMT
Modified: webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_attribute.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_attribute.c?rev=331946&r1=331945&r2=331946&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_attribute.c (original)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_attribute.c Tue Nov  8 20:29:48 2005
@@ -18,122 +18,175 @@
 #include <string.h>
 #include <axis2_defines.h>
 
-axis2_status_t AXIS2_CALL axis2_om_attribute_impl_free (axis2_env_t *
-                                             environment,
-                                             axis2_om_attribute_t *
-                                             attribute);
-
-axis2_qname_t * AXIS2_CALL axis2_om_attribute_impl_get_qname (axis2_env_t *
-                                                  environment,
-                                                  axis2_om_attribute_t *
-                                                  attribute);
-
-axis2_status_t AXIS2_CALL axis2_om_attribute_impl_serialize (axis2_env_t *
-                                                  environment,
-                                                  axis2_om_attribute_t *
-                                                  attribute,
-                                                  axis2_om_output_t *
-                                                  om_output);
+axis2_status_t AXIS2_CALL 
+axis2_om_attribute_free (axis2_om_attribute_t *om_attribute,
+                              axis2_env_t **env);
+
+axis2_qname_t * AXIS2_CALL 
+axis2_om_attribute_get_qname (axis2_om_attribute_t *om_attribute,
+                                   axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL 
+axis2_om_attribute_serialize (axis2_om_attribute_t *om_attribute,
+                                   axis2_env_t **env,
+                                   axis2_om_output_t *om_output);
+
+axis2_char_t* AXIS2_CALL
+axis2_om_attribute_get_localname(axis2_om_attribute_t *om_attribute,
+                                 axis2_env_t **env);
+
+axis2_char_t* AXIS2_CALL
+axis2_om_attribute_get_value(axis2_om_attribute_t *om_attribute,
+                             axis2_env_t **env);
+
+axis2_om_namespace_t* AXIS2_CALL 
+axis2_om_attribute_get_namespace(axis2_om_attribute_t *om_attribute,
+                                 axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL
+axis2_om_attribute_set_localname(axis2_om_attribute_t *om_attribute,
+                                 axis2_env_t **env,
+                                 const axis2_char_t *localname);
+
+axis2_status_t AXIS2_CALL
+axis2_om_attribute_set_value(axis2_om_attribute_t *om_attribute,
+                             axis2_env_t **env,
+                             const axis2_char_t *value);
+
+axis2_status_t AXIS2_CALL
+axis2_om_attribute_set_namespace(axis2_om_attribute_t *om_attribute,
+                                 axis2_env_t **env,
+                                 axis2_om_namespace_t *om_namespace);
+                                                                                                                                                                                             
+/*********************************** axis2_om_attribute_impl_t ************************/
+
+typedef struct axis2_om_attribute_impl
+{
+    axis2_om_attribute_t om_attribute;
+    /** localname of this attribute  */
+    axis2_char_t *localname;
+    /** value of this attribute */
+    axis2_char_t *value;
+    /** attribute namespace */
+    axis2_om_namespace_t *ns;
+
+
+
+}axis2_om_attribute_impl_t;
+
+/***************************************** macro ***********************************/
+
+#define AXIS2_INTF_TO_IMPL(om_attr) ((axis2_om_attribute_impl_t*)om_attr)
 
 
+/*************************************** *******************************************/
+
 AXIS2_DECLARE(axis2_om_attribute_t*)
- axis2_om_attribute_create (axis2_env_t * environment,
+axis2_om_attribute_create (axis2_env_t **env,
                            const axis2_char_t * localname,
                            const axis2_char_t * value,
                            axis2_om_namespace_t * ns)
 {
-    axis2_om_attribute_t *attribute = NULL;
+    axis2_om_attribute_impl_t *attribute = NULL;
+    
+    AXIS2_ENV_CHECK(env, NULL);
     if (!localname)
     {   /* localname is mandatory */
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return NULL;
     }
 
-    attribute =
-        (axis2_om_attribute_t *) axis2_malloc (environment->allocator,
-                                               sizeof (axis2_om_attribute_t));
+    attribute = (axis2_om_attribute_impl_t *) AXIS2_MALLOC ((*env)->allocator,
+                                               sizeof (axis2_om_attribute_impl_t));
     if (!attribute)
     {
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error , AXIS2_ERROR_NO_MEMORY);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return NULL;
     }
     /**  initialize fields */
-    attribute->localname = axis2_strdup (environment->string, localname);
+    attribute->localname =(axis2_char_t*) AXIS2_STRDUP(localname,env);
     if (!(attribute->localname))
     {
-        axis2_free (environment->allocator, attribute);
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
+        AXIS2_FREE ((*env)->allocator, attribute);
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_NO_MEMORY);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return NULL;
     }
-    attribute->value = axis2_strdup (environment->string, value);
+    attribute->value =(axis2_char_t*) AXIS2_STRDUP (value,env);
     if (!(attribute->value))
     {
-        axis2_free (environment->allocator, attribute);
-        axis2_free (environment->allocator, attribute);
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
+        AXIS2_FREE ((*env)->allocator, attribute->localname);
+        AXIS2_FREE ((*env)->allocator, attribute);
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_NO_MEMORY);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return NULL;
     }
     attribute->ns = ns;
 
     /** operations */
 
-    attribute->ops =
-        axis2_malloc (environment->allocator,
+    attribute->om_attribute.ops = (axis2_om_attribute_ops_t*)AXIS2_MALLOC ((*env)->allocator,
                       sizeof (axis2_om_attribute_ops_t));
-    if (!(attribute->ops))
+    if (!(attribute->om_attribute.ops))
     {
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
-        axis2_free (environment->allocator, attribute->localname);
-        axis2_free (environment->allocator, attribute->value);
-        axis2_free (environment->allocator, attribute);
+        AXIS2_FREE ((*env)->allocator, attribute->value);
+        AXIS2_FREE ((*env)->allocator, attribute->localname);
+        AXIS2_FREE ((*env)->allocator, attribute);
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_NO_MEMORY);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return NULL;
     }
-    attribute->ops->axis2_om_attribute_ops_free =
-        axis2_om_attribute_impl_free;
-    attribute->ops->axis2_om_attribute_ops_get_qname =
-        axis2_om_attribute_impl_get_qname;
-    attribute->ops->axis2_om_attribute_ops_serialize =
-        axis2_om_attribute_impl_serialize;
-    return attribute;
+  /*  attribute->ops->free = axis2_om_attribute_impl_free;
+    attribute->ops->get_qname = axis2_om_attribute_impl_get_qname;
+    attribute->ops->serialize = axis2_om_attribute_impl_serialize; */
+    return &(attribute->om_attribute);
 }
 
-axis2_status_t AXIS2_CALL
-axis2_om_attribute_impl_free (axis2_env_t * environment,
-                              axis2_om_attribute_t * attribute)
-{
-    if (attribute)
+
+axis2_status_t AXIS2_CALL 
+axis2_om_attribute_free (axis2_om_attribute_t *om_attribute,
+                              axis2_env_t **env)
+{   
+    AXIS2_FUNC_PARAM_CHECK(om_attribute, env, AXIS2_FAILURE);
+    if (AXIS2_INTF_TO_IMPL(om_attribute))
     {
-        if (attribute->localname)
+        if (AXIS2_INTF_TO_IMPL(om_attribute)->localname)
         {
-            axis2_free (environment->allocator, attribute->localname);
+            AXIS2_FREE ((*env)->allocator, AXIS2_INTF_TO_IMPL(om_attribute)->localname);
         }
-        if (attribute->value)
+        if (AXIS2_INTF_TO_IMPL(om_attribute)->value)
         {
-            axis2_free (environment->allocator, attribute->value);
+            AXIS2_FREE  ((*env)->allocator, AXIS2_INTF_TO_IMPL(om_attribute)->value);
         }
-        axis2_free (environment->allocator, attribute);
+        AXIS2_FREE  ((*env)->allocator, AXIS2_INTF_TO_IMPL(om_attribute));
         return AXIS2_SUCCESS;
     }
     return AXIS2_FAILURE;
 }
 
-axis2_qname_t* AXIS2_CALL
-axis2_om_attribute_impl_get_qname (axis2_env_t * environment,
-                                   axis2_om_attribute_t * attribute)
+
+
+axis2_qname_t * AXIS2_CALL 
+axis2_om_attribute_get_qname (axis2_om_attribute_t *om_attribute,
+                                   axis2_env_t **env)
 {
     axis2_qname_t *qname = NULL;
-    if (!attribute)
+    AXIS2_FUNC_PARAM_CHECK(om_attribute, env, NULL);
+
+    if (AXIS2_INTF_TO_IMPL(om_attribute)->ns)
     {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
-        return NULL;
-    }
-    if (attribute->ns)
+        axis2_om_namespace_t *ns = NULL;
+        ns = AXIS2_INTF_TO_IMPL(om_attribute)->ns;
+        
         qname =
-            axis2_qname_create (environment, attribute->localname,
-                                attribute->ns->uri, attribute->ns->prefix);
+            axis2_qname_create (env, AXIS2_INTF_TO_IMPL(om_attribute)->localname,
+                                AXIS2_OM_NAMESPACE_GET_URI(ns, env),AXIS2_OM_NAMESPACE_GET_PREFIX(ns, env));
+    }                                
     else
         qname =
-            axis2_qname_create (environment, attribute->localname, NULL,
+            axis2_qname_create (env,AXIS2_INTF_TO_IMPL(om_attribute)->localname, NULL,
                                 NULL);
 
     return qname;
@@ -141,30 +194,119 @@
 
 
 axis2_status_t AXIS2_CALL
-axis2_om_attribute_impl_serialize (axis2_env_t * environment,
-                                   axis2_om_attribute_t * attribute,
-                                   axis2_om_output_t * om_output)
+axis2_om_attribute_serialize (axis2_om_attribute_t *om_attribute,
+                              axis2_env_t **env,
+                              axis2_om_output_t *om_output)
 {
     int status = AXIS2_SUCCESS;
-    if (!attribute || !om_output)
+    axis2_om_attribute_impl_t *attribute = NULL;
+    
+    
+    AXIS2_FUNC_PARAM_CHECK(om_attribute, env,AXIS2_FAILURE);
+    
+    if (!om_output)
     {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
-
-    if (attribute->ns && attribute->ns->uri && attribute->ns->prefix)
-        status =
-            axis2_om_output_write (environment, om_output, AXIS2_OM_ATTRIBUTE,
-                                   4, attribute->localname, attribute->value,
-                                   attribute->ns->uri, attribute->ns->prefix);
-    else if (attribute->ns && attribute->ns->uri)
-        status =
-            axis2_om_output_write (environment, om_output, AXIS2_OM_ATTRIBUTE,
-                                   3, attribute->localname, attribute->value,
-                                   attribute->ns->uri);
+    
+    attribute = AXIS2_INTF_TO_IMPL(om_attribute);
+        
+    if (attribute->ns && AXIS2_OM_NAMESPACE_GET_URI(attribute->ns,env) && 
+        AXIS2_OM_NAMESPACE_GET_URI(attribute->ns,env))
+    {    
+        status = axis2_om_output_write (om_output, env, AXIS2_OM_ATTRIBUTE, 4,
+                                        attribute->localname,
+                                        attribute->value,
+                                        AXIS2_OM_NAMESPACE_GET_URI(attribute->ns, env),
+                                        AXIS2_OM_NAMESPACE_GET_URI(attribute->ns, env));
+    }                                   
+    else if (attribute->ns && AXIS2_OM_NAMESPACE_GET_URI(attribute->ns,env))
+    {
+        status = axis2_om_output_write (om_output, env, AXIS2_OM_ATTRIBUTE, 3, 
+                                        attribute->localname,
+                                        attribute->value,
+                                        AXIS2_OM_NAMESPACE_GET_URI(attribute->ns,env));
+    }                                   
     else
-        status =
-            axis2_om_output_write (environment, om_output, AXIS2_OM_ATTRIBUTE,
-                                   2, attribute->localname, attribute->value);
+    {
+        status = axis2_om_output_write ( om_output, env, AXIS2_OM_ATTRIBUTE, 2,
+                                         attribute->localname,
+                                         attribute->value);
+    }                                   
     return status;
 }
+
+axis2_char_t* AXIS2_CALL
+axis2_om_attribute_get_localname(axis2_om_attribute_t *om_attribute,
+                                 axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(om_attribute, env, NULL);
+    return AXIS2_INTF_TO_IMPL(om_attribute)->localname;
+
+}                                 
+
+axis2_char_t* AXIS2_CALL
+axis2_om_attribute_get_value(axis2_om_attribute_t *om_attribute,
+                             axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(om_attribute, env, NULL);
+    return AXIS2_INTF_TO_IMPL(om_attribute)->value;
+}                             
+
+axis2_om_namespace_t* AXIS2_CALL 
+axis2_om_attribute_get_namespace(axis2_om_attribute_t *om_attribute,
+                                 axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(om_attribute, env, NULL);
+    return AXIS2_INTF_TO_IMPL(om_attribute)->ns;
+}                                 
+
+axis2_status_t AXIS2_CALL
+axis2_om_attribute_set_localname(axis2_om_attribute_t *om_attribute,
+                                 axis2_env_t **env,
+                                 const axis2_char_t *localname)
+{
+    AXIS2_FUNC_PARAM_CHECK(om_attribute, env, AXIS2_FAILURE);
+    if(!localname)
+    {
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
+        return AXIS2_FAILURE;
+    }
+    AXIS2_INTF_TO_IMPL(om_attribute)->localname = (axis2_char_t*)AXIS2_STRDUP(localname,env);
+    return AXIS2_SUCCESS;
+}                                 
+
+axis2_status_t AXIS2_CALL
+axis2_om_attribute_set_value(axis2_om_attribute_t *om_attribute,
+                             axis2_env_t **env,
+                             const axis2_char_t *value)
+{
+    AXIS2_FUNC_PARAM_CHECK(om_attribute, env, AXIS2_FAILURE);
+    if(!value)
+    {
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
+        return AXIS2_FAILURE;
+    }
+    AXIS2_INTF_TO_IMPL(om_attribute)->value = (axis2_char_t*)AXIS2_STRDUP(value,env);
+    return AXIS2_SUCCESS;
+}                             
+
+axis2_status_t AXIS2_CALL
+axis2_om_attribute_set_namespace(axis2_om_attribute_t *om_attribute,
+                                 axis2_env_t **env,
+                                 axis2_om_namespace_t *om_namespace)
+{
+    AXIS2_FUNC_PARAM_CHECK(om_attribute, env, AXIS2_FAILURE);
+    if(!om_namespace)
+    {
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
+        return AXIS2_FAILURE;
+    }
+    AXIS2_INTF_TO_IMPL(om_attribute)->ns = om_namespace;
+    return AXIS2_SUCCESS;
+}                                 
\ No newline at end of file

Modified: webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_comment.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_comment.c?rev=331946&r1=331945&r2=331946&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_comment.c (original)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_comment.c Tue Nov  8 20:29:48 2005
@@ -15,91 +15,129 @@
  */
 
 #include <axis2_om_comment.h>
-#include <string.h>
+#include <axis2_string.h>
 
-axis2_status_t AXIS2_CALL axis2_om_comment_impl_free (axis2_env_t * environment,
-                                           axis2_om_comment_t * comment);
+axis2_status_t AXIS2_CALL
+axis2_om_comment_free (axis2_om_comment_t *om_comment,
+                       axis2_env_t **env);
+
+axis2_char_t* AXIS2_CALL
+axis2_om_comment_get_value(axis2_om_comment_t *om_comment,
+                           axis2_env_t **env);
+axis2_status_t AXIS2_CALL
+axis2_om_comment_set_value(axis2_om_comment_t *om_comment,
+                           axis2_env_t **env,
+                           const axis2_char_t *value);
+                                                                             
+/***************************** axis2_om_comment_struct ******************/
+
+typedef struct axis2_om_comment_impl_t
+{
+    axis2_om_comment_t om_comment;
+    /** comment text */
+    axis2_char_t *value;
+
+}axis2_om_comment_impl_t;
+/***************************** Macro **********************************/
+
+#define AXIS2_INTF_TO_IMPL(om_comment) ((axis2_om_comment_impl_t*)om_comment)
+
+
+/*************************** End Macro *******************************/
 
 AXIS2_DECLARE(axis2_om_comment_t*)
- axis2_om_comment_create (axis2_env_t * environment,
-                         const axis2_char_t * value, axis2_om_node_t ** node)
+axis2_om_comment_create(axis2_env_t **env,
+                        const axis2_char_t * value,
+                        axis2_om_node_t ** node)
 {
-    axis2_om_comment_t *comment = NULL;
+    axis2_om_comment_impl_t *comment = NULL;
     *node = NULL;
+    AXIS2_ENV_CHECK(env, NULL);
+    AXIS2_PARAM_CHECK((*env)->error, value, NULL);
+    AXIS2_PARAM_CHECK((*env)->error, node, NULL);
     
-    if (!node)
-    {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
-        return NULL;
-    }
-
-    *node = axis2_om_node_create (environment);
+    *node = axis2_om_node_create (env);
     if (!*node)
     {
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
-        return NULL;
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, NULL);
     }
-
-    comment =
-        (axis2_om_comment_t *) axis2_malloc (environment->allocator,
-                                             sizeof (axis2_om_comment_t));
+    
+    comment = (axis2_om_comment_impl_t *) AXIS2_MALLOC((*env)->allocator,
+                                             sizeof (axis2_om_comment_impl_t));
     if (!comment)
     {
-        axis2_om_node_free (environment, *node);
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
-        return NULL;
+        AXIS2_OM_NODE_FREE (*node, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, NULL);
     }
 
     comment->value = NULL;
 
     if (value)
     {
-        comment->value = axis2_strdup (environment->string, value);
+        comment->value = (axis2_char_t*)AXIS2_STRDUP(value,env);
         if (!comment->value)
         {
-            axis2_om_node_free (environment, *node);
-            axis2_free (environment->allocator, comment);
-            environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
-            return NULL;
+            AXIS2_FREE ((*env)->allocator,comment);
+            AXIS2_OM_NODE_FREE (*node, env);
+            AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, NULL);
         }
     }
 
-    (*node)->data_element = comment;
-    (*node)->node_type = AXIS2_OM_COMMENT;
+    AXIS2_OM_NODE_SET_DATA_ELEMENT((*node), env, comment);
+    AXIS2_OM_NODE_SET_NODE_TYPE((*node), env, AXIS2_OM_COMMENT);
 
     /* operations */
-    comment->ops = NULL;
-    comment->ops =
-        (axis2_om_comment_ops_t *) axis2_malloc (environment->allocator,
-                                                 sizeof
-                                                 (axis2_om_comment_ops_t));
-    if (!comment->ops)
-    {
-        axis2_om_node_free (environment, *node);
-        axis2_free (environment->allocator, comment);
-        axis2_free (environment->allocator, comment->value);
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
-        return NULL;
+    comment->om_comment.ops = NULL;
+    comment->om_comment.ops = (axis2_om_comment_ops_t *)AXIS2_MALLOC(
+                              (*env)->allocator,sizeof(axis2_om_comment_ops_t));
+    if (!comment->om_comment.ops)
+    {
+        AXIS2_FREE ((*env)->allocator, comment);
+        AXIS2_FREE ((*env)->allocator, comment->value);
+        AXIS2_FREE ((*env)->allocator,*node);
+        AXIS2_ERROR_SET((*env)->error,AXIS2_ERROR_NO_MEMORY, NULL);
     }
 
-    comment->ops->axis2_om_comment_ops_free = axis2_om_comment_impl_free;
-
-    return comment;
+    comment->om_comment.ops->free = axis2_om_comment_free;
+    comment->om_comment.ops->set_value = axis2_om_comment_set_value;
+    comment->om_comment.ops->get_value = axis2_om_comment_get_value;
+    return &(comment->om_comment);
 }
 
 
 axis2_status_t AXIS2_CALL
-axis2_om_comment_impl_free (axis2_env_t * environment,
-                            axis2_om_comment_t * comment)
+axis2_om_comment_free (axis2_om_comment_t *om_comment,
+                       axis2_env_t **env)
 {
-    if (comment)
+    AXIS2_FUNC_PARAM_CHECK(om_comment, env, AXIS2_FAILURE);
+    if (om_comment)
     {
-        if (comment->value)
+        if (AXIS2_INTF_TO_IMPL(om_comment)->value)
         {
-            axis2_free (environment->allocator, comment->value);
+            AXIS2_FREE ((*env)->allocator, AXIS2_INTF_TO_IMPL(om_comment)->value);
         }
-        axis2_free (environment->allocator, comment);
+        AXIS2_FREE((*env)->allocator,AXIS2_INTF_TO_IMPL(om_comment));
         return AXIS2_SUCCESS;
     }
     return AXIS2_FAILURE;
 }
+
+axis2_char_t* AXIS2_CALL
+axis2_om_comment_get_value(axis2_om_comment_t *om_comment,
+                           axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(om_comment, env, NULL);
+    return AXIS2_INTF_TO_IMPL(om_comment)->value;
+}   
+
+                        
+axis2_status_t AXIS2_CALL
+axis2_om_comment_set_value(axis2_om_comment_t *om_comment,
+                           axis2_env_t **env,
+                           const axis2_char_t *value)
+{
+    AXIS2_FUNC_PARAM_CHECK(om_comment, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, value, AXIS2_FAILURE);
+    AXIS2_INTF_TO_IMPL(om_comment)->value = (axis2_char_t*)AXIS2_STRDUP(value,env);
+    return AXIS2_SUCCESS;
+}                           
\ No newline at end of file

Modified: webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_doctype.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_doctype.c?rev=331946&r1=331945&r2=331946&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_doctype.c (original)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_doctype.c Tue Nov  8 20:29:48 2005
@@ -15,96 +15,136 @@
   */
 
 #include <axis2_om_doctype.h>
+#include <axis2_string.h>
 
-axis2_status_t AXIS2_CALL axis2_om_doctype_impl_free (axis2_env_t * environment,
-                                           axis2_om_doctype_t * doctype);
+axis2_status_t AXIS2_CALL
+axis2_om_doctype_free (axis2_om_doctype_t *om_doctype,
+                       axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL
+axis2_om_doctype_set_value(axis2_om_doctype_t *om_doctype,
+                           axis2_env_t **env,
+                           const axis2_char_t *value);
+
+axis2_char_t* AXIS2_CALL
+axis2_om_doctype_get_value(axis2_om_doctype_t *om_doctype,
+                           axis2_env_t **env);                                                  
+                       
+/************************ axis2_om_doctype struct *********************/
+
+typedef struct axis2_om_doctype_impl_t
+{
+    /* this should be first member for casting to work */
+    axis2_om_doctype_t om_doctype;
+    /** Doctype value */
+    axis2_char_t *value;
+    
+}axis2_om_doctype_impl_t;
+
+/*************************** Macro ***********************************/
+                       
+#define AXIS2_INTF_TO_IMPL(om_doctype) ((axis2_om_doctype_impl_t*)om_doctype)
+
+/********************************************************************/
 
 AXIS2_DECLARE(axis2_om_doctype_t *)
- axis2_om_doctype_create (axis2_env_t * environment,
-                         axis2_om_node_t * parent, const axis2_char_t * value,
+axis2_om_doctype_create (axis2_env_t **env,
+                         axis2_om_node_t * parent,
+                         const axis2_char_t * value,
                          axis2_om_node_t ** node)
 {
-    axis2_om_doctype_t *doctype = NULL;
-
-    if (!node)
-    {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
-        return NULL;
-    }
+    axis2_om_doctype_impl_t *doctype = NULL;
+    AXIS2_ENV_CHECK(env, NULL);
+    AXIS2_PARAM_CHECK((*env)->error,node,NULL);
 
-    *node = axis2_om_node_create (environment);
+    *node = axis2_om_node_create (env);
     if (!*node)
     {
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
-        return NULL;
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY,NULL);
     }
 
-    doctype =
-        (axis2_om_doctype_t *) axis2_malloc (environment->allocator,
-                                             sizeof (axis2_om_doctype_t));
+    doctype = (axis2_om_doctype_impl_t *) AXIS2_MALLOC ((*env)->allocator,
+                                             sizeof (axis2_om_doctype_impl_t));
+                                             
     if (!doctype)
     {
-        axis2_om_node_free (environment, *node);
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
-        return NULL;
+        AXIS2_OM_NODE_FREE ( *node, env);
+        AXIS2_ERROR_SET((*env)->error , AXIS2_ERROR_NO_MEMORY, NULL);
     }
 
     doctype->value = NULL;
 
     if (value)
     {
-        doctype->value = axis2_strdup (environment->string, value);
+        doctype->value =(axis2_char_t*)AXIS2_STRDUP(value,env);
         if (!doctype->value)
         {
-            axis2_om_node_free (environment, *node);
-            axis2_free (environment->allocator, doctype);
-            environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
-            return NULL;
+            AXIS2_FREE ((*env)->allocator, doctype);
+            AXIS2_OM_NODE_FREE (*node, env);
+            AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, NULL);
         }
     }
 
-    (*node)->data_element = doctype;
-    (*node)->node_type = AXIS2_OM_DOCTYPE;
+    AXIS2_OM_NODE_SET_DATA_ELEMENT((*node), env, doctype);
+    AXIS2_OM_NODE_SET_NODE_TYPE((*node), env, AXIS2_OM_DOCTYPE);
 
     if (parent)
     {
-        (*node)->parent = parent;
-        axis2_om_node_add_child (environment, parent, (*node));
+        AXIS2_OM_NODE_SET_PARENT((*node), env, parent);
+        AXIS2_OM_NODE_ADD_CHILD((*node), env, parent);
     }
 
     /* operations */
-    doctype->ops = NULL;
-    doctype->ops =
-        (axis2_om_doctype_ops_t *) axis2_malloc (environment->allocator,
-                                                 sizeof
-                                                 (axis2_om_doctype_ops_t));
-    if (!doctype->ops)
-    {
-        axis2_om_node_free (environment, *node);
-        axis2_free (environment->allocator, doctype);
-        axis2_free (environment->allocator, doctype->value);
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
-        return NULL;
+    doctype->om_doctype.ops = NULL;
+    doctype->om_doctype.ops = (axis2_om_doctype_ops_t *) AXIS2_MALLOC (
+                                (*env)->allocator,sizeof(axis2_om_doctype_ops_t));
+                                
+    if (!doctype->om_doctype.ops)
+    {
+        AXIS2_FREE((*env)->allocator, doctype);
+        AXIS2_FREE ((*env)->allocator, doctype->value);
+        AXIS2_OM_NODE_FREE( *node, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, NULL);
     }
 
-    doctype->ops->axis2_om_doctype_ops_free = axis2_om_doctype_impl_free;
+    doctype->om_doctype.ops->free = axis2_om_doctype_free;
 
-    return doctype;
+    return &(doctype->om_doctype);
 }
 
 
 axis2_status_t AXIS2_CALL
-axis2_om_doctype_impl_free (axis2_env_t * environment,
-                            axis2_om_doctype_t * doctype)
+axis2_om_doctype_free (axis2_om_doctype_t *om_doctype,
+                       axis2_env_t **env)
 {
-    if (doctype)
+    if (om_doctype)
     {
-        if (doctype->value)
+        if (AXIS2_INTF_TO_IMPL(om_doctype)->value)
         {
-            axis2_free (environment->allocator, doctype->value);
+            AXIS2_FREE ((*env)->allocator,AXIS2_INTF_TO_IMPL(om_doctype)->value);
         }
-        axis2_free (environment->allocator, doctype);
+        AXIS2_FREE ((*env)->allocator, AXIS2_INTF_TO_IMPL(om_doctype));
         return AXIS2_SUCCESS;
     }
     return AXIS2_FAILURE;
 }
+
+axis2_status_t AXIS2_CALL
+axis2_om_doctype_set_value(axis2_om_doctype_t *om_doctype,
+                           axis2_env_t **env,
+                           const axis2_char_t *value)
+{
+    AXIS2_FUNC_PARAM_CHECK(om_doctype, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, value, AXIS2_FAILURE);
+    AXIS2_INTF_TO_IMPL(om_doctype)->value = 
+        (axis2_char_t*)AXIS2_STRDUP(value,env);
+    return AXIS2_SUCCESS;
+}                           
+
+axis2_char_t* AXIS2_CALL
+axis2_om_doctype_get_value(axis2_om_doctype_t *om_doctype,
+                           axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(om_doctype, env, NULL);
+    return AXIS2_INTF_TO_IMPL(om_doctype)->value;
+}
\ No newline at end of file

Modified: webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_document.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_document.c?rev=331946&r1=331945&r2=331946&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_document.c (original)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_document.c Tue Nov  8 20:29:48 2005
@@ -17,285 +17,216 @@
 
 #include <axis2_om_document.h>
 #include <axis2_om_stax_builder.h>
+#include <axis2_string.h>
 
-axis2_status_t AXIS2_CALL axis2_om_document_impl_free (axis2_env_t * environment,
-                                            axis2_om_document_t * document);
-axis2_status_t AXIS2_CALL axis2_om_document_impl_add_child (axis2_env_t *
-                                                 environment,
-                                                 axis2_om_document_t *
-                                                 document,
-                                                 axis2_om_node_t * child);
-axis2_om_node_t * AXIS2_CALL axis2_om_document_impl_build_next (axis2_env_t *
-                                                    environment,
-                                                    axis2_om_document_t *
-                                                    document);
-axis2_om_node_t * AXIS2_CALL axis2_om_document_impl_get_root_element (axis2_env_t
-                                                          * environment,
-                                                          axis2_om_document_t
-                                                          * document);
-axis2_om_node_t * AXIS2_CALL axis2_om_document_impl_get_next_sibling (axis2_env_t
-                                                          * environment,
-                                                          axis2_om_document_t
-                                                          * document);
-axis2_om_node_t * AXIS2_CALL axis2_om_document_impl_get_first_child (axis2_env_t *
-                                                         environment,
-                                                         axis2_om_document_t *
-                                                         document);
-axis2_om_node_t * AXIS2_CALL axis2_om_document_impl_get_next_child (axis2_env_t *
-                                                        environment,
-                                                        axis2_om_document_t *
-                                                        document);
+axis2_status_t AXIS2_CALL 
+axis2_om_document_free (axis2_om_document_t * document,
+                        axis2_env_t **env);
+                        
+axis2_status_t AXIS2_CALL 
+axis2_om_document_add_child (axis2_om_document_t *document,
+                             axis2_env_t **env,
+                             axis2_om_node_t * child);
+                             
+axis2_om_node_t * AXIS2_CALL
+axis2_om_document_build_next (axis2_om_document_t *document,
+                              axis2_env_t **env);
+                              
+axis2_om_node_t * AXIS2_CALL 
+axis2_om_document_get_root_element (axis2_om_document_t *document,
+                                    axis2_env_t **env);
+                                   
+axis2_status_t  AXIS2_CALL
+axis2_om_document_set_root_element(axis2_om_document_t *document,
+                                   axis2_env_t **env,
+                                   axis2_om_node_t *node);                                
+                                  
+/********************************* end of function pointers ******************/
+
+typedef struct axis2_om_document_impl_t
+{
+    axis2_om_document_t om_document;
+    /** root element */
+    axis2_om_node_t *root_element;
+    /** last child */
+    axis2_om_node_t *last_child;
+    /** first child */
+    axis2_om_node_t *first_child;
+    /** done building the document */
+    axis2_bool_t done;
+    /** builder of the document */
+    struct axis2_om_stax_builder *builder;
+    /** char set encoding */        
+    axis2_char_t *char_set_encoding;
+    /** XML version */
+    axis2_char_t *xml_version;
+}axis2_om_document_impl_t;        
 
-AXIS2_DECLARE(axis2_om_document_t *)
-axis2_om_document_create (axis2_env_t * environment,
-                          axis2_om_node_t * root,
-                          axis2_om_stax_builder_t * builder)
-{
+/************************************ Macro ************************************/ 
+
+#define AXIS2_INTF_TO_IMPL(document) ((axis2_om_document_impl_t*)document)
 
-    axis2_om_document_t *document =
-        (axis2_om_document_t *) axis2_malloc (environment->allocator,
-                                              sizeof (axis2_om_document_t));
+/*******************************************************************************/
 
+AXIS2_DECLARE(axis2_om_document_t *)
+axis2_om_document_create (axis2_env_t **env,
+                          axis2_om_node_t *root,
+                          axis2_om_stax_builder_t *builder)
+{
+    axis2_om_document_impl_t *document = NULL;
+    
+    AXIS2_ENV_CHECK(env, NULL);
+
+    document = (axis2_om_document_impl_t *) AXIS2_MALLOC (
+                (*env)->allocator, sizeof (axis2_om_document_t));
+    
     if (!document)
-    {
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
-        return NULL;
-    }
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY,NULL); 
+
     document->builder = builder;
     document->root_element = root;
     document->first_child = NULL;
     document->last_child = NULL;
 
     document->char_set_encoding = NULL;
-    document->char_set_encoding =
-        (axis2_char_t *) axis2_strdup (environment->string,
-                                       CHAR_SET_ENCODING);
+    document->char_set_encoding = (axis2_char_t *) AXIS2_STRDUP(CHAR_SET_ENCODING,env);
 
     if (!document->char_set_encoding)
     {
-        axis2_free (environment->allocator, document);
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
-        return NULL;
+        AXIS2_FREE((*env)->allocator, document);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, NULL); 
     }
-
+    
     document->xml_version = NULL;
-    document->xml_version =
-        (axis2_char_t *) axis2_strdup (environment->string, XML_VERSION);
+    document->xml_version = (axis2_char_t *) AXIS2_STRDUP(XML_VERSION,env);
     if (!document->xml_version)
     {
-        axis2_free (environment->allocator, document);
-        axis2_free (environment->allocator, document->char_set_encoding);
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
-        return NULL;
+        AXIS2_FREE((*env)->allocator, document);
+        AXIS2_FREE((*env)->allocator, document->char_set_encoding);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, NULL);
     }
 
     document->done = AXIS2_FALSE;
 
     if (builder)
-    {
-        builder->document = document;
-    }
+        AXIS2_OM_STAX_BUILDER_SET_DOCUMENT (builder, env, &(document->om_document));
 
     /* operations */
-    document->ops = NULL;
-    document->ops =
-        (axis2_om_document_ops_t *) axis2_malloc (environment->allocator,
-                                                  sizeof
-                                                  (axis2_om_document_ops_t));
-
-    if (!document->ops)
-    {
-        axis2_free (environment->allocator, document);
-        axis2_free (environment->allocator, document->char_set_encoding);
-        axis2_free (environment->allocator, document->xml_version);
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
-        return NULL;
-    }
-
-    document->ops->axis2_om_document_ops_free = axis2_om_document_impl_free;
-    document->ops->axis2_om_document_ops_add_child =
-        axis2_om_document_impl_add_child;
-    document->ops->axis2_om_document_ops_build_next =
-        axis2_om_document_impl_build_next;
-    document->ops->axis2_om_document_ops_get_root_element =
-        axis2_om_document_impl_get_root_element;
-    document->ops->axis2_om_document_ops_get_next_sibling =
-        axis2_om_document_impl_get_next_sibling;
-    document->ops->axis2_om_document_ops_get_first_child =
-        axis2_om_document_impl_get_first_child;
-    document->ops->axis2_om_document_ops_get_next_child =
-        axis2_om_document_impl_get_next_child;
-    return document;
+    document->om_document.ops = NULL;
+    document->om_document.ops = (axis2_om_document_ops_t *) AXIS2_MALLOC ((*env)->allocator,
+                                                  sizeof(axis2_om_document_ops_t));
+
+    if (!document->om_document.ops)
+    {
+        AXIS2_FREE((*env)->allocator, document);
+        AXIS2_FREE((*env)->allocator, document->char_set_encoding);
+        AXIS2_FREE((*env)->allocator, document->xml_version);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, NULL);
+    }
+  
+    document->om_document.ops->free = axis2_om_document_free;
+    document->om_document.ops->add_child = axis2_om_document_add_child;
+    document->om_document.ops->build_next = axis2_om_document_build_next;
+    document->om_document.ops->get_root_element = axis2_om_document_get_root_element;
+    document->om_document.ops->set_root_element = axis2_om_document_set_root_element;
+    return &(document->om_document);
 }
 
-
 axis2_status_t AXIS2_CALL
-axis2_om_document_impl_free (axis2_env_t * environment,
-                             axis2_om_document_t * document)
+axis2_om_document_free (axis2_om_document_t *om_document,
+                        axis2_env_t **env)
 {
-    if (document)
-    {
-        if (document->char_set_encoding)
-            axis2_free (environment->allocator, document->char_set_encoding);
-        if (document->xml_version)
-            axis2_free (environment->allocator, document->xml_version);
-
-        (document->root_element)->ops->axis2_om_node_ops_free (environment,
-                                                               document->
-                                                               root_element);
+    axis2_om_document_impl_t *document = NULL;
+    AXIS2_FUNC_PARAM_CHECK(document, env, AXIS2_FAILURE);
+    document = AXIS2_INTF_TO_IMPL(om_document);
+    
+    if (document->char_set_encoding)
+        AXIS2_FREE((*env)->allocator, document->char_set_encoding);
+    if (document->xml_version)
+        AXIS2_FREE((*env)->allocator, document->xml_version);
+
+    AXIS2_OM_NODE_FREE(document->root_element, env);
+    
+    if(document->om_document.ops)
+        AXIS2_FREE((*env)->allocator, document->om_document.ops);
 
-        axis2_free (environment->allocator, document);
-    }
+    AXIS2_FREE((*env)->allocator, document);
     return AXIS2_SUCCESS;
 }
 
 
+
 axis2_status_t AXIS2_CALL
-axis2_om_document_impl_add_child (axis2_env_t * environment,
-                                  axis2_om_document_t * document,
-                                  axis2_om_node_t * child)
+axis2_om_document_add_child (axis2_om_document_t *document,
+                             axis2_env_t **env,
+                             axis2_om_node_t * child)
 {
-    if (!document || !child)
-    {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
-        return AXIS2_FAILURE;
-    }
+    AXIS2_FUNC_PARAM_CHECK(document, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error,child, AXIS2_FAILURE);
 
-    if (!(document->root_element) && child)
+    if (!(AXIS2_INTF_TO_IMPL(document)->root_element) && child)
     {
-        document->root_element = child;
+        AXIS2_INTF_TO_IMPL(document)->root_element = child;
         return AXIS2_SUCCESS;
-
     }
 
-    if (document->root_element && child)
+    if (AXIS2_INTF_TO_IMPL(document)->root_element && child)
     {
-        return axis2_om_node_add_child (environment, document->root_element,
-                                        child);
+        return AXIS2_OM_NODE_ADD_CHILD (AXIS2_INTF_TO_IMPL(document)->root_element,
+                                         env, child);
     }
-
     return AXIS2_FAILURE;
-
 }
 
 axis2_om_node_t* AXIS2_CALL
-axis2_om_document_impl_build_next (axis2_env_t * environment,
-                                   axis2_om_document_t * document)
+axis2_om_document_build_next (axis2_om_document_t *om_document,
+                                   axis2_env_t **env)
 {
-    if (!document)
-    {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
-        return NULL;
-    }
+    axis2_om_document_impl_t *document = NULL;
+    AXIS2_FUNC_PARAM_CHECK(document, env, NULL);
 
+    document = AXIS2_INTF_TO_IMPL(om_document);
+    
     if (!(document->root_element))
     {
-        return axis2_om_stax_builder_next (environment, document->builder);
+        return AXIS2_OM_STAX_BUILDER_NEXT (document->builder, env);
     }
-    else if (document->root_element->done)
+    else if (AXIS2_OM_NODE_GET_BUILD_STATUS(document->root_element, env))
         return NULL;            /* Nothing wrong but done with pulling */
 
-    return axis2_om_stax_builder_next (environment, document->builder);
+    return AXIS2_OM_STAX_BUILDER_NEXT (document->builder, env);
 }
 
 
 axis2_om_node_t * AXIS2_CALL
-axis2_om_document_impl_get_root_element (axis2_env_t * environment,
-                                         axis2_om_document_t * document)
+axis2_om_document_get_root_element (axis2_om_document_t * document,
+                                    axis2_env_t **env)
 {
-    axis2_status_t status = AXIS2_SUCCESS;
+   
     axis2_om_node_t *node = NULL;
-    if (document && document->root_element)
+    AXIS2_FUNC_PARAM_CHECK(document, env, NULL);
+    
+    if (AXIS2_INTF_TO_IMPL(document)->root_element)
     {
-        return document->root_element;
+        return AXIS2_INTF_TO_IMPL(document)->root_element;
     }
     else
     {
-        node =
-            (document)->ops->axis2_om_document_ops_build_next (environment,
-                                                               document);
-        if (document->root_element)
-            return document->root_element;
+        node = axis2_om_document_build_next(document, env);
+        if (AXIS2_INTF_TO_IMPL(document)->root_element)
+            return AXIS2_INTF_TO_IMPL(document)->root_element;
         else
-        {
-            if (status != AXIS2_SUCCESS)
-                environment->error->errorno = AXIS2_ERROR_INVALID_DOCUMENT_STATE_ROOT_NULL;
-            return NULL;
-        }
+            AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_INVALID_DOCUMENT_STATE_ROOT_NULL, NULL);
     }
 }
 
-axis2_om_node_t * AXIS2_CALL
-axis2_om_document_impl_get_next_sibling (axis2_env_t * environment,
-                                         axis2_om_document_t * document)
-{
-    axis2_om_node_t *lastchild = NULL;
-    axis2_om_node_t *current_node = NULL;
-    if (document && document->builder && document->builder->lastnode)
-    {
-        lastchild = document->builder->lastnode;
-        if (!(lastchild->parent))
-        {
-            return NULL;        /* if parent is null there can't be siblings */
-        }
-        while (!(lastchild->next_sibling) && !(lastchild->parent->done))
-            current_node = axis2_om_document_build_next (environment, document);
-        return lastchild->next_sibling;
-    }
-    return NULL;
-}
-
-axis2_om_node_t* AXIS2_CALL
-axis2_om_document_impl_get_first_child (axis2_env_t * environment,
-                                        axis2_om_document_t * document)
-{
-    axis2_om_node_t *current_child = NULL;
-    axis2_om_node_t *current_node = NULL;
-    axis2_status_t status = AXIS2_SUCCESS;
-    current_child = document->builder->lastnode;
-    if (current_child)
-    {
-        while (!(current_child->first_child) && !(current_child->done))
-        {
-            current_node = axis2_om_document_build_next (environment, document);
-        }
-
-        if (current_child->first_child)
-            return current_child->first_child;
-        else
-        {
-            if (status != AXIS2_SUCCESS)
-                environment->error->errorno = status;
-            return NULL;
-        }
-    }
-    return NULL;
-}
-
-axis2_om_node_t* AXIS2_CALL
-axis2_om_document_impl_get_next_child (axis2_env_t * environment,
-                                       axis2_om_document_t * document)
-{
-    axis2_om_node_t *current_child = NULL;
-    axis2_om_node_t *current_node = NULL;
-    axis2_status_t status = AXIS2_SUCCESS;
-    current_child = document->builder->lastnode;
-    if (current_child && current_child->parent->first_child)
-    {
-        current_node = axis2_om_document_build_next (environment, document);
-
-        if (current_child->last_child)
-            return current_child->last_child;
-        else
-        {
-            if (status != AXIS2_SUCCESS)
-                environment->error->errorno = status;
-            return NULL;
-        }
-    }
-    else
-    {
-        environment->error->errorno = AXIS2_ERROR_INVALID_ITERATOR_STATE;
-        return NULL;
-    }
-}
+axis2_status_t AXIS2_CALL
+axis2_om_document_set_root_element(axis2_om_document_t *document,
+                                   axis2_env_t **env,
+                                   axis2_om_node_t *node)
+{
+    AXIS2_FUNC_PARAM_CHECK(document, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, node, AXIS2_FAILURE);
+    AXIS2_INTF_TO_IMPL(document)->root_element = node;
+    return AXIS2_SUCCESS;
+}                                   
\ No newline at end of file

Modified: webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_element.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_element.c?rev=331946&r1=331945&r2=331946&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_element.c (original)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_element.c Tue Nov  8 20:29:48 2005
@@ -20,85 +20,132 @@
 
 
 axis2_om_namespace_t *AXIS2_CALL
-axis2_om_element_impl_find_namespace (axis2_env_t * environment,
-                                      axis2_om_node_t * node,
-                                      const axis2_char_t * uri,
-                                      const axis2_char_t * prefix);
+axis2_om_element_find_namespace(axis2_om_element_t *om_element,
+                                axis2_env_t **env,
+                                axis2_om_node_t *node,
+                                const axis2_char_t * uri,
+                                const axis2_char_t * prefix);
 
 axis2_status_t AXIS2_CALL
-axis2_om_element_impl_declare_namespace (axis2_env_t * environment,
-                                         axis2_om_node_t * node,
-                                         axis2_om_namespace_t * ns);
+axis2_om_element_declare_namespace (axis2_om_element_t *om_element,
+                                   axis2_env_t **env,
+                                   axis2_om_node_t * node,
+                                   axis2_om_namespace_t * ns);
 
 axis2_om_namespace_t *AXIS2_CALL
-axis2_om_element_impl_find_namespace_with_qname (axis2_env_t *
-                                                 environment,
-                                                 axis2_om_node_t * element,
-                                                 axis2_qname_t * qname);
+axis2_om_element_find_namespace_with_qname (axis2_om_element_t *om_element,
+                                            axis2_env_t **env,
+                                            axis2_om_node_t * node,
+                                            axis2_qname_t * qname);
 /*
-axis2_om_namespace_t *
-    AXIS2_CALL axis2_om_element_impl_find_declared_namespace (axis2_env_t *
-                                                    environment,
-                                                    struct axis2_om_element
-                                                    *element,
-                                                    const axis2_char_t * uri,
-                                                    const axis2_char_t *
-                                                    prefix);
+axis2_om_namespace_t *AXIS2_CALL
+axis2_om_element_find_declared_namespace (axis2_om_element_t *om_element,
+                                          axis2_env_t **env,
+                                          struct axis2_om_element *element,
+                                          const axis2_char_t *uri,
+                                          const axis2_char_t *prefix);
 */
 
 axis2_status_t AXIS2_CALL
-axis2_om_element_impl_add_attribute (axis2_env_t * environment,
-                                     struct axis2_om_element *element,
-                                     axis2_om_attribute_t * attribute);
+axis2_om_element_add_attribute (axis2_om_element_t *element,
+                                axis2_env_t **env,
+                                axis2_om_attribute_t *attribute);
 
 axis2_om_attribute_t *AXIS2_CALL
-axis2_om_element_impl_get_attribute (axis2_env_t * environment,
-                                     struct axis2_om_element *element,
-                                     axis2_qname_t * qname);
+axis2_om_element_get_attribute(axis2_om_element_t *element,
+                               axis2_env_t **env,
+                               axis2_qname_t * qname);
 
-axis2_status_t AXIS2_CALL axis2_om_element_impl_free (axis2_env_t *
-                                                      environment,
-                                                      struct axis2_om_element
-                                                      *element);
+axis2_status_t AXIS2_CALL
+axis2_om_element_free (axis2_om_element_t *element,                                     
+                       axis2_env_t **env);
 
 axis2_status_t AXIS2_CALL
-axis2_om_element_impl_serialize_start_part (axis2_env_t * environment,
-                                            axis2_om_element_t * element,
-                                            axis2_om_output_t * om_output);
+axis2_om_element_serialize_start_part(axis2_om_element_t * element,
+                                      axis2_env_t **env,
+                                      axis2_om_output_t *om_output);
 
 axis2_status_t AXIS2_CALL
-axis2_om_element_impl_serialize_end_part (axis2_env_t * environment,
-                                          axis2_om_element_t * element,
-                                          axis2_om_output_t * om_output);
+axis2_om_element_serialize_end_part (axis2_om_element_t * element,
+                                     axis2_env_t **env,
+                                     axis2_om_output_t * om_output);
+
+axis2_char_t* AXIS2_CALL
+axis2_om_element_get_localname(axis2_om_element_t *om_element,
+                               axis2_env_t **env);
 
+axis2_status_t AXIS2_CALL
+axis2_om_element_set_localname(axis2_om_element_t *om_element,
+                              axis2_env_t **env,
+                               const axis2_char_t *localname);
+        
+axis2_om_namespace_t *AXIS2_CALL
+axis2_om_element_get_namespace(axis2_om_element_t *om_element,
+                               axis2_env_t **env);
+                                                          
+axis2_status_t AXIS2_CALL 
+axis2_om_element_set_namespace(axis2_om_element_t *om_element,
+                               axis2_env_t **env,
+                               axis2_om_namespace_t *ns,
+                               axis2_om_node_t *node);                                                                                                                                                              
+                                                                                                                  
+                                     
+                                     
+                                          
+/************************** end function prototypes **********************/
+typedef struct axis2_om_element_impl
+{   
+    axis2_om_element_t om_element;
+    /** Element's namespace */
+    axis2_om_namespace_t *ns;
+    /** Element's local name */
+    axis2_char_t *localname;
+    /** List of attributes */
+    axis2_hash_t *attributes;
+    /** List of namespaces */
+    axis2_hash_t *namespaces;
+    
+}axis2_om_element_impl_t;
 
+/************************************Macro *****************************/
+
+
+#define AXIS2_INTF_TO_IMPL(om_element) ((axis2_om_element_impl_t*)om_element)
+#define AXIS2_IMPL_TO_INTF(element) &(element->om_element)
+
+/**********************************************************************/                                          
 AXIS2_DECLARE(axis2_om_element_t *)
-axis2_om_element_create (axis2_env_t * environment,
-                         axis2_om_node_t * parent,
-                         const axis2_char_t * localname,
-                         axis2_om_namespace_t * ns, axis2_om_node_t ** node)
-{
-    axis2_om_element_t *element;
+axis2_om_element_create (axis2_env_t **env,
+                         axis2_om_node_t *parent,
+                         const axis2_char_t *localname,
+                         axis2_om_namespace_t *ns,
+                         axis2_om_node_t **node)
+{
+    axis2_om_element_impl_t *element;
+    AXIS2_ENV_CHECK(env, NULL);
+    
     if (!localname || !node)
     {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return NULL;
     }
 
-    (*node) = axis2_om_node_create (environment);
+    (*node) = axis2_om_node_create (env);
     if (!(*node))
     {
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_NO_MEMORY);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return NULL;
     }
-    element =
-        (axis2_om_element_t *) axis2_malloc (environment->allocator,
-                                             sizeof (axis2_om_element_t));
+    element = (axis2_om_element_impl_t *) AXIS2_MALLOC ((*env)->allocator,
+                                             sizeof (axis2_om_element_impl_t));
 
     if (!element)
     {
-        axis2_om_node_free (environment, (*node));
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
+        AXIS2_OM_NODE_FREE ((*node), env);
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_NO_MEMORY);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return NULL;
     }
     element->ns = NULL;
@@ -106,110 +153,110 @@
     element->attributes = NULL;
     element->namespaces = NULL;
 
-    element->localname =
-        (char *) axis2_strdup (environment->string, localname);
+    element->localname = (axis2_char_t *) AXIS2_STRDUP(localname,env);
     if (!element->localname)
     {
-        axis2_free (environment->allocator, element);
-        axis2_om_node_free (environment, (*node));
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
+        AXIS2_FREE ((*env)->allocator, element);
+        AXIS2_OM_NODE_FREE ( (*node), env);
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_NO_MEMORY);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return NULL;
     }
 
-
     if (parent)
     {
-        (*node)->parent = parent;
-        axis2_om_node_add_child (environment, parent, (*node));
+        AXIS2_OM_NODE_SET_PARENT((*node), env, parent);
+        AXIS2_OM_NODE_ADD_CHILD((*node), env, parent);
     }
-
-    (*node)->done = AXIS2_FALSE;
-    (*node)->node_type = AXIS2_OM_ELEMENT;
-    (*node)->data_element = element;
+    
+    AXIS2_OM_NODE_SET_BUILD_STATUS((*node), env, AXIS2_FALSE);
+    AXIS2_OM_NODE_SET_NODE_TYPE((*node), env, AXIS2_OM_ELEMENT);
+    AXIS2_OM_NODE_SET_DATA_ELEMENT((*node), env, element);
 
     if (ns)
     {
         element->ns =
-            axis2_om_element_impl_find_namespace (environment, *node, ns->uri,
-                                                  ns->prefix);
+            axis2_om_element_find_namespace (AXIS2_IMPL_TO_INTF(element), env, *node,
+                                             AXIS2_OM_NAMESPACE_GET_URI(ns, env),
+                                             AXIS2_OM_NAMESPACE_GET_PREFIX(ns, env));
         if (!(element->ns))
         {
-            if (axis2_om_element_impl_declare_namespace
-                (environment, *node, ns) == AXIS2_SUCCESS)
+            if (axis2_om_element_declare_namespace(&(element->om_element), env, *node, ns) == AXIS2_SUCCESS)
                 element->ns = ns;
         }
     }
 
-    element->ops = NULL;
-    element->ops =
-        (axis2_om_element_ops_t *) axis2_malloc (environment->allocator,
-                                                 sizeof
-                                                 (axis2_om_element_ops_t));
-
-    if (!element->ops)
-    {
-        axis2_free (environment->allocator, element->localname);
-        axis2_free (environment->allocator, element);
-        axis2_om_node_free (environment, (*node));
-        environment->error->errorno = AXIS2_ERROR_NO_MEMORY;
+    element->om_element.ops = NULL;
+    element->om_element.ops = (axis2_om_element_ops_t *) AXIS2_MALLOC ((*env)->allocator,
+                                                       sizeof(axis2_om_element_ops_t));
+
+    if (!element->om_element.ops)
+    {
+        AXIS2_FREE ((*env)->allocator, element->localname);
+        AXIS2_FREE ((*env)->allocator, element);
+        AXIS2_OM_NODE_FREE ( (*node), env);
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_NO_MEMORY);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return NULL;
     }
 
-    /* operations */
-    element->ops->axis2_om_element_ops_find_namespace =
-        axis2_om_element_impl_find_namespace;
-    element->ops->axis2_om_element_ops_declare_namespace =
-        axis2_om_element_impl_declare_namespace;
-    element->ops->axis2_om_element_ops_find_namespace_with_qname =
-        axis2_om_element_impl_find_namespace_with_qname;
-    element->ops->axis2_om_element_ops_add_attribute =
-        axis2_om_element_impl_add_attribute;
-    element->ops->axis2_om_element_ops_get_attribute =
-        axis2_om_element_impl_get_attribute;
-    element->ops->axis2_om_element_ops_free = axis2_om_element_impl_free;
-    /*element->ops->axis2_om_element_ops_find_declared_namespace =
-       axis2_om_element_impl_find_declared_namespace; */
-    element->ops->axis2_om_element_ops_serialize_start_part =
-        axis2_om_element_impl_serialize_start_part;
-    element->ops->axis2_om_element_ops_serialize_end_part =
-        axis2_om_element_impl_serialize_end_part;
-
-    return element;
+    /* set function pointers */
+    element->om_element.ops->find_namespace = 
+        axis2_om_element_find_namespace;
+    element->om_element.ops->declare_namespace =
+        axis2_om_element_declare_namespace;
+    element->om_element.ops->find_namespace_with_qname =
+        axis2_om_element_find_namespace_with_qname;
+    element->om_element.ops->add_attribute =
+        axis2_om_element_add_attribute;
+    element->om_element.ops->get_attribute =
+        axis2_om_element_get_attribute;
+    element->om_element.ops->free = axis2_om_element_free;
+    
+    element->om_element.ops->serialize_start_part =
+        axis2_om_element_serialize_start_part;
+    element->om_element.ops->serialize_end_part =
+        axis2_om_element_serialize_end_part;
+    
+    return &(element->om_element);
 
 }
 
 AXIS2_DECLARE(axis2_om_element_t *)
-axis2_om_element_create_with_qname (axis2_env_t * environment,
-                                    axis2_om_node_t * parent,
-                                    axis2_qname_t * qname,
+axis2_om_element_create_with_qname (axis2_env_t **env,
+                                    axis2_om_node_t *parent,
+                                    axis2_qname_t *qname,
                                     axis2_om_node_t ** node)
 {
     axis2_om_element_t *element = NULL;
-
+    AXIS2_ENV_CHECK(env, NULL);
     if (!qname || !(*node))
     {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
-        return NULL;            /* can't create an element */
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
+        return NULL;           
     }
 
     /* TODO:handle namespace in the following */
-    element =
-        axis2_om_element_create (environment, parent, qname->localpart, NULL,
-                                 node);
+    element = axis2_om_element_create (env, parent,
+              AXIS2_QNAME_GET_LOCALPART(qname, env), NULL, node);
     if (*node)
     {
-        if (((axis2_om_element_t *) ((*node)->data_element))->ns)
+        axis2_om_element_t *ele = 
+            ((axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT((*node), env));
+        if ( AXIS2_INTF_TO_IMPL(ele)->ns)
         {
-            axis2_om_namespace_t *ns =
-                ((axis2_om_element_t *) ((*node)->data_element))->ns;
-            element->ns =
-                axis2_om_element_impl_find_namespace (environment, *node,
-                                                      ns->uri, ns->prefix);
-            if (!(element->ns))
+            axis2_om_namespace_t *ns = AXIS2_INTF_TO_IMPL(ele)->ns;
+                
+            AXIS2_INTF_TO_IMPL(element)->ns = 
+                axis2_om_element_find_namespace (element, env, *node,
+                                                 AXIS2_OM_NAMESPACE_GET_URI(ns, env),
+                                                 AXIS2_OM_NAMESPACE_GET_PREFIX(ns, env));
+                                                 
+            if (!(AXIS2_INTF_TO_IMPL(element)->ns))
             {
-                if (axis2_om_element_impl_declare_namespace
-                    (environment, *node, ns) == AXIS2_SUCCESS)
-                    element->ns = ns;
+                if (axis2_om_element_declare_namespace(element, env, *node, ns) == AXIS2_SUCCESS)
+                    (AXIS2_INTF_TO_IMPL(element)->ns) = ns;
             }
         }
     }
@@ -218,79 +265,89 @@
 }
 
 axis2_om_namespace_t * AXIS2_CALL
-axis2_om_element_impl_find_namespace (axis2_env_t * environment,
-                                      axis2_om_node_t * node,
-                                      const axis2_char_t * uri,
-                                      const axis2_char_t * prefix)
+axis2_om_element_find_namespace (axis2_om_element_t *ele,
+                                 axis2_env_t **env,
+                                 axis2_om_node_t * node,
+                                 const axis2_char_t * uri,
+                                 const axis2_char_t * prefix)
 {
     void *ns = NULL;
     axis2_hash_index_t *hashindex;
     axis2_om_element_t *element = NULL;
-
+    axis2_om_node_t *parent = NULL;
+    AXIS2_ENV_CHECK(env, NULL);
+    
     if (!node)
     {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return NULL;
     }
-    if (!(node->data_element) || node->node_type != AXIS2_OM_ELEMENT)
+    if (!AXIS2_OM_NODE_GET_DATA_ELEMENT(node, env) || 
+            AXIS2_OM_NODE_GET_NODE_TYPE(node, env) != AXIS2_OM_ELEMENT)
     {
         /* wrong element type or null node */
-        environment->error->errorno = AXIS2_ERROR_INVALID_NODE_TYPE;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NODE_TYPE);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return NULL;
     }
 
-    element = (axis2_om_element_t *) (node->data_element);
-    if (!prefix || axis2_strcmp (environment->string, prefix, "") == 0)
+    element = (axis2_om_element_t *) AXIS2_OM_NODE_GET_DATA_ELEMENT(node, env);
+    if (!prefix || axis2_strcmp ( prefix, "") == 0)
     {
-        for (hashindex = axis2_hash_first (environment, element->namespaces);
-             hashindex; hashindex = axis2_hash_next (environment, hashindex))
+        for (hashindex = axis2_hash_first (AXIS2_INTF_TO_IMPL(element)->namespaces, env);
+             hashindex; hashindex = axis2_hash_next (env, hashindex))
         {
             axis2_hash_this (hashindex, NULL, NULL, &ns);
-            if (ns
-                && axis2_strcmp (environment->string,
-                                 ((axis2_om_namespace_t *) (ns))->uri,
-                                 uri) == 0)
+            if (ns && 
+                axis2_strcmp (AXIS2_OM_NAMESPACE_GET_URI(
+                    (axis2_om_namespace_t *) (ns), env),uri) == 0)
             {
                 return (axis2_om_namespace_t *) (ns);
             }
         }
     }
 
-    if (element->namespaces)
-        ns = axis2_hash_get (element->namespaces, prefix,
+    if (AXIS2_INTF_TO_IMPL(element)->namespaces)
+        ns = axis2_hash_get (AXIS2_INTF_TO_IMPL(element)->namespaces, prefix,
                              AXIS2_HASH_KEY_STRING);
+    
+    parent = AXIS2_OM_NODE_GET_PARENT(node, env);                       
 
     if (ns)
     {
-        return ns;
+        return (axis2_om_namespace_t*)ns;
     }
-    else if ((node->parent != NULL) &&
-             (node->parent->node_type == AXIS2_OM_ELEMENT))
+    else if ((parent != NULL) &&
+             (AXIS2_OM_NODE_GET_NODE_TYPE(parent, env) == AXIS2_OM_ELEMENT))
     {
-        return axis2_om_element_impl_find_namespace (environment,
-                                                     node->parent, uri,
-                                                     prefix);
+        return axis2_om_element_find_namespace (
+                (axis2_om_element_t*)AXIS2_OM_NODE_GET_DATA_ELEMENT(node, env),
+                    env, parent, uri, prefix);
     }
 
     return NULL;
 }
 
 axis2_status_t AXIS2_CALL
-axis2_om_element_impl_declare_namespace (axis2_env_t * environment,
-                                         axis2_om_node_t * node,
-                                         axis2_om_namespace_t * ns)
+axis2_om_element_declare_namespace (axis2_om_element_t *ele,
+                                    axis2_env_t **env,
+                                    axis2_om_node_t *node,
+                                    axis2_om_namespace_t *ns)
 {
     axis2_om_namespace_t *declared_ns = NULL;
     axis2_om_element_t *element = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     if (!node || !ns)
     {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
 
-    declared_ns =
-        axis2_om_element_impl_find_namespace (environment, node, ns->uri,
-                                              ns->prefix);
+    declared_ns = axis2_om_element_find_namespace(ele, env, node, 
+                                              AXIS2_OM_NAMESPACE_GET_URI(ns, env),
+                                              AXIS2_OM_NAMESPACE_GET_PREFIX(ns ,env));
 
     if (declared_ns)
     {
@@ -298,27 +355,29 @@
         return AXIS2_SUCCESS;
     }
 
-    element = (axis2_om_element_t *) (node->data_element);
+    element = (axis2_om_element_t *) AXIS2_OM_NODE_GET_DATA_ELEMENT(node, env);
 
     if (!element)
     {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE); 
         return AXIS2_FAILURE;
     }
 
-    if (!(element->namespaces))
+    if (!(AXIS2_INTF_TO_IMPL(element)->namespaces))
     {
-        element->namespaces = axis2_hash_make (environment);
-        if (!(element->namespaces))
+        AXIS2_INTF_TO_IMPL(element)->namespaces = axis2_hash_make (env);
+        if (!(AXIS2_INTF_TO_IMPL(element)->namespaces))
             return AXIS2_FAILURE;
     }
 
-    if (ns->prefix)
-        axis2_hash_set (element->namespaces, ns->prefix,
+    if (AXIS2_OM_NAMESPACE_GET_PREFIX(ns,env))
+        axis2_hash_set (AXIS2_INTF_TO_IMPL(element)->namespaces,
+                        AXIS2_OM_NAMESPACE_GET_PREFIX(ns,env),
                         AXIS2_HASH_KEY_STRING, ns);
     else
-        axis2_hash_set (element->namespaces, "default", AXIS2_HASH_KEY_STRING,
-                        ns);
+        axis2_hash_set (AXIS2_INTF_TO_IMPL(element)->namespaces,
+                        "default",  AXIS2_HASH_KEY_STRING,  ns);
 
     return AXIS2_SUCCESS;
 }
@@ -363,22 +422,26 @@
 */
 
 axis2_om_namespace_t * AXIS2_CALL
-axis2_om_element_impl_find_namespace_with_qname (axis2_env_t *
-                                                 environment,
-                                                 axis2_om_node_t * element,
-                                                 axis2_qname_t * qname)
+axis2_om_element_find_namespace_with_qname (axis2_om_element_t *element,
+                                            axis2_env_t **env,
+                                            axis2_om_node_t *node,
+                                            axis2_qname_t *qname)
 {
-    if (!element || !qname)
+    AXIS2_ENV_CHECK(env, NULL);
+   
+    if (!node || !qname)
     {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, 
+                                     AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return NULL;
     }
 
-    if (qname->namespace_uri)
+    if (AXIS2_QNAME_GET_URI(qname, env))
     {
-        return axis2_om_element_impl_find_namespace (environment, element,
-                                                     qname->namespace_uri,
-                                                     qname->prefix);
+        return axis2_om_element_find_namespace (element, env, node,
+                                                AXIS2_QNAME_GET_URI(qname, env),
+                                                AXIS2_QNAME_GET_PREFIX(qname, env));
     }
     else
     {
@@ -387,84 +450,86 @@
 }
 
 axis2_status_t AXIS2_CALL
-axis2_om_element_impl_add_attribute (axis2_env_t * environment,
-                                     struct axis2_om_element * element,
-                                     axis2_om_attribute_t * attribute)
+axis2_om_element_add_attribute (axis2_om_element_t *om_element,
+                                axis2_env_t **env,
+                                axis2_om_attribute_t *attribute)
 {
     axis2_qname_t *qname = NULL;
-
-    if (!element || !attribute)
+    AXIS2_FUNC_PARAM_CHECK(om_element, env, AXIS2_FAILURE);
+    if (!attribute)
     {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, 
+                                     AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
 
-    if (!(element->attributes))
+    if (!(AXIS2_INTF_TO_IMPL(om_element)->attributes))
     {
-        element->attributes = axis2_hash_make (environment);
-        if (!(element->attributes))
+        AXIS2_INTF_TO_IMPL(om_element)->attributes = axis2_hash_make (env);
+        if (!(AXIS2_INTF_TO_IMPL(om_element)->attributes))
             return AXIS2_FAILURE;
     }
 
-    qname = axis2_om_attribute_get_qname (environment, attribute);
+    qname = AXIS2_OM_ATTRIBUTE_GET_QNAME(attribute, env);
     if (qname)
-        axis2_hash_set (element->attributes, qname, sizeof (axis2_qname_t),
+        axis2_hash_set (AXIS2_INTF_TO_IMPL(om_element)->attributes, 
+                        qname, sizeof (axis2_qname_t),
                         attribute);
 
     return ((qname) ? AXIS2_SUCCESS : AXIS2_FAILURE);
 }
 
 axis2_om_attribute_t * AXIS2_CALL
-axis2_om_element_impl_get_attribute (axis2_env_t * environment,
-                                     struct axis2_om_element * element,
-                                     axis2_qname_t * qname)
+axis2_om_element_get_attribute (axis2_om_element_t *om_element,
+                                axis2_env_t **env,
+                                axis2_qname_t *qname)
 {
-    if (!element || !qname)
+    AXIS2_FUNC_PARAM_CHECK(om_element, env, NULL);
+    
+    if (!qname)
     {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error, 
+                                     AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);
         return NULL;
     }
 
-    return (axis2_om_attribute_t
-            *) (axis2_hash_get (element->attributes, qname,
+    return (axis2_om_attribute_t*)
+                (axis2_hash_get(AXIS2_INTF_TO_IMPL(om_element)->attributes, qname,
                                 sizeof (axis2_qname_t)));
 }
 
 axis2_status_t AXIS2_CALL
-axis2_om_element_impl_free (axis2_env_t * environment,
-                            struct axis2_om_element *element)
+axis2_om_element_free (axis2_om_element_t *om_element,
+                       axis2_env_t **env)
 {
     axis2_status_t status = AXIS2_SUCCESS;
-
-    if (!element)
+    AXIS2_FUNC_PARAM_CHECK(om_element, env, AXIS2_FAILURE);
+    
+    if (om_element)
     {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
-        return AXIS2_FAILURE;
-    }
-
-    if (element)
-    {
-        if (element->localname)
+        if (AXIS2_INTF_TO_IMPL(om_element)->localname)
         {
-            axis2_free (environment->allocator, element->localname);
+            AXIS2_FREE ((*env)->allocator,AXIS2_INTF_TO_IMPL(om_element)->localname);
         }
-        if (element->ns)
+        if (AXIS2_INTF_TO_IMPL(om_element)->ns)
         {
             /* it is the responsibility of the element where the namespace is declared to free it */
         }
-        if (element->attributes)
+        if (AXIS2_INTF_TO_IMPL(om_element)->attributes)
         {
-            axis2_hash_free (environment, element->attributes);
+            axis2_hash_free (AXIS2_INTF_TO_IMPL(om_element)->attributes, env);
 
             /* TODO: free attributes */
             /*need to iterate and free individual attributes */
         }
-        if (element->namespaces)
+        if (AXIS2_INTF_TO_IMPL(om_element)->namespaces)
         {
             axis2_hash_index_t *hi;
             void *val = NULL;
-            for (hi = axis2_hash_first (environment, element->namespaces); hi;
-                 hi = axis2_hash_next (environment, hi))
+            for (hi = axis2_hash_first (AXIS2_INTF_TO_IMPL(om_element)->namespaces, env); hi;
+                 hi = axis2_hash_next ( env, hi))
             {
             /*   axis2_hash_this (hi, NULL, NULL, &val);
 
@@ -475,60 +540,70 @@
                    status = AXIS2_FAILURE;
                    }
                    val = NULL;
-              */   
+                */
             }
-            axis2_hash_free (environment, element->namespaces);
+            axis2_hash_free (AXIS2_INTF_TO_IMPL(om_element)->namespaces, env);
             /*TODO: free namespaces */
-            /*need to eterate and free individual namespaces */
+           /* need to iterate and free individual namespaces */
         }
-        axis2_free (environment->allocator, element->ops);
-        axis2_free (environment->allocator, element);
+        AXIS2_FREE ((*env)->allocator, om_element->ops);
+        AXIS2_FREE ((*env)->allocator, AXIS2_INTF_TO_IMPL(om_element));
     }
     return status;
 }
 
 axis2_status_t AXIS2_CALL
-axis2_om_element_impl_serialize_start_part (axis2_env_t * environment,
-                                            axis2_om_element_t * element,
-                                            axis2_om_output_t * om_output)
+axis2_om_element_serialize_start_part (axis2_om_element_t *om_element,
+                                       axis2_env_t **env,
+                                       axis2_om_output_t *om_output)
 {
     int status = AXIS2_SUCCESS;
-    if (!element || !om_output)
+    axis2_om_element_impl_t *ele_impl = NULL;
+    AXIS2_FUNC_PARAM_CHECK(om_element, env, AXIS2_FAILURE);
+    if (!om_output)
     {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error,
+                                     AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error, AXIS2_FAILURE);                                     
         return AXIS2_FAILURE;
     }
-
-
-    if (element->ns && element->ns->uri && element->ns->prefix)
-        status =
-            axis2_om_output_write (environment, om_output, AXIS2_OM_ELEMENT,
-                                   3, element->localname, element->ns->uri,
-                                   element->ns->prefix);
-    else if (element->ns && element->ns->uri)
-        status =
-            axis2_om_output_write (environment, om_output, AXIS2_OM_ELEMENT,
-                                   2, element->localname, element->ns->uri);
+    ele_impl = AXIS2_INTF_TO_IMPL(om_element);
+    
+    if (ele_impl->ns &&
+        AXIS2_OM_NAMESPACE_GET_URI(ele_impl->ns, env) &&
+        AXIS2_OM_NAMESPACE_GET_PREFIX(ele_impl->ns, env))
+    {
+        status = axis2_om_output_write (om_output, env,
+                                        AXIS2_OM_ELEMENT, 3,
+                                        ele_impl->localname, 
+                                        AXIS2_OM_NAMESPACE_GET_URI(ele_impl->ns, env),
+                                        AXIS2_OM_NAMESPACE_GET_PREFIX(ele_impl->ns, env));
+    }                                   
+    else if (ele_impl->ns && AXIS2_OM_NAMESPACE_GET_URI(ele_impl->ns, env))
+    {    status = 
+            axis2_om_output_write (om_output, env,
+                                AXIS2_OM_ELEMENT, 2,
+                                ele_impl->localname,
+                                AXIS2_OM_NAMESPACE_GET_URI(ele_impl->ns, env));
+    }                                   
     else
-        status =
-            axis2_om_output_write (environment, om_output, AXIS2_OM_ELEMENT,
-                                   1, element->localname);
+    {    status = axis2_om_output_write (om_output, env,
+                                    AXIS2_OM_ELEMENT, 1, ele_impl->localname);
 
-    /* serialize attributes */
-    if (element->attributes)
+    }
+    if (ele_impl->attributes)
     {
         axis2_hash_index_t *hi;
         void *val;
-        for (hi = axis2_hash_first (environment, element->attributes); hi;
-             hi = axis2_hash_next (environment, hi))
+        for (hi = axis2_hash_first (ele_impl->attributes, env); hi;
+             hi = axis2_hash_next (env, hi))
         {
             axis2_hash_this (hi, NULL, NULL, &val);
 
             if (val)
                 status =
-                    axis2_om_attribute_serialize (environment,
-                                                  (axis2_om_attribute_t *)
-                                                  val, om_output);
+                    AXIS2_OM_ATTRIBUTE_SERIALIZE ((axis2_om_attribute_t *)val,
+                                                  env, om_output);
             else
             {
                 status = AXIS2_FAILURE;
@@ -536,21 +611,20 @@
         }
     }
 
-    /* serialize namespaces */
-    if (element->namespaces)
+    
+    if (ele_impl->namespaces)
     {
         axis2_hash_index_t *hi;
         void *val;
-        for (hi = axis2_hash_first (environment, element->namespaces); hi;
-             hi = axis2_hash_next (environment, hi))
+        for (hi = axis2_hash_first ( ele_impl->namespaces, env); hi;
+             hi = axis2_hash_next (env, hi))
         {
             axis2_hash_this (hi, NULL, NULL, &val);
 
             if (val)
-                status =
-                    axis2_om_namespace_serialize (environment,
-                                                  (axis2_om_namespace_t *)
-                                                  val, om_output);
+                status = 
+                    AXIS2_OM_NAMESPACE_SERIALIZE((axis2_om_namespace_t *)val,
+                                                  env, om_output);
             else
             {
                 status = AXIS2_FAILURE;
@@ -562,19 +636,70 @@
 }
 
 axis2_status_t AXIS2_CALL
-axis2_om_element_impl_serialize_end_part (axis2_env_t * environment,
-                                          axis2_om_element_t * element,
-                                          axis2_om_output_t * om_output)
+axis2_om_element_serialize_end_part (axis2_om_element_t *om_element,
+                                     axis2_env_t **env,
+                                     axis2_om_output_t * om_output)
 {
     int status = AXIS2_SUCCESS;
 
     if (!om_output)
     {
-        environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAM;
+        AXIS2_ERROR_SET_ERROR_NUMBER((*env)->error ,
+                                     AXIS2_ERROR_INVALID_NULL_PARAM);
+        AXIS2_ERROR_SET_STATUS_CODE((*env)->error , AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
 
     status =
-        axis2_om_output_write (environment, om_output, AXIS2_OM_ELEMENT, 0);
+        axis2_om_output_write (om_output, env, AXIS2_OM_ELEMENT, 0);
     return status;
 }
+
+
+axis2_char_t* AXIS2_CALL
+axis2_om_element_get_localname(axis2_om_element_t *om_element,
+                               axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(om_element, env, NULL);
+    return AXIS2_INTF_TO_IMPL(om_element)->localname;
+}                               
+
+axis2_status_t AXIS2_CALL
+axis2_om_element_set_localname(axis2_om_element_t *om_element,
+                               axis2_env_t **env,
+                               const axis2_char_t *localname)
+{
+    AXIS2_FUNC_PARAM_CHECK(om_element, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, localname, AXIS2_FAILURE);
+    AXIS2_INTF_TO_IMPL(om_element)->localname = 
+        (axis2_char_t*)AXIS2_STRDUP(localname,env);
+    return AXIS2_SUCCESS;        
+}                               
+        
+axis2_om_namespace_t *AXIS2_CALL
+axis2_om_element_get_namespace(axis2_om_element_t *om_element,
+                               axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(om_element, env, NULL);
+    return AXIS2_INTF_TO_IMPL(om_element)->ns;
+}                               
+                                                          
+axis2_status_t AXIS2_CALL 
+axis2_om_element_set_namespace(axis2_om_element_t *om_element,
+                               axis2_env_t **env,
+                               axis2_om_namespace_t *ns,
+                               axis2_om_node_t *node)
+{
+    axis2_om_namespace_t *om_ns = NULL;
+    axis2_status_t status;
+    AXIS2_FUNC_PARAM_CHECK(om_element, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error,ns , AXIS2_FAILURE);
+    om_ns = axis2_om_element_find_namespace(om_element,env,node,
+                                AXIS2_OM_NAMESPACE_GET_URI(ns, env),
+                                AXIS2_OM_NAMESPACE_GET_PREFIX(ns , env));
+    if(om_ns == NULL)
+        status = axis2_om_element_declare_namespace(om_element, env, node, ns);
+    if(status = AXIS2_SUCCESS)
+        AXIS2_INTF_TO_IMPL(om_element)->ns = om_ns;
+    return AXIS2_SUCCESS;                                
+}                               
\ No newline at end of file



Mime
View raw message