axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r306514 - in /webservices/axis2/trunk/c: include/ modules/test/om/src/ modules/xml/guththila/src/ modules/xml/om/src/
Date Thu, 06 Oct 2005 03:30:19 GMT
Author: samisa
Date: Wed Oct  5 20:30:06 2005
New Revision: 306514

URL: http://svn.apache.org/viewcvs?rev=306514&view=rev
Log:
Added attribute serilization stuff

Modified:
    webservices/axis2/trunk/c/include/axis2_om_attribute.h
    webservices/axis2/trunk/c/modules/test/om/src/test_om_serialize.c
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_xml_stream_writer.c
    webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_attribute.c
    webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_element.c
    webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_output.c

Modified: webservices/axis2/trunk/c/include/axis2_om_attribute.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_om_attribute.h?rev=306514&r1=306513&r2=306514&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_om_attribute.h (original)
+++ webservices/axis2/trunk/c/include/axis2_om_attribute.h Wed Oct  5 20:30:06 2005
@@ -25,6 +25,7 @@
 #include <axis2_qname.h>
 #include <axis2_om_node.h>
 #include <axis2_om_namespace.h>
+#include <axis2_om_output.h>
 
 /**
  * localname   
@@ -63,5 +64,7 @@
  */
 
 void axis2_om_attribute_free(axis2_om_attribute_t *attr);
+
+int axis2_om_attribute_serialize(axis2_om_attribute_t *attribute, axis2_om_output_t* om_output);
 
 #endif /* AXIS2_OM_ATTRIBUTE_H */

Modified: webservices/axis2/trunk/c/modules/test/om/src/test_om_serialize.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/test/om/src/test_om_serialize.c?rev=306514&r1=306513&r2=306514&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/test/om/src/test_om_serialize.c (original)
+++ webservices/axis2/trunk/c/modules/test/om/src/test_om_serialize.c Wed Oct  5 20:30:06
2005
@@ -17,18 +17,18 @@
     axis2_om_namespace_t *ns1 = NULL, *ns2 = NULL, *ns3 = NULL;
     axis2_om_output_t* om_output = NULL;
 
-    ns1 = axis2_om_namespace_create ("ns1", "test1");
-    ns2 = axis2_om_namespace_create ("ns2", "test2");
-    ns3 = axis2_om_namespace_create ("ns3", "test3");
+    ns1 = axis2_om_namespace_create ("ns1uri", "ns1prefix");
+    ns2 = axis2_om_namespace_create ("ns2uri", "ns2prefix");
+    ns3 = axis2_om_namespace_create ("ns3uri", "ns3prefix");
     
     ele1 = axis2_om_element_create (NULL, "root", ns1, &node1);
     if (node1->first_child)
         printf("has first_child\n");
 
-    ele2 = axis2_om_element_create (node1, "ele1", ns2, &node2);
+    ele2 = axis2_om_element_create (node1, "ele2", ns2, &node2);
 
-    attr1 = axis2_om_attribute_create ("ele1", "attr1", ns2);
-    axis2_om_element_add_attribute (ele2, attr1);
+    attr1 = axis2_om_attribute_create ("attr1key", "attr1value", ns1);
+    axis2_om_element_add_attribute (node2, attr1);
     
 
 

Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_xml_stream_writer.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_xml_stream_writer.c?rev=306514&r1=306513&r2=306514&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_xml_stream_writer.c (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_xml_stream_writer.c Wed
Oct  5 20:30:06 2005
@@ -607,7 +607,7 @@
                 {
                     fputs( to_write, stream_writer->writer);
 
-                    free (to_write);
+                    //free (to_write);
                 }
                 else
                     return GUTHTHILA_STREAM_WRITER_ERROR_OUT_OF_MEMORY;
@@ -629,7 +629,7 @@
                 {
                     fputs( to_write, stream_writer->writer);
 
-                    free (to_write);
+                    //free (to_write);
                 }
                 else
                     return GUTHTHILA_STREAM_WRITER_ERROR_OUT_OF_MEMORY;
@@ -652,7 +652,7 @@
             {
                 fputs( to_write, stream_writer->writer);
 
-                free (to_write);
+                //free (to_write);
             }
             else
                 return GUTHTHILA_STREAM_WRITER_ERROR_OUT_OF_MEMORY;

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=306514&r1=306513&r2=306514&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 Wed Oct  5 20:30:06
2005
@@ -72,3 +72,22 @@
 		}
 		return qname;
 }
+
+
+int axis2_om_attribute_serialize(axis2_om_attribute_t *attribute, axis2_om_output_t* om_output)
+{
+    int status = AXIS2_SUCCESS;
+    // TODO : handle null pointer errors
+    if (attribute->ns && attribute->ns->uri && attribute->ns->prefix)
+        status = axis2_om_output_write (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 (om_output, AXIS2_OM_ATTRIBUTE, 3,
+                               attribute->localname, attribute->value, attribute->ns->uri);
+    else 
+        status = axis2_om_output_write (om_output, AXIS2_OM_ATTRIBUTE, 2,
+                               attribute->localname, attribute->value);
+    return status;
+}
+

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=306514&r1=306513&r2=306514&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 Wed Oct  5 20:30:06 2005
@@ -470,6 +470,30 @@
         status = axis2_om_output_write (om_output, AXIS2_OM_ELEMENT, 1,
                                element_node->localname);
 
+    // serialize attributes
+    if (element_node->attributes)
+    {
+        apr_hash_index_t *hi;
+        void *val;
+        for (hi = apr_hash_first(om_pool, element_node->attributes); hi; hi = apr_hash_next(hi))

+        {
+            apr_hash_this(hi, NULL, NULL, &val);
+    
+            if (val)            
+                status = axis2_om_attribute_serialize( (axis2_om_attribute_t*)val, om_output);
+            else
+            {
+                status = AXIS2_FAILURE;
+            }
+        }
+    }
+    
+    // serialize namespaces
+    if (element_node->namespaces)
+    {
+        
+    }
+    
     return status;
 }
 

