axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r353971 [2/2] - in /webservices/axis2/trunk/c: bindings/php/ include/ modules/util/src/ modules/xml/parser/ modules/xml/parser/guththila/src/ modules/xml/parser/libxml2/src/ test/xml/om/
Date Mon, 05 Dec 2005 03:49:50 GMT
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=353971&r1=353970&r2=353971&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_om_element.h (original)
+++ webservices/axis2/trunk/c/include/axis2_om_element.h Sun Dec  4 19:49:16 2005
@@ -286,7 +286,7 @@
         ((om_element)->ops->get_namespace(om_element, env))
 /** set localname */        
 #define AXIS2_OM_ELEMENT_SET_LOCALNAME(om_element, env, localname) \
-        ((om_element)->ops->set_localname(om_element, env))
+        ((om_element)->ops->set_localname(om_element, env, localname))
 /** set namespace */        
 #define AXIS2_OM_ELEMENT_SET_NAMESPACE(om_element, env, ns , node) \
         ((om_element)->ops->set_namespace(om_element, env, ns, node))

Modified: webservices/axis2/trunk/c/modules/util/src/env.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/env.c?rev=353971&r1=353970&r2=353971&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/env.c (original)
+++ webservices/axis2/trunk/c/modules/util/src/env.c Sun Dec  4 19:49:16 2005
@@ -22,9 +22,6 @@
 
 AXIS2_DECLARE(axis2_status_t)  axis2_env_free (axis2_env_t *env)
 {
-    if(NULL != env && NULL != env->allocator)
-        free (env->allocator);
-
     if(env != NULL && env->stream != NULL && (env->stream->ops)
!= NULL)
 		AXIS2_STREAM_FREE(env->stream);
 

Modified: webservices/axis2/trunk/c/modules/xml/parser/axis2_xml_writer.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/parser/axis2_xml_writer.h?rev=353971&r1=353970&r2=353971&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/parser/axis2_xml_writer.h (original)
+++ webservices/axis2/trunk/c/modules/xml/parser/axis2_xml_writer.h Sun Dec  4 19:49:16 2005
@@ -418,6 +418,9 @@
                                                  axis2_env_t **env,
                                                  axis2_char_t *text,
                                                  int in_attr);
+                                                 
+        axis2_char_t* (AXIS2_CALL *get_xml)(axis2_xml_writer_t *,
+                                             axis2_env_t **env);                        
                        
 
     };
 
@@ -444,7 +447,6 @@
 
 AXIS2_DECLARE(axis2_xml_writer_t *)
 axis2_xml_writer_create_for_memory(axis2_env_t **env,
-                                   char **buffer,
                                    axis2_char_t *encoding,
                                    int is_prefix_default,
                                    int compression);
@@ -553,6 +555,9 @@
 
 #define AXIS2_XML_WRITER_WRITE_ENCODED(writer, env, text, in_attr) \
         ((writer)->ops->write_encoded(writer, env, text, in_attr))
+        
+#define AXIS2_XML_WRITER_GET_XML(writer, env) \
+        ((writer)->ops->get_xml(writer, env))        
 /** @} */
 
 

Modified: webservices/axis2/trunk/c/modules/xml/parser/guththila/src/guththila_xml_writer_wrapper.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/parser/guththila/src/guththila_xml_writer_wrapper.c?rev=353971&r1=353970&r2=353971&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/parser/guththila/src/guththila_xml_writer_wrapper.c
(original)
+++ webservices/axis2/trunk/c/modules/xml/parser/guththila/src/guththila_xml_writer_wrapper.c
Sun Dec  4 19:49:16 2005
@@ -194,6 +194,10 @@
                                          axis2_char_t *text,
                                          int in_attr);
 
+axis2_char_t* AXIS2_CALL 
+guththila_xml_writer_wrapper_get_xml(axis2_xml_writer_t *writer,
+                                     axis2_env_t **env);                                
        
