Author: nandika
Date: Mon May 15 03:30:34 2006
New Revision: 406606

URL: http://svn.apache.org/viewcvs?rev=406606&view=rev
Log:
AXIS2_OM_ELEMENT_EXTRACT_ATTRIBUTES function added

Modified:
    webservices/axis2/trunk/c/include/axis2_om_element.h
    webservices/axis2/trunk/c/modules/xml/attachments/mime_output.c
    webservices/axis2/trunk/c/modules/xml/om/om_element.c

Modified: webservices/axis2/trunk/c/include/axis2_om_element.h
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_om_element.h?rev=406606&r1=406605&r2=406606&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_om_element.h (original)
+++ webservices/axis2/trunk/c/include/axis2_om_element.h Mon May 15 03:30:34 
2006
@@ -429,7 +429,16 @@
          set_namespace_with_no_find_in_current_scope)(
                         axis2_om_element_t *om_element,
                         axis2_env_t **env,
-                        axis2_om_namespace_t *om_ns);                          
      
+                        axis2_om_namespace_t *om_ns); 
+                        
+        /**
+         *  Extract attributes , returns a clones hash table of attributes,
+         *  if attributes are associated with a namespace it is also cloned
+         */                                                       
+         axis2_hash_t* (AXIS2_CALL *
+         extract_attributes)(axis2_om_element_t *om_element,
+                             axis2_env_t **env,
+                             axis2_om_node_t *ele_node);
     
     };
 
@@ -584,7 +593,8 @@
 #define 
AXIS2_OM_ELEMENT_SET_NAMESPACE_WITH_NO_FIND_IN_CURRENT_SCOPE(om_element, env, 
om_ns) \
         
((om_element)->ops->set_namespace_with_no_find_in_current_scope(om_element, 
env, om_ns))
                
-                                       
+#define AXIS2_OM_ELEMENT_EXTRACT_ATTRIBUTES(om_element, env, ele_node) \
+        ((om_element)->ops->extract_attributes(om_element, env, ele_node))     
                                  
 /** @} */
 
 

Modified: webservices/axis2/trunk/c/modules/xml/attachments/mime_output.c
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/attachments/mime_output.c?rev=406606&r1=406605&r2=406606&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/attachments/mime_output.c (original)
+++ webservices/axis2/trunk/c/modules/xml/attachments/mime_output.c Mon May 15 
03:30:34 2006
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
  
-#include <axis2_mime_output.h>
-#include <axis2_data_handler.h>
-#include <axis2_mime_body_part.h>
+#include "axis2_mime_output.h"
+#include "axis2_data_handler.h"
+#include "axis2_mime_body_part.h"
 #include <axis2_string.h>
 #include <axis2_om_text.h>
 

Modified: webservices/axis2/trunk/c/modules/xml/om/om_element.c
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/om_element.c?rev=406606&r1=406605&r2=406606&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/om_element.c (original)
+++ webservices/axis2/trunk/c/modules/xml/om/om_element.c Mon May 15 03:30:34 
2006
@@ -198,6 +198,12 @@
                                     axis2_om_element_t *om_element,
                                     axis2_env_t **env,
                                     axis2_om_namespace_t  *om_ns);
+                                    
+axis2_hash_t* AXIS2_CALL
+axis2_om_element_extract_attributes(axis2_om_element_t *om_element,
+                                    axis2_env_t **env,
+                                    axis2_om_node_t *ele_node);
+                                        
                                                                
                                          
 /************************** end function prototypes **********************/
@@ -410,7 +416,10 @@
         axis2_om_element_build;
         
     element->om_element.ops->set_namespace_with_no_find_in_current_scope =
-        axis2_om_element_set_namespace_with_no_find_in_current_scope;        
+        axis2_om_element_set_namespace_with_no_find_in_current_scope;
+        
+    element->om_element.ops->extract_attributes =
+        axis2_om_element_extract_attributes;                
 
     return &(element->om_element);
 }
@@ -1654,3 +1663,63 @@
     om_ele_impl->ns = om_ns;
     return AXIS2_SUCCESS;
 }                                    
+
+axis2_hash_t* AXIS2_CALL
+axis2_om_element_extract_attributes(axis2_om_element_t *om_element,
+                                    axis2_env_t **env,
+                                    axis2_om_node_t *ele_node)
+{
+    axis2_om_element_impl_t *om_ele_impl = NULL;
+    axis2_hash_index_t *hi = NULL;
+    axis2_hash_t *ht_cloned = NULL;
+    
+    axis2_om_attribute_t *om_attr = NULL;
+    axis2_om_attribute_t *cloned_attr = NULL;
+    
+    axis2_om_namespace_t *om_ns = NULL;
+    axis2_om_namespace_t *cloned_ns = NULL;
+    
+    axis2_char_t *key = NULL;
+    axis2_qname_t *qn = NULL;
+    
+    AXIS2_PARAM_CHECK((*env)->error, ele_node, NULL);
+    om_ele_impl = AXIS2_INTF_TO_IMPL(om_element);
+    if(!om_ele_impl->attributes)
+        return NULL;
+    ht_cloned = axis2_hash_make(env);
+    if(!ht_cloned)
+    {
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+    }        
+    
+    for(hi = axis2_hash_first(om_ele_impl->attributes, env);
+        hi; axis2_hash_next(env, hi))
+    {
+        void *val = NULL;
+        axis2_hash_this(hi, NULL, NULL, &val);
+        if(NULL != val)
+        {
+            om_attr = (axis2_om_attribute_t *)val;
+            cloned_attr = AXIS2_OM_ATTRIBUTE_CLONE(om_attr, env);
+            
+            om_ns = AXIS2_OM_ATTRIBUTE_GET_NAMESPACE(om_attr, env);
+            if(NULL != om_ns)
+            {
+                cloned_ns = AXIS2_OM_NAMESPACE_CLONE(om_ns, env);
+                AXIS2_OM_ATTRIBUTE_SET_NAMESPACE(cloned_attr, env, cloned_ns);
+            }
+            qn = AXIS2_OM_ATTRIBUTE_GET_QNAME(cloned_attr, env);
+            key = AXIS2_QNAME_TO_STRING(qn, env);
+            axis2_hash_set(ht_cloned, key, AXIS2_HASH_KEY_STRING, cloned_attr);
+        }
+        val = NULL;
+        key = NULL;
+        qn  = NULL;
+        om_attr = NULL;
+        cloned_attr = NULL;
+        om_ns = NULL;
+        cloned_ns = NULL;
+    }        
+    return ht_cloned;
+}                                    
\ No newline at end of file


Reply via email to