Modified: webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_output.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_output.c?rev=306514&r1=306513&r2=306514&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_output.c (original)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_output.c Wed Oct  5 20:30:06 2005
@@ -17,15 +17,19 @@
 #include <axis2_om_output.h>
 
 
-axis2_om_output_t* axis2_create_om_output( FILE* stream)
+axis2_om_output_t *
+axis2_create_om_output (FILE * stream)
 {
-    axis2_om_output_t *om_output = (axis2_om_output_t*) malloc (sizeof (axis2_om_output_t));
+    axis2_om_output_t *om_output =
+        (axis2_om_output_t *) malloc (sizeof (axis2_om_output_t));
 
     if (!om_output)
         return 0;
 
     om_output->out_stream = stream;
-    om_output->xml_writer = guththila_create_xml_stream_writer( om_output->out_stream,
DEFAULT_CHAR_SET_ENCODING, 0 );
+    om_output->xml_writer =
+        guththila_create_xml_stream_writer (om_output->out_stream,
+                                            DEFAULT_CHAR_SET_ENCODING, 1);
     om_output->do_optimize = 0;
     om_output->mime_boundary = 0;
     om_output->root_content_id = 0;
@@ -38,56 +42,83 @@
     return om_output;
 }
 
-int axis2_om_output_write(axis2_om_output_t* om_output, axis2_om_types_t type, int no_of_args,
... )
+int
+axis2_om_output_write (axis2_om_output_t * om_output, axis2_om_types_t type,
+                       int no_of_args, ...)
 {
-
-    char* args_list[no_of_args];
+    int status = AXIS2_SUCCESS;
+    char *args_list[no_of_args];
     int i = 0;
     va_list ap;
-    
-    switch (type)
+
+    va_start (ap, no_of_args);
+    for (i = 0; i < no_of_args; i++)
     {
-        case AXIS2_OM_ELEMENT:
-            
-            
-            va_start(ap, no_of_args);
-            
-            for( i = 0; i < no_of_args; i ++)
-            {
-                args_list[i] = va_arg(ap, char*);
-            }
-            va_end(ap);
-            switch (no_of_args)
-            {
-                case 0:
-                    guththila_xml_stream_writer_write_end_element( om_output->xml_writer);
-                    break;
-                case 1:
-                    guththila_xml_stream_writer_write_start_element( om_output->xml_writer,
args_list[0] );
-                    break;
-                case 2:
-                    guththila_xml_stream_writer_write_start_element_with_namespace( om_output->xml_writer,
args_list[0], args_list[1] );
-                    break;
-                case 3:
-                    guththila_xml_stream_writer_write_start_element_with_namespace_prefix(
om_output->xml_writer, args_list[0], args_list[1], args_list[2] );
-                    break;
+        args_list[i] = va_arg (ap, char *);
     }
+    va_end (ap);
+
+
+    switch (type)
+    {
+    case AXIS2_OM_ELEMENT:
+
+
+        switch (no_of_args)
+        {
+        case 0:
+            status = guththila_xml_stream_writer_write_end_element (om_output->
+                                                           xml_writer);
             break;
+        case 1:
+            status = guththila_xml_stream_writer_write_start_element (om_output->
+                                                             xml_writer,
+                                                             args_list[0]);
+            break;
+        case 2:
+            status = guththila_xml_stream_writer_write_start_element_with_namespace
+                (om_output->xml_writer, args_list[0], args_list[1]);
+            break;
+        case 3:
+            status = guththila_xml_stream_writer_write_start_element_with_namespace_prefix
+                (om_output->xml_writer, args_list[0], args_list[1],
+                 args_list[2]);
+            break;
+        }
+        break;
+
+    case AXIS2_OM_ATTRIBUTE:
+        switch (no_of_args)
+        {
+            case 2:
+                status = guththila_xml_stream_writer_write_attribute(om_output->xml_writer,
args_list[0], args_list[1]);
+                break;
+            case 3:
+                status = guththila_xml_stream_writer_write_attribute_with_namespace(om_output->xml_writer,
args_list[0], args_list[1], args_list[2]);
+                break;
+            case 4:
+                status = guththila_xml_stream_writer_write_attribute_with_namespace_prefix(om_output->xml_writer,
args_list[0], args_list[1], args_list[2], args_list[3]);
+                break;
 
-        case AXIS2_OM_ATTRIBUTE:
-                
+        }
+        break;
         /*case AXIS2_OM_DOCUMENT:
-            b= 10,
-         = 20,
-        AXIS2_OM_DOCTYPE = 30,
-        AXIS2_OM_COMMENT = 40,
-        
-        AXIS2_OM_NAMESPACE = 60,
-        AXIS2_OM_PROCESSING_INSTRUCTION = 70,
-            AXIS2_OM_TEXT = 80*/
-        default:
-            break;
+           b= 10,
+           = 20,
+           AXIS2_OM_DOCTYPE = 30,
+           AXIS2_OM_COMMENT = 40,
+
+           AXIS2_OM_NAMESPACE = 60,
+           AXIS2_OM_PROCESSING_INSTRUCTION = 70,
+           AXIS2_OM_TEXT = 80 */
+    default:
+        break;
     };
-  
-    return AXIS2_SUCCESS;
+
+    if (status == GUTHTHILA_SUCCESS)
+    {
+        return AXIS2_SUCCESS;
+    }
+    else 
+        return AXIS2_FAILURE;
 }



Mime
View raw message