+
 
 
 /**************************** end function pointers ****************************/
@@ -203,6 +207,7 @@
     axis2_xml_writer_t writer;
     guththila_xml_stream_writer_t *guththila_writer;
     guththila_environment_t *guththila_env;
+    
 }guththila_xml_writer_wrapper_impl_t;
 
 
@@ -311,13 +316,15 @@
     writer_impl->writer.ops->set_default_prefix = 
             guththila_xml_writer_wrapper_set_default_prefix;
     writer_impl->writer.ops->write_encoded = 
-            guththila_xml_writer_wrapper_write_encoded;    
+            guththila_xml_writer_wrapper_write_encoded; 
+    writer_impl->writer.ops->get_xml =
+            guththila_xml_writer_wrapper_get_xml;
+                           
     return &(writer_impl->writer);
 }
 
 AXIS2_DECLARE(axis2_xml_writer_t *)
 axis2_xml_writer_create_for_memory(axis2_env_t **env,
-                                   char **buffer,
                                    axis2_char_t *encoding,
                                    int is_prefix_default,
                                    int compression)
@@ -773,3 +780,11 @@
                     AXIS2_INTF_TO_IMPL(writer)->guththila_env,
                     AXIS2_INTF_TO_IMPL(writer)->guththila_writer, text, in_attr);
 }
+
+axis2_char_t* AXIS2_CALL 
+guththila_xml_writer_wrapper_get_xml(axis2_xml_writer_t *writer,
+                                     axis2_env_t **env)
+{
+    printf(" not implemented yet ");
+}                                     
+                                     

Modified: webservices/axis2/trunk/c/modules/xml/parser/libxml2/src/axis2_libxml2_writer_wrapper.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/parser/libxml2/src/axis2_libxml2_writer_wrapper.c?rev=353971&r1=353970&r2=353971&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/parser/libxml2/src/axis2_libxml2_writer_wrapper.c
(original)
+++ webservices/axis2/trunk/c/modules/xml/parser/libxml2/src/axis2_libxml2_writer_wrapper.c
Sun Dec  4 19:49:16 2005
@@ -210,6 +210,10 @@
                                          axis2_char_t *text,
                                          int in_attr);
 
+axis2_char_t* AXIS2_CALL
+axis2_libxml2_writer_wrapper_get_xml(axis2_xml_writer_t *writer,
+                                     axis2_env_t **env);
+
 static axis2_bool_t 
 axis2_libxml2_writer_wrapper_validate_namespace(axis2_xml_writer_t *writer,
                                          axis2_env_t **env,
@@ -218,6 +222,8 @@
 static axis2_status_t 
 axis2_libxml2_writer_wrapper_reset(axis2_xml_writer_t *writer,
                                    axis2_env_t **env);
+
+                                   
                                                                             
 
 
@@ -237,7 +243,6 @@
     axis2_xml_writer_t writer;
     xmlTextWriterPtr xml_writer;
     xmlBufferPtr buffer;
-    axis2_char_t **output_buffer;
     int writer_type;
     axis2_char_t *encoding;
     int is_prefix_defaulting;
@@ -276,6 +281,9 @@
         AXIS2_FREE((*env)->allocator, writer_impl);
                 
     }
+    writer_impl->buffer = NULL;
+    writer_impl->encoding = NULL;
+    
     
     if(encoding)
         writer_impl->encoding = AXIS2_STRDUP(encoding , env);
@@ -369,6 +377,8 @@
             axis2_libxml2_writer_wrapper_set_default_prefix;
     writer_impl->writer.ops->write_encoded = 
             axis2_libxml2_writer_wrapper_write_encoded;    
+    writer_impl->writer.ops->get_xml =
+            axis2_libxml2_writer_wrapper_get_xml;            
     return &(writer_impl->writer);
 }
 
