axis-c-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shan...@apache.org
Subject svn commit: r926481 - in /axis/axis2/c/core/trunk/axiom: include/ src/om/
Date Tue, 23 Mar 2010 07:10:28 GMT
Author: shankar
Date: Tue Mar 23 07:10:27 2010
New Revision: 926481

URL: http://svn.apache.org/viewvc?rev=926481&view=rev
Log:
refactoring. 

Added:
    axis/axis2/c/core/trunk/axiom/src/om/axiom_document_internal.h
Modified:
    axis/axis2/c/core/trunk/axiom/include/axiom_document.h
    axis/axis2/c/core/trunk/axiom/include/axiom_element.h
    axis/axis2/c/core/trunk/axiom/include/axiom_stax_builder.h
    axis/axis2/c/core/trunk/axiom/src/om/axiom_stax_builder_internal.h
    axis/axis2/c/core/trunk/axiom/src/om/om_document.c
    axis/axis2/c/core/trunk/axiom/src/om/om_element.c
    axis/axis2/c/core/trunk/axiom/src/om/om_stax_builder.c

Modified: axis/axis2/c/core/trunk/axiom/include/axiom_document.h
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/include/axiom_document.h?rev=926481&r1=926480&r2=926481&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/include/axiom_document.h (original)
+++ axis/axis2/c/core/trunk/axiom/include/axiom_document.h Tue Mar 23 07:10:27 2010
@@ -48,52 +48,6 @@ extern "C"
     typedef struct axiom_document axiom_document_t;
 
     /**
-      * creates an axiom_document_t struct
-      * @param env Environment. MUST NOT be NULL.
-      * @param root pointer to document's root node. Optional, can be NULL
-      * @param builder pointer to axiom_stax_builder 
-      * @return pointer to the newly created document.
-      */
-    AXIS2_EXTERN axiom_document_t *AXIS2_CALL
-    axiom_document_create(
-        const axutil_env_t * env,
-        axiom_node_t * root,
-        struct axiom_stax_builder *builder);
-
-    /**
-      * Free document struct
-      * @param document pointer to axiom_document_t struct to be freed
-      * @param env Environment. MUST NOT be NULL  
-      * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
-      */
-    AXIS2_EXTERN void AXIS2_CALL
-    axiom_document_free(
-        struct axiom_document *document,
-        const axutil_env_t * env);
-
-    /**
-     * Free document struct only, Does not free the associated axiom struture.
-     * @param document pointer to axiom_document_t struct to be freed
-     * @param env Environment. MUST NOT be NULL  
-     * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
-     */
-    AXIS2_EXTERN void AXIS2_CALL
-    axiom_document_free_self(
-        struct axiom_document *document,
-        const axutil_env_t * env);
-
-    /** Builds the next node if the builder is not finished with input xml stream
-      * @param document document whose next node is to be built. cannot be NULL
-      * @param env Environment. MUST NOT be NULL.  
-      * @return pointer to the next node. NULL on error.
-      */
-
-    AXIS2_EXTERN axiom_node_t *AXIS2_CALL
-    axiom_document_build_next(
-        struct axiom_document *document,
-        const axutil_env_t * env);
-
-    /**
       * Gets the root element of the document.
       * @param document document to return the root of
       * @param env Environment. MUST NOT be NULL.  
@@ -106,20 +60,6 @@ extern "C"
         const axutil_env_t * env);
 
     /**
-      * set the root element of the document. IF a root node is already exist,it is freed

-      * before setting to root element 
-      * @param document document struct to return the root of
-      * @param env Environment. MUST NOT be NULL.  
-      * @return returns status code AXIS2_SUCCESS on success ,AXIS2_FAILURE on error. 
-      */
-
-    AXIS2_EXTERN axis2_status_t AXIS2_CALL
-    axiom_document_set_root_element(
-        struct axiom_document *document,
-        const axutil_env_t * env,
-        axiom_node_t * om_node);
-
-    /**
      * This method builds the rest of the xml input stream from current position till
      * the root element is completed .
      * @param document pointer to axiom_document_t struct to be built.
@@ -130,40 +70,6 @@ extern "C"
         struct axiom_document *document,
         const axutil_env_t * env);
 
-    /**
-     * get builder
-     * @param document pointer to axiom_document_t struct to be built.
-     * @param env environment MUST NOT be NULL.
-     * @return builder, returns NULL if a builder is not associated with 
-     * document
-     */
-    AXIS2_EXTERN struct axiom_stax_builder *AXIS2_CALL
-    axiom_document_get_builder(
-        struct axiom_document *document,
-        const axutil_env_t * env);
-
-    /**
-     * sets builder for document.
-     * @param document pointer to axiom_document_t struct to be built.
-     * @param env environment MUST NOT be NULL.
-     * @param builder pointer to builder to associate with document
-     */ 
-    AXIS2_EXTERN void AXIS2_CALL
-    axiom_document_set_builder(
-        axiom_document_t * document,
-        const axutil_env_t * env,
-        struct axiom_stax_builder * builder);
-
-    /**
-     * @param om_document
-     * @return status code AXIS2_SUCCESS on success , otherwise AXIS2_FAILURE
-     */
-    AXIS2_EXTERN axis2_status_t AXIS2_CALL
-    axiom_document_serialize(
-        struct axiom_document *document,
-        const axutil_env_t * env,
-        axiom_output_t * om_output);
-
     /** @} */
 
 #ifdef __cplusplus

