You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2008/12/06 18:04:55 UTC

svn commit: r724011 - in /webservices/axis2/trunk/c/axiom: include/axiom_node.h src/om/om_node.c

Author: dimuthu
Date: Sat Dec  6 09:04:55 2008
New Revision: 724011

URL: http://svn.apache.org/viewvc?rev=724011&view=rev
Log:
fixing https://issues.apache.org/jira/browse/AXIS2C-1308 - adding axiom_node_create_from_buffer

Modified:
    webservices/axis2/trunk/c/axiom/include/axiom_node.h
    webservices/axis2/trunk/c/axiom/src/om/om_node.c

Modified: webservices/axis2/trunk/c/axiom/include/axiom_node.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/include/axiom_node.h?rev=724011&r1=724010&r2=724011&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/include/axiom_node.h (original)
+++ webservices/axis2/trunk/c/axiom/include/axiom_node.h Sat Dec  6 09:04:55 2008
@@ -102,6 +102,18 @@
         const axutil_env_t * env);
 
     /**
+      * Creates a node struct from a character buffer.
+      * @param env Environment. MUST NOT be NULL, .
+      * @param buffer string. buffer to make the node
+      * @return a pointer to newly created node struct. NULL on error. 
+      */
+    AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+    axiom_node_create_from_buffer(    
+        const axutil_env_t * env,
+        axis2_char_t *buffer);
+
+
+    /**
     * Frees an om node and all of its children. Please note that the attached
     * data_element will also be freed along with the node.  If the node is
     * still attached to a parent, it will be detached first, then freed.

Modified: webservices/axis2/trunk/c/axiom/src/om/om_node.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/om/om_node.c?rev=724011&r1=724010&r2=724011&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/om/om_node.c (original)
+++ webservices/axis2/trunk/c/axiom/src/om/om_node.c Sat Dec  6 09:04:55 2008
@@ -91,6 +91,52 @@
     return node;
 }
 
+AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+axiom_node_create_from_buffer(
+    const axutil_env_t * env,
+    axis2_char_t *buffer)
+{
+    axiom_xml_reader_t *reader = NULL;
+    axiom_stax_builder_t *builder = NULL;
+    axiom_document_t *document = NULL;
+    axiom_node_t *om_node = NULL;
+
+    reader = axiom_xml_reader_create_for_memory (env, buffer, axutil_strlen (buffer),
+        "UTF-8", AXIS2_XML_PARSER_TYPE_BUFFER);
+
+    if (!reader)
+    {
+        return NULL;
+    }
+
+    builder = axiom_stax_builder_create (env, reader);
+
+    if (!builder)
+    {
+        return NULL;
+    }
+    document = axiom_stax_builder_get_document (builder, env);
+    if (!document)
+    {
+        AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "Document is null for deserialization");
+        return NULL;
+    }
+
+    om_node = axiom_document_get_root_element (document, env);
+
+    if (!om_node)
+    {
+        AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "Root element of the document is not found");
+        return NULL;
+    }
+    axiom_document_build_all (document, env);
+
+    axiom_stax_builder_free_self (builder, env);
+
+    return om_node;
+}
+
+
 static void
 axiom_node_free_detached_subtree(
     axiom_node_t * om_node,