@@ -376,7 +386,6 @@
 
 AXIS2_DECLARE(axis2_xml_writer_t *)
 axis2_xml_writer_create_for_memory(axis2_env_t **env,
-                                   char **buffer,
                                    axis2_char_t *encoding, 
                                    int is_prefix_default,
                                    int compression)
@@ -394,7 +403,6 @@
     writer_impl->qname_array.prefix = NULL;
     writer_impl->qname_array.uri = NULL;
     writer_impl->writer_type = AXIS2_LIBXML2_WRITER_MEMORY;
-    writer_impl->output_buffer = buffer;
     
     
     writer_impl->buffer = xmlBufferCreate();
@@ -503,7 +511,9 @@
     writer_impl->writer.ops->set_default_prefix = 
             axis2_libxml2_writer_wrapper_set_default_prefix;
     writer_impl->writer.ops->write_encoded = 
-            axis2_libxml2_writer_wrapper_write_encoded;    
+            axis2_libxml2_writer_wrapper_write_encoded;
+    writer_impl->writer.ops->get_xml =
+            axis2_libxml2_writer_wrapper_get_xml;                 
     return &(writer_impl->writer);
 }
 
@@ -516,20 +526,8 @@
     AXIS2_FUNC_PARAM_CHECK(writer, env, AXIS2_FAILURE);
     writer_impl = AXIS2_INTF_TO_IMPL(writer);
 
-    if(writer_impl->xml_writer)
-    {
-        xmlFreeTextWriter(writer_impl->xml_writer);
-        writer_impl->xml_writer = NULL;
-    }
    
-    if(writer_impl->writer_type == AXIS2_LIBXML2_WRITER_MEMORY)
-    {
-      *(writer_impl->output_buffer) = AXIS2_MALLOC((*env)->allocator,     
-            sizeof(axis2_char_t)*(strlen((const axis2_char_t*)writer_impl->buffer->content)+1));
-        sprintf(*(writer_impl->output_buffer),(const axis2_char_t*)writer_impl->buffer->content);
-        xmlBufferFree(writer_impl->buffer);
-        writer_impl->buffer = NULL;
-    }
+ 
            
     if(writer_impl->encoding)
     {
@@ -1368,3 +1366,35 @@
         writer_impl->qname_array.current_no = 0;    
     return AXIS2_SUCCESS;
 }
+
+
+axis2_char_t* AXIS2_CALL
+axis2_libxml2_writer_wrapper_get_xml(axis2_xml_writer_t *writer,
+                                     axis2_env_t **env)
+{
+    axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL;
+    axis2_char_t *output = NULL;
+    writer_impl = AXIS2_INTF_TO_IMPL(writer);
+    if(writer_impl->xml_writer)
+    {
+        xmlFreeTextWriter(writer_impl->xml_writer);
+        writer_impl->xml_writer = NULL;
+    }
+    if(writer_impl->writer_type == AXIS2_LIBXML2_WRITER_MEMORY)
+    {
+
+        if(writer_impl->buffer != NULL)
+        {
+           output = AXIS2_MALLOC((*env)->allocator,     
+                    sizeof(axis2_char_t)*(
+                        strlen((const axis2_char_t*)(writer_impl->buffer->content))+1));
+            sprintf(output, 
+                    ((const axis2_char_t*)(writer_impl->buffer->content)));
+        }
+    }
+    else if(writer_impl->writer_type == AXIS2_LIBXML2_WRITER_FILE)
+    {
+        printf(" This is not supported for this type of writer");
+    }
+    return output;   
+}
\ No newline at end of file

Modified: webservices/axis2/trunk/c/test/xml/om/test_om.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/test/xml/om/test_om.c?rev=353971&r1=353970&r2=353971&view=diff
==============================================================================
--- webservices/axis2/trunk/c/test/xml/om/test_om.c (original)
+++ webservices/axis2/trunk/c/test/xml/om/test_om.c Sun Dec  4 19:49:16 2005
@@ -6,7 +6,7 @@
 #include <axis2_stream_default.h>
 #include <axis2_log_default.h>
 #include <axis2_error_default.h>