Modified: axis/axis2/c/core/trunk/axiom/include/axiom_element.h
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/include/axiom_element.h?rev=926481&r1=926480&r2=926481&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/include/axiom_element.h (original)
+++ axis/axis2/c/core/trunk/axiom/include/axiom_element.h Tue Mar 23 07:10:27 2010
@@ -506,22 +506,7 @@ extern "C"
         const axutil_env_t * env,
         axiom_node_t * element_node);
 
-    /**
-     * builds this om_element_node completely, This is only possible 
-     * if the om_stax_builder is associated with the om_element_node,
-     * @param om_element pointer to om_element
-     * @param env environment MUST not be NULL
-     * @param om_node pointer to this element node
-     * @param element_node corresponding om element node of this om element
-     * struct 
-     * @returns AXIS2_SUCCESS if this element node was successfully completed,
-     * otherwise returns AXIS2_FAILURE
-     */
-    AXIS2_EXTERN axis2_status_t AXIS2_CALL
-    axiom_element_build(
-        axiom_element_t * om_element,
-        const axutil_env_t * env,
-        axiom_node_t * element_node);
+
 
     /**
      * retrieves the default namespace of this element , if available,
@@ -738,6 +723,25 @@ extern "C"
         axiom_element_t * root_element,
         axutil_hash_t *inscope_namespaces);
 
+#if 0
+    /**
+     * builds this om_element_node completely, This is only possible
+     * if the om_stax_builder is associated with the om_element_node,
+     * @param om_element pointer to om_element
+     * @param env environment MUST not be NULL
+     * @param om_node pointer to this element node
+     * @param element_node corresponding om element node of this om element
+     * struct
+     * @returns AXIS2_SUCCESS if this element node was successfully completed,
+     * otherwise returns AXIS2_FAILURE
+     */
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    axiom_element_build(
+        axiom_element_t * om_element,
+        const axutil_env_t * env,
+        axiom_node_t * element_node);
+
+#endif
     /** @} */
 
 #ifdef __cplusplus

