You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2005/10/03 10:16:20 UTC
svn commit: r293275 - in /webservices/axis2/trunk/c:
include/axis2_om_element.h include/axis2_om_output.h
modules/xml/om/src/axis2_om_element.c modules/xml/om/src/axis2_om_output.c
Author: samisa
Date: Mon Oct 3 01:16:09 2005
New Revision: 293275
URL: http://svn.apache.org/viewcvs?rev=293275&view=rev
Log:
Added the output struct and seriaizing logic
Added:
webservices/axis2/trunk/c/include/axis2_om_output.h
webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_output.c
Modified:
webservices/axis2/trunk/c/include/axis2_om_element.h
webservices/axis2/trunk/c/modules/xml/om/src/axis2_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=293275&r1=293274&r2=293275&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_om_element.h (original)
+++ webservices/axis2/trunk/c/include/axis2_om_element.h Mon Oct 3 01:16:09 2005
@@ -19,6 +19,7 @@
#include <axis2_om_namespace.h>
#include <axis2_om_attribute.h>
+#include <axis2_om_output.h>
#include <axis2_node.h>
#include <apr.h>
#include <apr_hash.h>
@@ -133,6 +134,8 @@
*/
char *axis2_om_element_get_localname(axis2_node_t *element_node);
+int axis2_om_element_serialize_start_part(axis2_om_element_t *element_node, axis2_om_output_t* om_output);
+int axis2_om_element_serialize_end_part(axis2_om_element_t *element_node, axis2_om_output_t* om_output);
#endif // AXIS2_OM_ELEMENT_H
Added: webservices/axis2/trunk/c/include/axis2_om_output.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_om_output.h?rev=293275&view=auto
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_om_output.h (added)
+++ webservices/axis2/trunk/c/include/axis2_om_output.h Mon Oct 3 01:16:09 2005
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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 AXIS2_OM_OUTPUT_H
+#define AXIS2_OM_OUTPUT_H
+
+#include <guththila_xml_stream_writer.h>
+#include <axis2_node.h>
+
+#include <stdarg.h>
+
+static const char* DEFAULT_CHAR_SET_ENCODING = "utf-8";
+
+typedef struct {
+ guththila_xml_stream_writer_t* xml_writer;
+ int do_optimize;
+ FILE* out_stream;
+ //apr_array_t binary_node_list;
+ //buffered_soap_out_stream;
+ char* mime_boundary;
+ char* root_content_id;
+ int next_id;
+ int is_soap_11;
+ char* char_set_encoding;
+ char* xml_version;
+ int ignore_xml_declaration;
+} axis2_om_output_t;
+
+axis2_om_output_t* axis2_create_om_output( FILE* stream);
+
+int axis2_om_output_write(axis2_om_output_t* om_output, axis2_om_types_t type, int no_of_args, ... );
+
+#endif // AXIS2_OM_OUTPUT_H
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=293275&r1=293274&r2=293275&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 Mon Oct 3 01:16:09 2005
@@ -22,136 +22,145 @@
static apr_pool_t *om_pool;
-axis2_node_t *axis2_om_element_create(const char *localname,axis2_om_namespace_t * ns
- ,axis2_node_t *parent)
+axis2_node_t *
+axis2_om_element_create (const char *localname, axis2_om_namespace_t * ns,
+ axis2_node_t * parent)
{
- axis2_node_t *node;
- axis2_om_element_t *element;
- if(!localname)
- {
- fprintf(stderr,"Localname can't be null");
- return NULL;
- }
+ axis2_node_t *node;
+ axis2_om_element_t *element;
+ if (!localname)
+ {
+ fprintf (stderr, "Localname can't be null");
+ return NULL;
+ }
- node = axis2_node_create();
+ node = axis2_node_create ();
if (!node)
{
- fprintf(stderr,"%d Error",AXIS2_ERROR_OM_MEMORY_ALLOCATION);
- return NULL;
- }
- element = (axis2_om_element_t *) malloc(sizeof(axis2_om_element_t));
-
- if(!element)
- {
- axis2_node_free(node);
- return NULL;
- }
- element->ns = NULL;
- element->localname = strdup(localname);
- element->pns_counter = 0;
- element->attributes = NULL;
- element->namespaces = NULL;
-
- if(parent)
- {
- node->parent = parent;
- axis2_node_add_child(parent,node);
- }
- node->done = true;
- node->element_type = AXIS2_OM_ELEMENT;
- node->data_element = element;
- axis2_om_element_set_namespace(node,ns);
+ fprintf (stderr, "%d Error", AXIS2_ERROR_OM_MEMORY_ALLOCATION);
+ return NULL;
+ }
+ element = (axis2_om_element_t *) malloc (sizeof (axis2_om_element_t));
+
+ if (!element)
+ {
+ axis2_node_free (node);
+ return NULL;
+ }
+ element->ns = NULL;
+ element->localname = strdup (localname);
+ element->pns_counter = 0;
+ element->attributes = NULL;
+ element->namespaces = NULL;
+
+ if (parent)
+ {
+ node->parent = parent;
+ axis2_node_add_child (parent, node);
+ }
+ node->done = true;
+ node->element_type = AXIS2_OM_ELEMENT;
+ node->data_element = element;
+ axis2_om_element_set_namespace (node, ns);
+
+ return node;
- return node;
-
}
/* create an om_element using qname and parent */
-axis2_node_t *axis2_om_element_create_with_qname(axis2_qname_t *qname
- ,axis2_node_t *parent)
+axis2_node_t *
+axis2_om_element_create_with_qname (axis2_qname_t * qname,
+ axis2_node_t * parent)
{
axis2_node_t *node = NULL;;
if (!qname)
{
- return NULL; /* can't create an element */
+ return NULL; /* can't create an element */
}
- node = axis2_om_element_create(qname->localpart, NULL,parent);
+ node = axis2_om_element_create (qname->localpart, NULL, parent);
if (node)
{
- ((axis2_om_element_t *) (node->data_element))->ns =
- axis2_om_element_handle_namespace_with_qname(node,qname);
+ ((axis2_om_element_t *) (node->data_element))->ns =
+ axis2_om_element_handle_namespace_with_qname (node, qname);
}
return node;
}
-axis2_node_t *axis2_om_element_create_with_builder(const char *localname,axis2_om_namespace_t *ns
- ,axis2_node_t *parent,axis2_stax_om_builder_t *builder)
-{ axis2_node_t *node;
- axis2_om_element_t *element;
- if(!localname)
- {
- fprintf(stderr,"Localname can't be null");
- return NULL;
- }
+axis2_node_t *
+axis2_om_element_create_with_builder (const char *localname,
+ axis2_om_namespace_t * ns,
+ axis2_node_t * parent,
+ axis2_stax_om_builder_t * builder)
+{
+ axis2_node_t *node;
+ axis2_om_element_t *element;
+ if (!localname)
+ {
+ fprintf (stderr, "Localname can't be null");
+ return NULL;
+ }
- node = axis2_node_create();
+ node = axis2_node_create ();
if (!node)
{
- fprintf(stderr,"%d Error",AXIS2_ERROR_OM_MEMORY_ALLOCATION);
- return NULL;
- }
- element = (axis2_om_element_t *) malloc(sizeof(axis2_om_element_t));
-
- if(!element)
- {
- axis2_node_free(node);
- return NULL;
- }
- element->localname = strdup(localname);
- element->attributes = NULL;
- element->pns_counter = 0;
- element->namespaces = NULL;
- element->ns = NULL;
-
- node->builder = builder;
- node->data_element = element;
- node->done = false;
- node->element_type = AXIS2_OM_ELEMENT;
-
- if(parent)
- {
- node->parent = parent;
- axis2_node_add_child(parent,node);
- }
- axis2_om_element_set_namespace(node,ns);
- return node;
-}
-
-axis2_om_namespace_t *axis2_om_element_find_namespace(axis2_node_t
- *element_node,const char *uri,const char *prefix)
-{
- axis2_om_namespace_t *ns = NULL;
-
- if (!element_node)
- {
- return NULL;
+ fprintf (stderr, "%d Error", AXIS2_ERROR_OM_MEMORY_ALLOCATION);
+ return NULL;
}
- if (!(element_node->data_element) || element_node->element_type !=AXIS2_OM_ELEMENT)
+ element = (axis2_om_element_t *) malloc (sizeof (axis2_om_element_t));
+
+ if (!element)
{
- /* wrong element type or null node */
- return NULL;
+ axis2_node_free (node);
+ return NULL;
}
-
- ns = axis2_om_element_find_declared_namespace(element_node, uri,prefix);
+ element->localname = strdup (localname);
+ element->attributes = NULL;
+ element->pns_counter = 0;
+ element->namespaces = NULL;
+ element->ns = NULL;
+
+ node->builder = builder;
+ node->data_element = element;
+ node->done = false;
+ node->element_type = AXIS2_OM_ELEMENT;
+
+ if (parent)
+ {
+ node->parent = parent;
+ axis2_node_add_child (parent, node);
+ }
+ axis2_om_element_set_namespace (node, ns);
+ return node;
+}
+
+axis2_om_namespace_t *
+axis2_om_element_find_namespace (axis2_node_t
+ * element_node, const char *uri,
+ const char *prefix)
+{
+ axis2_om_namespace_t *ns = NULL;
+
+ if (!element_node)
+ {
+ return NULL;
+ }
+ if (!(element_node->data_element)
+ || element_node->element_type != AXIS2_OM_ELEMENT)
+ {
+ /* wrong element type or null node */
+ return NULL;
+ }
+
+ ns = axis2_om_element_find_declared_namespace (element_node, uri, prefix);
if (!ns)
{
- return ns;
+ return ns;
}
- if ((element_node->parent != NULL) &&
- (element_node->parent->element_type ==AXIS2_OM_ELEMENT))
+ if ((element_node->parent != NULL) &&
+ (element_node->parent->element_type == AXIS2_OM_ELEMENT))
{
- axis2_om_element_find_namespace(element_node->parent, uri, prefix);
+ axis2_om_element_find_namespace (element_node->parent, uri, prefix);
}
return NULL;
}
@@ -159,43 +168,47 @@
/* declare a namespace for this om element */
-axis2_om_namespace_t *axis2_om_element_declare_namespace(axis2_node_t *
- element_node,axis2_om_namespace_t *ns)
+axis2_om_namespace_t *
+axis2_om_element_declare_namespace (axis2_node_t *
+ element_node, axis2_om_namespace_t * ns)
{
apr_status_t status;
axis2_om_element_t *element = NULL;
if (!element_node || !ns || !element_node->data_element
- || element_node->element_type != AXIS2_OM_ELEMENT)
+ || element_node->element_type != AXIS2_OM_ELEMENT)
{
- return NULL;
+ return NULL;
}
-
+
element = (axis2_om_element_t *) (element_node->data_element);
-
- if (!element->namespaces)
+
+ if (!element->namespaces)
{
- if (!om_pool)
- {
- status = apr_pool_create(&om_pool, NULL);
- }
-
- element->namespaces = apr_hash_make(om_pool);
+ if (!om_pool)
+ {
+ status = apr_pool_create (&om_pool, NULL);
+ }
+
+ element->namespaces = apr_hash_make (om_pool);
}
- apr_hash_set(element->namespaces, ns->prefix, APR_HASH_KEY_STRING, ns);
-
- return ns;
+ apr_hash_set (element->namespaces, ns->prefix, APR_HASH_KEY_STRING, ns);
+
+ return ns;
}
-axis2_om_namespace_t *axis2_om_element_declare_namespace_with_ns_uri_prefix(
- axis2_node_t *element_node,const char *uri,const char *prefix)
+axis2_om_namespace_t *
+axis2_om_element_declare_namespace_with_ns_uri_prefix (axis2_node_t *
+ element_node,
+ const char *uri,
+ const char *prefix)
{
axis2_om_namespace_t *nsp = NULL;
- nsp = axis2_om_namespace_create(uri, prefix);
+ nsp = axis2_om_namespace_create (uri, prefix);
if (nsp)
- {
- return axis2_om_element_declare_namespace(element_node, nsp);
+ {
+ return axis2_om_element_declare_namespace (element_node, nsp);
}
return NULL;
}
@@ -205,32 +218,34 @@
* can be used to retrive a prefix of a known namespace uri
*
*/
-axis2_om_namespace_t *axis2_om_element_find_declared_namespace(
- axis2_node_t *element_node,const char *uri,const char *prefix)
+axis2_om_namespace_t *
+axis2_om_element_find_declared_namespace (axis2_node_t * element_node,
+ const char *uri, const char *prefix)
{
void *ns = NULL;
apr_hash_index_t *hashindex;
axis2_om_element_t *element = NULL;
-
- if (!element_node || !ns || element_node->element_type != AXIS2_OM_ELEMENT)
+
+ if (!element_node || !ns
+ || element_node->element_type != AXIS2_OM_ELEMENT)
{
- return NULL;
+ return NULL;
}
element = (axis2_om_element_t *) (element_node->data_element);
- if (!prefix || strcmp(prefix, "") == 0)
+ if (!prefix || strcmp (prefix, "") == 0)
{
- for(hashindex = apr_hash_first(om_pool,element->namespaces);
- hashindex;hashindex = apr_hash_next(hashindex))
- {
- apr_hash_this(hashindex,NULL,NULL,&ns);
- if(strcmp(((axis2_om_namespace_t*)(ns))->uri,uri))
- {
- return (axis2_om_namespace_t*)(ns);
- }
- }
+ for (hashindex = apr_hash_first (om_pool, element->namespaces);
+ hashindex; hashindex = apr_hash_next (hashindex))
+ {
+ apr_hash_this (hashindex, NULL, NULL, &ns);
+ if (strcmp (((axis2_om_namespace_t *) (ns))->uri, uri))
+ {
+ return (axis2_om_namespace_t *) (ns);
+ }
+ }
}
- ns = apr_hash_get(element->namespaces, prefix, APR_HASH_KEY_STRING);
+ ns = apr_hash_get (element->namespaces, prefix, APR_HASH_KEY_STRING);
return (axis2_om_namespace_t *) ns;
}
@@ -242,178 +257,221 @@
-static axis2_om_namespace_t *axis2_om_element_handle_namespace_with_qname(
- axis2_node_t *element_node,axis2_qname_t * qname)
+static axis2_om_namespace_t *
+axis2_om_element_handle_namespace_with_qname (axis2_node_t * element_node,
+ axis2_qname_t * qname)
{
axis2_om_namespace_t *pns = NULL;
char *ns_uri = qname->ns_uri;
if (ns_uri != NULL)
{
- pns = axis2_om_element_find_namespace(element_node, ns_uri,qname->prefix);
- /**
+ pns =
+ axis2_om_element_find_namespace (element_node, ns_uri,
+ qname->prefix);
+ /**
* What is left now is
* 1. nsURI = null & parent != null, but ns = null
* 2. nsURI != null, (parent doesn't have an ns with given URI), but ns = null
*/
- if (pns == NULL)
- {
- if (qname->prefix)
- {
- pns = axis2_om_element_declare_namespace_with_ns_uri_prefix(
- element_node, ns_uri, qname->prefix);
- }
- }
+ if (pns == NULL)
+ {
+ if (qname->prefix)
+ {
+ pns =
+ axis2_om_element_declare_namespace_with_ns_uri_prefix
+ (element_node, ns_uri, qname->prefix);
+ }
+ }
}
return NULL;
}
-static axis2_om_namespace_t *axis2_om_element_handle_namespace(axis2_node_t
- *element_node,axis2_om_namespace_t *ns)
+static axis2_om_namespace_t *
+axis2_om_element_handle_namespace (axis2_node_t
+ * element_node, axis2_om_namespace_t * ns)
{
axis2_om_namespace_t *ns1 = NULL;
if (!ns || !element_node)
{
- return NULL;
+ return NULL;
+ }
+ ns1 = axis2_om_element_find_namespace (element_node, ns->uri, ns->prefix);
+
+ if (!ns1)
+ {
+ ns1 = axis2_om_element_declare_namespace (element_node, ns);
}
- ns1 = axis2_om_element_find_namespace(element_node,ns->uri,ns->prefix);
-
- if(!ns1)
- {
- ns1 = axis2_om_element_declare_namespace(element_node,ns);
- }
- return ns1;
+ return ns1;
}
-axis2_om_attribute_t *axis2_om_element_add_attribute(axis2_node_t *element_node,
- axis2_om_attribute_t *attr)
+axis2_om_attribute_t *
+axis2_om_element_add_attribute (axis2_node_t * element_node,
+ axis2_om_attribute_t * attr)
{
apr_status_t status;
axis2_qname_t *qname = NULL;
axis2_om_element_t *element = NULL;
-
- if (!element_node || element_node->element_type !=AXIS2_OM_ELEMENT)
+
+ if (!element_node || element_node->element_type != AXIS2_OM_ELEMENT)
{
- return NULL;
+ return NULL;
}
- element = (axis2_om_element_t *)(element_node->data_element);
+ element = (axis2_om_element_t *) (element_node->data_element);
if (!(element->attributes))
{
- if (!om_pool)
- {
- status = apr_pool_create(&om_pool, NULL);
- }
- element->attributes = apr_hash_make(om_pool);
+ if (!om_pool)
+ {
+ status = apr_pool_create (&om_pool, NULL);
+ }
+ element->attributes = apr_hash_make (om_pool);
}
- qname = axis2_om_attribute_get_qname(attr);
-
- apr_hash_set(element->attributes, qname,sizeof(axis2_qname_t), attr);
+ qname = axis2_om_attribute_get_qname (attr);
+
+ apr_hash_set (element->attributes, qname, sizeof (axis2_qname_t), attr);
return attr;
}
-axis2_om_attribute_t *axis2_om_element_get_attribute(axis2_node_t *element_node,
- axis2_qname_t *qname)
+axis2_om_attribute_t *
+axis2_om_element_get_attribute (axis2_node_t * element_node,
+ axis2_qname_t * qname)
{
char *key = NULL;
axis2_om_element_t *element = NULL;
- if (!element_node || !qname
- || element_node->element_type != AXIS2_OM_ELEMENT)
+ if (!element_node || !qname
+ || element_node->element_type != AXIS2_OM_ELEMENT)
{
- return NULL;
+ return NULL;
}
element = (axis2_om_element_t *) (element_node->data_element);
-
- return (axis2_om_attribute_t *) (apr_hash_get(element->attributes, qname
- ,sizeof(axis2_qname_t)));
+
+ return (axis2_om_attribute_t
+ *) (apr_hash_get (element->attributes, qname,
+ sizeof (axis2_qname_t)));
}
/*
* The node passed to the method should have the data element as of type OM_ELEMENT
*/
-axis2_om_attribute_t *axis2_om_element_add_attribute_with_namespace(
- axis2_node_t *element_node,const char *attribute_name,const char *value,
- axis2_om_namespace_t *ns)
+axis2_om_attribute_t *
+axis2_om_element_add_attribute_with_namespace (axis2_node_t * element_node,
+ const char *attribute_name,
+ const char *value,
+ axis2_om_namespace_t * ns)
{
- axis2_om_namespace_t *namespace1= NULL;
- if (!element_node || element_node->element_type != AXIS2_OM_ELEMENT)
+ axis2_om_namespace_t *namespace1 = NULL;
+ if (!element_node || element_node->element_type != AXIS2_OM_ELEMENT)
{
- return NULL;
+ return NULL;
}
if (ns)
{
- namespace1 = axis2_om_element_find_namespace(element_node, ns->uri,
- ns->prefix);
- if (namespace1 == NULL)
- {
- return NULL;
- }
- }
- return axis2_om_element_add_attribute(element_node,
- axis2_om_attribute_create(attribute_name, value, ns));
+ namespace1 = axis2_om_element_find_namespace (element_node, ns->uri,
+ ns->prefix);
+ if (namespace1 == NULL)
+ {
+ return NULL;
+ }
+ }
+ return axis2_om_element_add_attribute (element_node,
+ axis2_om_attribute_create
+ (attribute_name, value, ns));
}
-void axis2_om_element_set_namespace(axis2_node_t * node,axis2_om_namespace_t *ns)
+void
+axis2_om_element_set_namespace (axis2_node_t * node,
+ axis2_om_namespace_t * ns)
{
axis2_om_namespace_t *nsp = NULL;
if (ns && node && (node->data_element))
{
- nsp = axis2_om_element_handle_namespace(node, ns);
+ nsp = axis2_om_element_handle_namespace (node, ns);
}
- ((axis2_om_element_t *)( node->data_element))->ns = nsp;
- nsp = NULL;
+ ((axis2_om_element_t *) (node->data_element))->ns = nsp;
+ nsp = NULL;
}
-void axis2_free_om_element(axis2_om_element_t * element)
+void
+axis2_free_om_element (axis2_om_element_t * element)
{
if (element)
{
- if (element->localname)
- {
- free(element->localname);
- }
- if (element->ns)
- {
- axis2_om_namespace_free(element->ns);
- }
- if (element->attributes)
- {
-
- }
- if (element->namespaces)
- {
-
- }
- free(element);
+ if (element->localname)
+ {
+ free (element->localname);
+ }
+ if (element->ns)
+ {
+ axis2_om_namespace_free (element->ns);
+ }
+ if (element->attributes)
+ {
+
+ }
+ if (element->namespaces)
+ {
+
+ }
+ free (element);
}
}
-void axis2_om_element_set_localname(axis2_node_t * element_node,const char *localname)
+void
+axis2_om_element_set_localname (axis2_node_t * element_node,
+ const char *localname)
{
axis2_om_element_t *element = NULL;
- if (!element_node || element_node->element_type !=AXIS2_OM_ELEMENT)
+ if (!element_node || element_node->element_type != AXIS2_OM_ELEMENT)
{
- return;
+ return;
}
element = (axis2_om_element_t *) (element_node->data_element);
-
- if (element->localname)
+
+ if (element->localname)
{
- free(element->localname);
+ free (element->localname);
}
- element->localname = strdup(localname);
+ element->localname = strdup (localname);
}
-char *axis2_om_element_get_localname(axis2_node_t * element_node)
+char *
+axis2_om_element_get_localname (axis2_node_t * element_node)
{
- if (!element_node || element_node->element_type !=AXIS2_OM_ELEMENT)
+ if (!element_node || element_node->element_type != AXIS2_OM_ELEMENT)
{
- return NULL;
+ return NULL;
}
return ((axis2_om_element_t *) (element_node->data_element))->localname;
+}
+
+int
+axis2_om_element_serialize_start_part (axis2_om_element_t * element_node,
+ axis2_om_output_t * om_output)
+{
+ if (element_node->ns && element_node->ns->prefix)
+ axis2_om_output_write (om_output, AXIS2_OM_ELEMENT, 3,
+ element_node->localname, element_node->ns->uri,
+ element_node->ns->prefix);
+ else if (element_node->ns)
+ axis2_om_output_write (om_output, AXIS2_OM_ELEMENT, 2,
+ element_node->localname,
+ element_node->ns->uri);
+ else
+ axis2_om_output_write (om_output, AXIS2_OM_ELEMENT, 1,
+ element_node->localname);
+
+
+}
+
+int
+axis2_om_element_serialize_end_part (axis2_om_element_t * element_node,
+ axis2_om_output_t * om_output)
+{
+
}
Added: 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=293275&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_output.c (added)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_output.c Mon Oct 3 01:16:09 2005
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+#include <axis2_om_output.h>
+
+
+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));
+
+ 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->do_optimize = 0;
+ om_output->mime_boundary = 0;
+ om_output->root_content_id = 0;
+ om_output->next_id = 0;
+ om_output->is_soap_11 = 1;
+ om_output->char_set_encoding = 0;
+ om_output->xml_version = 0;
+ om_output->ignore_xml_declaration = 0;
+
+ return om_output;
+}
+
+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 i = 0;
+ va_list ap;
+
+ switch (type)
+ {
+ 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 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] );
+ 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;
+ }
+ break;
+
+ case AXIS2_OM_ATTRIBUTE:
+
+ /*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;
+ };
+
+ return 1;
+}