-
+#include <axis2_xml_reader.h>
 #include <stdio.h>
 #include <axis2_xml_writer.h>
 
@@ -41,15 +41,13 @@
     axis2_om_namespace_t* ns = NULL;
     axis2_xml_reader_t *reader = NULL;
     axis2_xml_writer_t *writer = NULL;
-    axis2_char_t *buf = NULL;
-    
-    
+    char *buffer = NULL;
     f =fopen(filename, "r");
     if(!f)
         return -1;
       
     /** create pull parser */
-    reader = axis2_xml_reader_create_for_memory(&environment, read_input, NULL);
+     reader = axis2_xml_reader_create_for_memory(&environment, read_input, NULL);
     
     if(!reader)
     {
@@ -80,8 +78,7 @@
     {
         /** print root node information */
         
-       if(AXIS2_OM_NODE_GET_NODE_TYPE(node1, &environment) == AXIS2_OM_ELEMENT)
-       {
+       
         ele1 =AXIS2_OM_NODE_GET_DATA_ELEMENT(node1,&environment);
         if(ele1)
              
@@ -92,10 +89,9 @@
         if (ns)
         {
             printf ("root ns prefix %s\n", AXIS2_OM_NAMESPACE_GET_PREFIX(ns,&environment));
-            printf ("root ns uri %s\n", AXIS2_OM_NAMESPACE_GET_URI(ns,&environment));
-            ns = NULL;
+            printf ("root ns uri %s\n", AXIS2_OM_NAMESPACE_GET_PREFIX(ns,&environment));
+
         }
-       }
     }
     /** build the document continuously untill all the xml file is built in to a om model
*/
     
@@ -111,20 +107,9 @@
         {
         case AXIS2_OM_ELEMENT:
             ele2 =(axis2_om_element_t*) AXIS2_OM_NODE_GET_DATA_ELEMENT(node2, &environment);
-        if(ele2 && AXIS2_OM_ELEMENT_GET_LOCALNAME(ele2,&environment))
-        { 
-               printf("\n localname %s\n" , AXIS2_OM_ELEMENT_GET_LOCALNAME(ele2,&environment));

-            
-               ns = AXIS2_OM_ELEMENT_GET_NAMESPACE(ele2,&environment);
-    
-            if (ns)
-            {
-                printf ("prefix %s\n", AXIS2_OM_NAMESPACE_GET_PREFIX(ns,&environment));
-                printf ("ns uri %s\n", AXIS2_OM_NAMESPACE_GET_URI(ns,&environment));
-            }
-            
-                ns = NULL;
-            }            
+            if(ele2 && AXIS2_OM_ELEMENT_GET_LOCALNAME(ele2,&environment))
+                printf("\n localname %s\n" , AXIS2_OM_ELEMENT_GET_LOCALNAME(ele2,&environment));

+                        
             break;
         case AXIS2_OM_TEXT:
             
@@ -142,21 +127,25 @@
     while (node2);
     printf ("END: pull document\n");
 
-    printf ("Serialize pulled document\n\n\n\n");
+    printf ("Serialize pulled document\n");
     
-    writer = axis2_xml_writer_create_for_memory(&environment, &buf, NULL, AXIS2_TRUE,
0);
-    /*
-    for guththila use following 
-    writer = axis2_xml_writer_create(&environment, NULL , NULL, AXIS2_TRUE, 0);
-    */
+    writer = axis2_xml_writer_create_for_memory(&environment,NULL, AXIS2_TRUE, 0);
     om_output = axis2_om_output_create (&environment, writer);
-    AXIS2_OM_NODE_SERIALIZE (AXIS2_OM_DOCUMENT_GET_ROOT_ELEMENT(document, &environment),
&environment , om_output);
-    AXIS2_OM_DOCUMENT_FREE(document, &environment); 
+
+    AXIS2_OM_NODE_SERIALIZE (node1, &environment , om_output);
+    
+    buffer = AXIS2_XML_WRITER_GET_XML(writer, &environment);
     axis2_om_output_free(om_output, &environment);  
+    printf("%s",buffer);
+    
+    AXIS2_OM_DOCUMENT_FREE(document, &environment); 
+  
     AXIS2_OM_STAX_BUILDER_FREE(builder, &environment);
   
-    printf("%s",buf);    
-    AXIS2_FREE(environment->allocator, buf);
+  
+    
+
+    
     printf ("\ndone\n");
     return 0;
 }
@@ -180,7 +169,6 @@
        </book>
     */
     int status;
-    axis2_xml_writer_t *writer = NULL;
     axis2_om_element_t *ele1 = NULL, *ele2 = NULL, *ele3 = NULL, *ele4 =
         NULL;
     axis2_om_node_t *node1 = NULL, *node2 = NULL, *node3 = NULL, *node4 =
@@ -189,7 +177,9 @@
     axis2_om_namespace_t *ns1 = NULL, *ns2 = NULL, *ns3 = NULL;
     axis2_om_text_t *text1 = NULL;
     axis2_om_output_t *om_output = NULL;
-    char *buffer = NULL;
+    axis2_xml_writer_t *writer = NULL;
+    axis2_char_t *output_buffer = NULL;
+
     ns1 =
         axis2_om_namespace_create (&environment,
                                    "http://ws.apache.org/axis2/c/om",
@@ -221,19 +211,13 @@
     
     AXIS2_OM_ELEMENT_ADD_ATTRIBUTE(ele4,&environment, attr2);
     
-    writer = axis2_xml_writer_create_for_memory(&environment, &buffer, NULL, AXIS2_TRUE,
0);
-    /* for guththila use following */
-    /*
-    writer = axis2_xml_writer_create(&environment,NULL, NULL, AXIS2_TRUE, 0);
-    */
    
     /* serializing stuff */
-    om_output = axis2_om_output_create (&environment,writer);
+    writer = axis2_xml_writer_create_for_memory(&environment, NULL, AXIS2_TRUE, 0);
+    om_output = axis2_om_output_create (&environment, writer);
 
     printf ("Serialize built document\n");
-    AXIS2_XML_WRITER_WRITE_START_DOCUMENT(om_output->xml_writer , &environment);
     status = AXIS2_OM_NODE_SERIALIZE (node1,&environment ,om_output);
-    AXIS2_XML_WRITER_WRITE_END_DOCUMENT(om_output->xml_writer, &environment);
     if (status != AXIS2_SUCCESS)
     {
         printf ("\naxis2_om_node_serialize failed\n");
@@ -244,10 +228,11 @@
     /* end serializing stuff */
 
      AXIS2_OM_NODE_FREE_TREE(node1,&environment);
+     output_buffer = AXIS2_XML_WRITER_GET_XML(writer, &environment);
      axis2_om_output_free(om_output, &environment);
-             
-     printf("%s", buffer); 
-    
+     
+     printf("%s",output_buffer);
+     
      printf ("\nDONE\n");
 
     return 0;
@@ -256,20 +241,20 @@
 int
 main (int argc, char *argv[])
 {
-    char *file_name = "contents.xml";
+    char *file_name = "test.xml";
     if (argc > 1)
         file_name = argv[1];
     allocator = axis2_allocator_init (NULL);
     axis_log = axis2_log_create(allocator, NULL);
     error = axis2_error_create(allocator);
-
+    
     stream = axis2_stream_create(allocator, NULL);
-
+    
     environment = axis2_env_create_with_error_stream_log(allocator, error, stream, axis_log);
-    test_om_build (file_name); 
+    test_om_build (file_name);
     test_om_serialize();
     axis2_env_free(environment); 
-    
+    getchar();
     return 0;
  }
 



Mime
View raw message