Modified: axis/axis2/c/core/trunk/axiom/include/axiom_stax_builder.h
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/include/axiom_stax_builder.h?rev=926481&r1=926480&r2=926481&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/include/axiom_stax_builder.h (original)
+++ axis/axis2/c/core/trunk/axiom/include/axiom_stax_builder.h Tue Mar 23 07:10:27 2010
@@ -34,7 +34,6 @@ extern "C"
      * @ingroup axiom_om
      * @{
      */
-
     typedef struct axiom_stax_builder axiom_stax_builder_t;
 
     /**
@@ -50,30 +49,6 @@ extern "C"
         axiom_xml_reader_t * parser);
 
     /**
-      * Builds the next node from stream. Moves pull parser forward and reacts 
-      * to events.
-      * @param builder pointer to stax builder struct to be used
-      * @param environment Environment. MUST NOT be NULL.
-      * @return a pointer to the next node, or NULL if there are no more nodes.
-      *     On erros sets the error and returns NULL.
-      */
-    AXIS2_EXTERN axiom_node_t *AXIS2_CALL
-    axiom_stax_builder_next(
-        struct axiom_stax_builder *builder,
-        const axutil_env_t * env);
-
-    /**
-      * Discards the element that is being built currently.
-      * @param environment Environment. MUST NOT be NULL, .
-      * @param builder pointer to stax builder struct to be used
-      * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
-      */
-    AXIS2_EXTERN axis2_status_t AXIS2_CALL
-    axiom_stax_builder_discard_current_element(
-        struct axiom_stax_builder *builder,
-        const axutil_env_t * env);
-
-    /**
       * Free the build struct instance and its associated document,axiom tree.
       * @param builder pointer to builder struct
       * @param env environment, MUST NOT be NULL
@@ -110,41 +85,6 @@ extern "C"
         struct axiom_stax_builder *builder,
         const axutil_env_t * env);
 
-    /**
-      * builder is finished building om structure
-      * @param builder pointer to stax builder struct to be used
-      * @param environment Environment. MUST NOT be NULL.
-      *
-      * @return AXIS2_TRUE if is complete or AXIS2_FALSE otherwise
-      */
-
-    AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-    axiom_stax_builder_is_complete(
-        struct axiom_stax_builder *builder,
-        const axutil_env_t * env);
-
-    /**
-      * moves the reader to next event and returns the token returned by the xml_reader ,
-      * @param builder pointer to STAX builder struct to be used
-      * @param environment Environment. MUST NOT be NULL.
-      * @return next event axiom_xml_reader_event_types. Returns -1 on error
-      */
-    AXIS2_EXTERN int AXIS2_CALL
-    axiom_stax_builder_next_with_token(
-        struct axiom_stax_builder *builder,
-        const axutil_env_t * env);
-
-    AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL
-    axiom_stax_builder_get_parser(
-        axiom_stax_builder_t * om_builder,
-        const axutil_env_t * env);
-
-    AXIS2_EXTERN void AXIS2_CALL
-    axiom_stax_builder_set_cache(
-        axiom_stax_builder_t * om_builder,
-        const axutil_env_t * env,
-        axis2_bool_t enable_cache);
-
     /** @} */
 
 #ifdef __cplusplus

Added: axis/axis2/c/core/trunk/axiom/src/om/axiom_document_internal.h
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/src/om/axiom_document_internal.h?rev=926481&view=auto
==============================================================================
--- axis/axis2/c/core/trunk/axiom/src/om/axiom_document_internal.h (added)
+++ axis/axis2/c/core/trunk/axiom/src/om/axiom_document_internal.h Tue Mar 23 07:10:27 2010
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AXIOM_DOCUMENT_INTERNAL_H_
+#define AXIOM_DOCUMENT_INTERNAL_H_
+
+#include <axiom_document.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+    /**
+      * creates an axiom_document_t struct
+      * @param env Environment. MUST NOT be NULL.
+      * @param root pointer to document's root node. Optional, can be NULL
+      * @param builder pointer to axiom_stax_builder
+      * @return pointer to the newly created document.
+      */
+    axiom_document_t *AXIS2_CALL
+    axiom_document_create(
+        const axutil_env_t * env,
+        axiom_node_t * root,
+        struct axiom_stax_builder *builder);
+
+    /**
+      * Free document struct
+      * @param document pointer to axiom_document_t struct to be freed
+      * @param env Environment. MUST NOT be NULL
+      * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
+      */
+    void AXIS2_CALL
+    axiom_document_free(
+        struct axiom_document *document,
+        const axutil_env_t * env);
+
+    /**
+     * Free document struct only, Does not free the associated axiom structure.
+     * @param document pointer to axiom_document_t struct to be freed
+     * @param env Environment. MUST NOT be NULL
+     * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
+     */
+    void AXIS2_CALL
+    axiom_document_free_self(
+        struct axiom_document *document,
+        const axutil_env_t * env);
+
+    /** Builds the next node if the builder is not finished with input xml stream
+      * @param document document whose next node is to be built. cannot be NULL
+      * @param env Environment. MUST NOT be NULL.
+      * @return pointer to the next node. NULL on error.
+      */
+    axiom_node_t *AXIS2_CALL
+    axiom_document_build_next(
+        struct axiom_document *document,
+        const axutil_env_t * env);
+
+    /**
+      * set the root element of the document. IF a root node is already exist,it is freed
+      * before setting to root element
+      * @param document document struct to return the root of
+      * @param env Environment. MUST NOT be NULL.
+      * @return returns status code AXIS2_SUCCESS on success ,AXIS2_FAILURE on error.
+      */
+    axis2_status_t AXIS2_CALL
+    axiom_document_set_root_element(
+        struct axiom_document *document,
+        const axutil_env_t * env,
+        axiom_node_t * om_node);
+
+#if 0
+    /* these methods are commented, because it is not used anymore (1.6.0)*/
+
+    /**
+     * get builder
+     * @param document pointer to axiom_document_t struct to be built.
+     * @param env environment MUST NOT be NULL.
+     * @return builder, returns NULL if a builder is not associated with
+     * document
+     */
+    AXIS2_EXTERN struct axiom_stax_builder *AXIS2_CALL
+    axiom_document_get_builder(
+        struct axiom_document *document,
+        const axutil_env_t * env);
+
+    /**
+     * sets builder for document.
+     * @param document pointer to axiom_document_t struct to be built.
+     * @param env environment MUST NOT be NULL.
+     * @param builder pointer to builder to associate with document
+     */
+    AXIS2_EXTERN void AXIS2_CALL
+    axiom_document_set_builder(
+        axiom_document_t * document,
+        const axutil_env_t * env,
+        struct axiom_stax_builder * builder);
+
+    /**
+     * @param om_document
+     * @return status code AXIS2_SUCCESS on success , otherwise AXIS2_FAILURE
+     */
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    axiom_document_serialize(
+        struct axiom_document *document,
+        const axutil_env_t * env,
+        axiom_output_t * om_output);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AXIOM_DOCUMENT_INTERNAL_H_ */

Modified: axis/axis2/c/core/trunk/axiom/src/om/axiom_stax_builder_internal.h
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/src/om/axiom_stax_builder_internal.h?rev=926481&r1=926480&r2=926481&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/src/om/axiom_stax_builder_internal.h (original)
+++ axis/axis2/c/core/trunk/axiom/src/om/axiom_stax_builder_internal.h Tue Mar 23 07:10:27
2010
@@ -39,32 +39,94 @@ extern "C"
      * @{
      */
 
-    AXIS2_EXTERN int AXIS2_CALL
+    int AXIS2_CALL
     axiom_stax_builder_get_current_event(
         axiom_stax_builder_t * builder,
         const axutil_env_t * env);
 
-    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    axis2_status_t AXIS2_CALL
     axiom_stax_builder_set_lastnode(
         axiom_stax_builder_t * builder,
         const axutil_env_t * env,
         axiom_node_t * om_node);
 
-    AXIS2_EXTERN axiom_node_t *AXIS2_CALL
-        axiom_stax_builder_get_lastnode(
-            axiom_stax_builder_t * builder,
-            const axutil_env_t * env);
+    axiom_node_t *AXIS2_CALL
+    axiom_stax_builder_get_lastnode(
+        axiom_stax_builder_t * builder,
+        const axutil_env_t * env);
 
-    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    axis2_status_t AXIS2_CALL
     axiom_stax_builder_set_element_level(
         axiom_stax_builder_t * builder,
         const axutil_env_t * env,
         int element_level);
 
-    AXIS2_EXTERN int AXIS2_CALL
-        axiom_stax_builder_get_element_level(
-            axiom_stax_builder_t * builder,
-            const axutil_env_t * env);
+    int AXIS2_CALL
+    axiom_stax_builder_get_element_level(
+        axiom_stax_builder_t * builder,
+        const axutil_env_t * env);
+
+    /**
+      * Builds the next node from stream. Moves pull parser forward and reacts
+      * to events.
+      * @param builder pointer to stax builder struct to be used
+      * @param environment Environment. MUST NOT be NULL.
+      * @return a pointer to the next node, or NULL if there are no more nodes.
+      *     On erros sets the error and returns NULL.
+      */
+    axiom_node_t *AXIS2_CALL
+    axiom_stax_builder_next(
+        struct axiom_stax_builder *builder,
+        const axutil_env_t * env);
+
+    /**
+      * builder is finished building om structure
+      * @param builder pointer to stax builder struct to be used
+      * @param environment Environment. MUST NOT be NULL.
+      *
+      * @return AXIS2_TRUE if is complete or AXIS2_FALSE otherwise
+      */
+
+    axis2_bool_t AXIS2_CALL
+    axiom_stax_builder_is_complete(
+        struct axiom_stax_builder *builder,
+        const axutil_env_t * env);
+
+    /**
+      * moves the reader to next event and returns the token returned by the xml_reader ,
+      * @param builder pointer to STAX builder struct to be used
+      * @param environment Environment. MUST NOT be NULL.
+      * @return next event axiom_xml_reader_event_types. Returns -1 on error
+      */
+    int AXIS2_CALL
+    axiom_stax_builder_next_with_token(
+        struct axiom_stax_builder *builder,
+        const axutil_env_t * env);
+
+#if 0
+    /**
+      * Discards the element that is being built currently.
+      * @param environment Environment. MUST NOT be NULL, .
+      * @param builder pointer to stax builder struct to be used
+      * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
+      */
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    axiom_stax_builder_discard_current_element(
+        struct axiom_stax_builder *builder,
+        const axutil_env_t * env);
+
+    AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL
+    axiom_stax_builder_get_parser(
+        axiom_stax_builder_t * om_builder,
+        const axutil_env_t * env);
+
+    AXIS2_EXTERN void AXIS2_CALL
+    axiom_stax_builder_set_cache(
+        axiom_stax_builder_t * om_builder,
+        const axutil_env_t * env,
+        axis2_bool_t enable_cache);
+
+#endif
 
     /** @} */
 

Modified: axis/axis2/c/core/trunk/axiom/src/om/om_document.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/src/om/om_document.c?rev=926481&r1=926480&r2=926481&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/src/om/om_document.c (original)
+++ axis/axis2/c/core/trunk/axiom/src/om/om_document.c Tue Mar 23 07:10:27 2010
@@ -15,96 +15,72 @@
  * limitations under the License.
  */
 
-#include <axiom_document.h>
-#include <axiom_stax_builder.h>
+#include <axiom_document_internal.h>
+#include <axiom_stax_builder_internal.h>
 #include <axutil_string.h>
 
 struct axiom_document
 {
-
     /** root element */
     axiom_node_t *root_element;
 
     /** last child */
     axiom_node_t *last_child;
 
-    /** first child */
-    axiom_node_t *first_child;
-
-    /** done building the document */
-    axis2_bool_t done;
-
     /** builder of the document */
     struct axiom_stax_builder *builder;
 
-    /** char set encoding */
-    axis2_char_t *char_set_encoding;
-
-    /** XML version */
-    axis2_char_t *xml_version;
 };
 
-AXIS2_EXTERN axiom_document_t *AXIS2_CALL
+
+axiom_document_t *AXIS2_CALL
 axiom_document_create(
     const axutil_env_t * env,
     axiom_node_t * root,
     axiom_stax_builder_t * builder)
 {
     axiom_document_t *document = NULL;
-
-    AXIS2_ENV_CHECK(env, NULL);
-
     document = (axiom_document_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_document_t));
-
     if(!document)
     {
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Insufficient memory to create axiom document");
         return NULL;
     }
 
     document->builder = builder;
     document->root_element = root;
-    document->first_child = root;
     document->last_child = root;
-    document->xml_version = XML_VERSION;
-    document->char_set_encoding = CHAR_SET_ENCODING;
-    document->done = AXIS2_FALSE;
-
     return document;
 }
 
-AXIS2_EXTERN void AXIS2_CALL
+void AXIS2_CALL
 axiom_document_free(
     axiom_document_t * document,
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, void);
-
     if(document->root_element)
     {
         axiom_node_free_tree(document->root_element, env);
     }
     AXIS2_FREE(env->allocator, document);
-    return;
 }
 
-AXIS2_EXTERN void AXIS2_CALL
+void AXIS2_CALL
 axiom_document_free_self(
     axiom_document_t * document,
     const axutil_env_t * env)
 {
     AXIS2_FREE(env->allocator, document);
-    return;
 }
 
-AXIS2_EXTERN axiom_node_t *AXIS2_CALL
+axiom_node_t *AXIS2_CALL
 axiom_document_build_next(
     axiom_document_t * document,
     const axutil_env_t * env)
 {
     axiom_node_t *last_child = NULL;
 
-    AXIS2_ENV_CHECK(env, NULL);
 
     if(!document->builder)
     {
@@ -133,13 +109,33 @@ axiom_document_build_next(
     return last_child;
 }
 
+axis2_status_t AXIS2_CALL
+axiom_document_set_root_element(
+    axiom_document_t * document,
+    const axutil_env_t * env,
+    axiom_node_t * node)
+{
+    AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE);
+
+    if(document->root_element)
+    {
+        axiom_node_free_tree(document->root_element, env);
+        document->root_element = node;
+        return AXIS2_SUCCESS;
+    }
+    else
+    {
+        document->root_element = node;
+    }
+    return AXIS2_SUCCESS;
+}
+
 AXIS2_EXTERN axiom_node_t *AXIS2_CALL
 axiom_document_get_root_element(
     axiom_document_t * document,
     const axutil_env_t * env)
 {
     axiom_node_t *node = NULL;
-    AXIS2_ENV_CHECK(env, NULL);
 
     if(document->root_element)
     {
@@ -155,34 +151,11 @@ axiom_document_get_root_element(
     return NULL;
 }
 
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axiom_document_set_root_element(
-    axiom_document_t * document,
-    const axutil_env_t * env,
-    axiom_node_t * node)
-{
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE);
-
-    if(document->root_element)
-    {
-        axiom_node_free_tree(document->root_element, env);
-        document->root_element = node;
-        return AXIS2_SUCCESS;
-    }
-    else
-    {
-        document->root_element = node;
-    }
-    return AXIS2_SUCCESS;
-}
-
 AXIS2_EXTERN axiom_node_t *AXIS2_CALL
 axiom_document_build_all(
     struct axiom_document * document,
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
     if(!document)
     {
         return NULL;
@@ -220,12 +193,12 @@ axiom_document_build_all(
         return NULL;
 }
 
+#if 0
 AXIS2_EXTERN axiom_stax_builder_t *AXIS2_CALL
 axiom_document_get_builder(
     axiom_document_t * document,
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
     return document->builder;
 }
 
@@ -247,7 +220,6 @@ axiom_document_serialize(
     if(!document)
         return AXIS2_FAILURE;
 
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     if(!(document->root_element))
     {
         axiom_document_get_root_element(document, env);
@@ -261,3 +233,4 @@ axiom_document_serialize(
         return AXIS2_FAILURE;
     }
 }
+#endif

Modified: axis/axis2/c/core/trunk/axiom/src/om/om_element.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/src/om/om_element.c?rev=926481&r1=926480&r2=926481&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/src/om/om_element.c (original)
+++ axis/axis2/c/core/trunk/axiom/src/om/om_element.c Tue Mar 23 07:10:27 2010
@@ -1231,38 +1231,7 @@ axiom_element_get_child_elements(
     return NULL;
 }
 
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axiom_element_build(
-    axiom_element_t * om_element,
-    const axutil_env_t * env,
-    axiom_node_t * om_ele_node)
-{
-    axiom_stax_builder_t *builder = NULL;
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
-    AXIS2_PARAM_CHECK(env->error, om_ele_node, AXIS2_FAILURE);
-    if(axiom_node_get_node_type(om_ele_node, env) != AXIOM_ELEMENT)
-    {
-        return AXIS2_FAILURE;
-    }
-
-    builder = axiom_node_get_builder(om_ele_node, env);
-    if(!builder)
-    {
-        return AXIS2_FAILURE;
-    }
-    while(!axiom_node_is_complete(om_ele_node, env)
-        && !axiom_stax_builder_is_complete(builder, env))
-    {
-        void *value = NULL;
-        value = axiom_stax_builder_next(builder, env);
-        if(!value)
-        {
-            return AXIS2_FAILURE;
-        }
-    }
-    return AXIS2_SUCCESS;
-}
 
 AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL
 axiom_element_get_default_namespace(
@@ -1816,3 +1785,38 @@ axiom_element_redeclare_parent_namespace
         child_node = axiom_node_get_next_sibling(child_node, env);
     }
 }
+
+#if 0
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axiom_element_build(
+    axiom_element_t * om_element,
+    const axutil_env_t * env,
+    axiom_node_t * om_ele_node)
+{
+    axiom_stax_builder_t *builder = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+    AXIS2_PARAM_CHECK(env->error, om_ele_node, AXIS2_FAILURE);
+    if(axiom_node_get_node_type(om_ele_node, env) != AXIOM_ELEMENT)
+    {
+        return AXIS2_FAILURE;
+    }
+
+    builder = axiom_node_get_builder(om_ele_node, env);
+    if(!builder)
+    {
+        return AXIS2_FAILURE;
+    }
+    while(!axiom_node_is_complete(om_ele_node, env)
+        && !axiom_stax_builder_is_complete(builder, env))
+    {
+        void *value = NULL;
+        value = axiom_stax_builder_next(builder, env);
+        if(!value)
+        {
+            return AXIS2_FAILURE;
+        }
+    }
+    return AXIS2_SUCCESS;
+}
+#endif

Modified: axis/axis2/c/core/trunk/axiom/src/om/om_stax_builder.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/src/om/om_stax_builder.c?rev=926481&r1=926480&r2=926481&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/src/om/om_stax_builder.c (original)
+++ axis/axis2/c/core/trunk/axiom/src/om/om_stax_builder.c Tue Mar 23 07:10:27 2010
@@ -25,16 +25,17 @@
 #include <axiom_doctype.h>
 #include "axiom_node_internal.h"
 #include "axiom_stax_builder_internal.h"
+#include "axiom_document_internal.h"
 
 struct axiom_stax_builder
 {
-
     /** pull parser instance used by the om_builder */
     axiom_xml_reader_t *parser;
 
     /** last node the om_builder found */
     axiom_node_t *lastnode;
 
+    /** root node of the xml document */
     axiom_node_t *root_node;
 
     /** document associated with the om_builder */
@@ -43,16 +44,12 @@ struct axiom_stax_builder
     /** done building the document? */
     axis2_bool_t done;
 
-    /** parser was accessed? */
-    axis2_bool_t parser_accessed;
-
-    /** caching enabled? */
-    axis2_bool_t cache;
-
     /** current event */
     int current_event;
+
     /** Indicate the  current element level. */
     int element_level;
+
     axutil_hash_t *declared_namespaces;
 };
 
@@ -68,11 +65,10 @@ axiom_stax_builder_create(
     if(!om_builder)
     {
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Insufficient memory to create stax builder");
         return NULL;
     }
 
-    om_builder->cache = AXIS2_TRUE;
-    om_builder->parser_accessed = AXIS2_FALSE;
     om_builder->done = AXIS2_FALSE;
     om_builder->lastnode = NULL;
     om_builder->document = NULL;
@@ -91,6 +87,134 @@ axiom_stax_builder_create(
     return om_builder;
 }
 
+AXIS2_EXTERN void AXIS2_CALL
+axiom_stax_builder_free(
+    axiom_stax_builder_t * om_builder,
+    const axutil_env_t * env)
+{
+    if(!om_builder)
+    {
+        return;
+    }
+    if(om_builder->declared_namespaces)
+    {
+        axutil_hash_free(om_builder->declared_namespaces, env);
+        om_builder->declared_namespaces = NULL;
+    }
+
+    if(om_builder->document)
+    {
+        axiom_document_free(om_builder->document, env);
+        om_builder->document = NULL;
+    }
+    else
+    {
+        if(om_builder->root_node)
+        {
+            axiom_node_free_tree(om_builder->root_node, env);
+            om_builder->root_node = NULL;
+        }
+    }
+
+    if(om_builder->parser)
+    {
+        axiom_xml_reader_free(om_builder->parser, env);
+        om_builder->parser = NULL;
+    }
+
+    AXIS2_FREE(env->allocator, om_builder);
+
+    return;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axiom_stax_builder_free_self(
+    axiom_stax_builder_t * om_builder,
+    const axutil_env_t * env)
+{
+
+    axiom_node_t *temp_node = NULL;
+    axiom_node_t *nodes[256];
+    axiom_node_t *om_node = NULL;
+    int count = 0;
+
+    om_node = om_builder->root_node;
+
+    nodes[count++] = om_node;
+
+    if(om_node)
+    {
+        do
+        {
+
+            axiom_node_set_builder(om_node, env, NULL);
+            axiom_node_set_document(om_node, env, NULL);
+
+            temp_node = axiom_node_get_first_child(om_node, env);
+            /* serialize children of this node */
+            if(temp_node)
+            {
+                om_node = temp_node;
+                nodes[count++] = om_node;
+            }
+            else
+            {
+                temp_node = axiom_node_get_next_sibling(om_node, env);
+                if(temp_node)
+                {
+                    om_node = temp_node;
+                    nodes[count - 1] = om_node;
+                }
+                else
+                {
+                    while(count > 1 && !temp_node)
+                    {
+                        count--;
+                        om_node = nodes[count - 1];
+                        temp_node = axiom_node_get_next_sibling(om_node, env);
+                    }
+                    if(temp_node && count > 1)
+                    {
+                        om_node = temp_node;
+                        nodes[count - 1] = om_node;
+                    }
+                    else
+                    {
+                        count--;
+                    }
+                }
+            }
+        }
+        while(count > 0);
+    }
+    if(om_builder->declared_namespaces)
+    {
+        axutil_hash_free(om_builder->declared_namespaces, env);
+        om_builder->declared_namespaces = NULL;
+    }
+
+    if(om_builder->parser)
+    {
+        axiom_xml_reader_free(om_builder->parser, env);
+        om_builder->parser = NULL;
+    }
+    if(om_builder->document)
+    {
+        axiom_document_free_self(om_builder->document, env);
+        om_builder->document = NULL;
+    }
+    AXIS2_FREE(env->allocator, om_builder);
+    return;
+}
+
+AXIS2_EXTERN axiom_document_t *AXIS2_CALL
+axiom_stax_builder_get_document(
+    axiom_stax_builder_t * om_builder,
+    const axutil_env_t * env)
+{
+    return om_builder->document;
+}
+
 static axis2_status_t
 axiom_stax_builder_process_attributes(
     axiom_stax_builder_t * om_builder,
@@ -556,19 +680,14 @@ axiom_stax_builder_end_element(
     return AXIS2_SUCCESS;
 }
 
-AXIS2_EXTERN axiom_node_t *AXIS2_CALL
+axiom_node_t *AXIS2_CALL
 axiom_stax_builder_next(
     axiom_stax_builder_t * om_builder,
     const axutil_env_t * env)
 {
     int token = 0;
     axiom_node_t *node = NULL;
-    AXIS2_ENV_CHECK(env, NULL);
 
-    if(!om_builder->parser)
-    {
-        return NULL;
-    }
     do
     {
         if(om_builder->done)
@@ -585,11 +704,6 @@ axiom_stax_builder_next(
 
         om_builder->current_event = token;
 
-        if(!(om_builder->cache))
-        {
-            return NULL;
-        }
-
         switch(token)
         {
             case AXIOM_XML_READER_START_DOCUMENT:
@@ -649,134 +763,7 @@ axiom_stax_builder_next(
     return node;
 }
 
-AXIS2_EXTERN void AXIS2_CALL
-axiom_stax_builder_free(
-    axiom_stax_builder_t * om_builder,
-    const axutil_env_t * env)
-{
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    if(!om_builder)
-    {
-        return;
-    }
-    if(om_builder->declared_namespaces)
-    {
-        axutil_hash_free(om_builder->declared_namespaces, env);
-        om_builder->declared_namespaces = NULL;
-    }
-
-    if(om_builder->document)
-    {
-        axiom_document_free(om_builder->document, env);
-        om_builder->document = NULL;
-    }
-    else
-    {
-        if(om_builder->root_node)
-        {
-            axiom_node_free_tree(om_builder->root_node, env);
-            om_builder->root_node = NULL;
-        }
-    }
-
-    if(om_builder->parser)
-    {
-        axiom_xml_reader_free(om_builder->parser, env);
-        om_builder->parser = NULL;
-    }
-
-    AXIS2_FREE(env->allocator, om_builder);
-
-    return;
-}
-
-AXIS2_EXTERN void AXIS2_CALL
-axiom_stax_builder_free_self(
-    axiom_stax_builder_t * om_builder,
-    const axutil_env_t * env)
-{
-
-    axiom_node_t *temp_node = NULL;
-    axiom_node_t *nodes[256];
-    axiom_node_t *om_node = NULL;
-    int count = 0;
-
-    om_node = om_builder->root_node;
-
-    nodes[count++] = om_node;
-
-    if(om_node)
-    {
-        do
-        {
-
-            axiom_node_set_builder(om_node, env, NULL);
-            axiom_node_set_document(om_node, env, NULL);
 
-            temp_node = axiom_node_get_first_child(om_node, env);
-            /* serialize children of this node */
-            if(temp_node)
-            {
-                om_node = temp_node;
-                nodes[count++] = om_node;
-            }
-            else
-            {
-                temp_node = axiom_node_get_next_sibling(om_node, env);
-                if(temp_node)
-                {
-                    om_node = temp_node;
-                    nodes[count - 1] = om_node;
-                }
-                else
-                {
-                    while(count > 1 && !temp_node)
-                    {
-                        count--;
-                        om_node = nodes[count - 1];
-                        temp_node = axiom_node_get_next_sibling(om_node, env);
-                    }
-                    if(temp_node && count > 1)
-                    {
-                        om_node = temp_node;
-                        nodes[count - 1] = om_node;
-                    }
-                    else
-                    {
-                        count--;
-                    }
-                }
-            }
-        }
-        while(count > 0);
-    }
-    if(om_builder->declared_namespaces)
-    {
-        axutil_hash_free(om_builder->declared_namespaces, env);
-        om_builder->declared_namespaces = NULL;
-    }
-
-    if(om_builder->parser)
-    {
-        axiom_xml_reader_free(om_builder->parser, env);
-        om_builder->parser = NULL;
-    }
-    if(om_builder->document)
-    {
-        axiom_document_free_self(om_builder->document, env);
-        om_builder->document = NULL;
-    }
-    AXIS2_FREE(env->allocator, om_builder);
-    return;
-}
-
-AXIS2_EXTERN axiom_document_t *AXIS2_CALL
-axiom_stax_builder_get_document(
-    axiom_stax_builder_t * om_builder,
-    const axutil_env_t * env)
-{
-    return om_builder->document;
-}
 
 /**
   * moves the reader to next event and returns the token returned by the xml_reader ,
@@ -784,7 +771,7 @@ axiom_stax_builder_get_document(
   * @param environment Environment. MUST NOT be NULL.
   * @return next event axiom_xml_reader_event_types. Returns -1 on error
   */
-AXIS2_EXTERN int AXIS2_CALL
+int AXIS2_CALL
 axiom_stax_builder_next_with_token(
     axiom_stax_builder_t * om_builder,
     const axutil_env_t * env)
@@ -814,12 +801,6 @@ axiom_stax_builder_next_with_token(
         return -1;
     }
 
-    if(!om_builder->cache)
-    {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Caching disabled");
-        return -1;
-    }
-
     switch(token)
     {
         case AXIOM_XML_READER_START_DOCUMENT:
@@ -909,74 +890,10 @@ axiom_stax_builder_next_with_token(
     return token;
 }
 
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axiom_stax_builder_discard_current_element(
-    axiom_stax_builder_t * om_builder,
-    const axutil_env_t * env)
-{
-    axiom_node_t *element = NULL;
-    axiom_node_t *prev_node = NULL;
-    axiom_node_t *parent = NULL;
-
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
-    element = om_builder->lastnode;
-
-    if(axiom_node_is_complete(element, env) || !(om_builder->cache))
-    {
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_BUILDER_STATE_CANNOT_DISCARD,
AXIS2_FAILURE);
-        return AXIS2_FAILURE;
-    }
-
-    om_builder->cache = AXIS2_FALSE;
-    do
-    {
-        while(axiom_xml_reader_next(om_builder->parser, env) != AXIOM_XML_READER_END_ELEMENT)
-            ;
-    }
-    while(!(axiom_node_is_complete(element, env)));
-
-    /*All children of this element is pulled now */
-
-    prev_node = axiom_node_get_previous_sibling(element, env);
-    if(prev_node)
-    {
-        axiom_node_free_tree(axiom_node_get_next_sibling(prev_node, env), env);
-        axiom_node_set_next_sibling(prev_node, env, NULL);
-    }
-    else
-    {
-        parent = axiom_node_get_parent(element, env);
-        axiom_node_free_tree(axiom_node_get_first_child(parent, env), env);
-        axiom_node_set_first_child(parent, env, NULL);
-        om_builder->lastnode = parent;
-    }
-    om_builder->cache = AXIS2_TRUE;
-
-    return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL
-axiom_stax_builder_get_parser(
-    axiom_stax_builder_t * om_builder,
-    const axutil_env_t * env)
-{
-    return om_builder->parser;
-}
-
-AXIS2_EXTERN void AXIS2_CALL
-axiom_stax_builder_set_cache(
-    axiom_stax_builder_t * om_builder,
-    const axutil_env_t * env,
-    axis2_bool_t enable_cache)
-{
-    om_builder->cache = enable_cache;
-}
-
 /**
  internal function for soap om_builder only
  */
-AXIS2_EXTERN int AXIS2_CALL
+int AXIS2_CALL
 axiom_stax_builder_get_current_event(
     axiom_stax_builder_t * om_builder,
     const axutil_env_t * env)
@@ -987,7 +904,7 @@ axiom_stax_builder_get_current_event(
 /**
  internal function for soap om_builder only
  */
-AXIS2_EXTERN axiom_node_t *AXIS2_CALL
+axiom_node_t *AXIS2_CALL
 axiom_stax_builder_get_lastnode(
     axiom_stax_builder_t * om_builder,
     const axutil_env_t * env)
@@ -998,7 +915,7 @@ axiom_stax_builder_get_lastnode(
 /**
  internal function for soap om_builder only
  */
-AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_bool_t AXIS2_CALL
 axiom_stax_builder_is_complete(
     axiom_stax_builder_t * om_builder,
     const axutil_env_t * env)
@@ -1009,7 +926,7 @@ axiom_stax_builder_is_complete(
 /**
  internal function for soap om_builder only
  */
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_status_t AXIS2_CALL
 axiom_stax_builder_set_lastnode(
     axiom_stax_builder_t * om_builder,
     const axutil_env_t * env,
@@ -1022,7 +939,7 @@ axiom_stax_builder_set_lastnode(
 /**
  internal function for soap om_builder only
  */
-AXIS2_EXTERN int AXIS2_CALL
+int AXIS2_CALL
 axiom_stax_builder_get_element_level(
     axiom_stax_builder_t * om_builder,
     const axutil_env_t * env)
@@ -1033,7 +950,7 @@ axiom_stax_builder_get_element_level(
 /**
  internal function for soap om_builder only
  */
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_status_t AXIS2_CALL
 axiom_stax_builder_set_element_level(
     axiom_stax_builder_t * om_builder,
     const axutil_env_t * env,
@@ -1069,4 +986,68 @@ axiom_stax_builder_create_om_doctype(
     axiom_xml_reader_xml_free(om_builder->parser, env, doc_value);
     return doctype_node;
 }
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axiom_stax_builder_discard_current_element(
+    axiom_stax_builder_t * om_builder,
+    const axutil_env_t * env)
+{
+    axiom_node_t *element = NULL;
+    axiom_node_t *prev_node = NULL;
+    axiom_node_t *parent = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+    element = om_builder->lastnode;
+
+    if(axiom_node_is_complete(element, env) || !(om_builder->cache))
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_BUILDER_STATE_CANNOT_DISCARD,
AXIS2_FAILURE);
+        return AXIS2_FAILURE;
+    }
+
+    om_builder->cache = AXIS2_FALSE;
+    do
+    {
+        while(axiom_xml_reader_next(om_builder->parser, env) != AXIOM_XML_READER_END_ELEMENT)
+            ;
+    }
+    while(!(axiom_node_is_complete(element, env)));
+
+    /*All children of this element is pulled now */
+
+    prev_node = axiom_node_get_previous_sibling(element, env);
+    if(prev_node)
+    {
+        axiom_node_free_tree(axiom_node_get_next_sibling(prev_node, env), env);
+        axiom_node_set_next_sibling(prev_node, env, NULL);
+    }
+    else
+    {
+        parent = axiom_node_get_parent(element, env);
+        axiom_node_free_tree(axiom_node_get_first_child(parent, env), env);
+        axiom_node_set_first_child(parent, env, NULL);
+        om_builder->lastnode = parent;
+    }
+    om_builder->cache = AXIS2_TRUE;
+
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL
+axiom_stax_builder_get_parser(
+    axiom_stax_builder_t * om_builder,
+    const axutil_env_t * env)
+{
+    return om_builder->parser;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axiom_stax_builder_set_cache(
+    axiom_stax_builder_t * om_builder,
+    const axutil_env_t * env,
+    axis2_bool_t enable_cache)
+{
+    om_builder->cache = enable_cache;
+}
 #endif



Mime
View raw message