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 sa...@apache.org on 2005/09/27 10:03:31 UTC
svn commit: r291854 - /webservices/axis2/trunk/c/modules/xml/om/src/
Author: samisa
Date: Tue Sep 27 01:03:18 2005
New Revision: 291854
URL: http://svn.apache.org/viewcvs?rev=291854&view=rev
Log:
Added the files with correct naming convention
Added:
webservices/axis2/trunk/c/modules/xml/om/src/axis2c_node.c
webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_attribute.c
webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_comment.c
webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_doctype.c
webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_document.c
webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_element.c
webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_processing_instruction.c
webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_text.c
webservices/axis2/trunk/c/modules/xml/om/src/axis2c_qname.c
webservices/axis2/trunk/c/modules/xml/om/src/axis2c_stax_ombuilder.c
Modified:
webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_namespace.c
Added: webservices/axis2/trunk/c/modules/xml/om/src/axis2c_node.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2c_node.c?rev=291854&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2c_node.c (added)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2c_node.c Tue Sep 27 01:03:18 2005
@@ -0,0 +1,105 @@
+/*
+ * 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 <axis2c_node.h>
+
+node_t *axis2c_create_node()
+{
+ node_t *node = (node_t *) malloc(sizeof(node_t));
+ if (!node)
+ {
+ return NULL;
+ }
+ node->first_child = NULL;
+ node->last_child = NULL;
+ node->next_sibling = NULL;
+ node->prev_sibling = NULL;
+ node->parent = NULL;
+ node->element_type = 0;
+ node->done = FALSE;
+ node->builder = NULL;
+ node->data_element = NULL;
+ return node;
+}
+
+
+void axis2c_free_node(node_t * node)
+{
+ if (!node)
+ return;
+ //if(node->
+}
+
+void axis2c_node_add_child(node_t * parent, node_t * child)
+{
+ if (!parent || !child)
+ return;
+ if (parent->first_child == NULL)
+ {
+ parent->first_child = child;
+ }
+ else
+ {
+ parent->last_child->next_sibling = child;
+ child->prev_sibling = parent->last_child;
+ }
+ child->parent = parent;
+ parent->last_child = child;
+}
+
+
+
+node_t *axis2c_detach_node(node_t * node_to_detach)
+{
+ node_t *parent = NULL;
+ node_t *next_sibling = NULL;
+ if (!node_to_detach)
+ {
+ return NULL;
+ }
+
+ if (!(node_to_detach->parent))
+ {
+ /* nodes that do not have a parent can't be detached
+ */
+ return NULL;
+ }
+ parent = node_to_detach->parent;
+ if ((node_to_detach->prev_sibling) == NULL)
+ {
+ parent->first_child = node_to_detach->next_sibling;
+ }
+ else
+ {
+ node_to_detach->prev_sibling->next_sibling =
+ node_to_detach->next_sibling;
+ }
+ if (!(node_to_detach->next_sibling))
+ {
+ node_to_detach->next_sibling->prev_sibling =
+ node_to_detach->prev_sibling;
+ }
+
+ node_to_detach->parent = NULL;
+
+ return node_to_detach;
+
+}
+
+void axis2c_node_set_parent(node_t * node)
+{
+
+}
Added: webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_attribute.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_attribute.c?rev=291854&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_attribute.c (added)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_attribute.c Tue Sep 27 01:03:18 2005
@@ -0,0 +1,74 @@
+/*
+ * 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 <axis2c_om_attribute.h>
+#include <string.h>
+
+
+om_attribute_t *axis2c_create_om_attribute(const char *localname,
+ const char *value,
+ om_namespace_t * ns)
+{
+ om_attribute_t *attr =
+ (om_attribute_t *) malloc(sizeof(om_attribute_t));
+ if (!attr)
+ {
+
+ return NULL;
+ }
+
+ attr->localname = strdup(localname);
+ attr->value = strdup(value);
+ attr->ns = ns;
+ return attr;
+}
+
+void axis2c_om_attribute_free(om_attribute_t * attr)
+{
+ if (attr)
+ {
+ free(attr->localname);
+ free(attr->value);
+ /* should namespace pointer be ...
+ */
+
+ }
+
+}
+
+qname_t *axis2c_om_attribute_get_qname(om_attribute_t * attr)
+{
+ qname_t *qn = NULL;
+ if (attr)
+ {
+ if (attr->ns)
+ {
+ qn = axis2c_create_qname(attr->localname, attr->ns->uri,
+ attr->ns->prefix);
+ }
+ else
+ {
+ qn = axis2c_create_qname(attr->localname, NULL, NULL);
+ }
+ return qn;
+ }
+ return NULL;
+
+}
Added: webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_comment.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_comment.c?rev=291854&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_comment.c (added)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_comment.c Tue Sep 27 01:03:18 2005
@@ -0,0 +1,91 @@
+/*
+ * 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 <axis2c_om_comment.h>
+#include <string.h>
+#include <axis2c_errno.h>
+
+node_t *axis2c_create_om_comment(const char *value)
+{
+ node_t *node = NULL;
+ om_comment_t *comment = NULL;
+
+ node = axis2c_create_node();
+ if (!node)
+ {
+ fprintf(stderr, "%d Error", AXIS2C_ERROR_OM_MEMORY_ALLOCATION);
+ return NULL;
+ }
+ comment = (om_comment_t *) malloc(sizeof(om_comment_t));
+ if (!comment)
+ {
+ free(node);
+ fprintf(stderr, "%d Error", AXIS2C_ERROR_OM_MEMORY_ALLOCATION);
+ return NULL;
+
+ }
+ comment->value = strdup(value);
+ if (!comment->value)
+ {
+ fprintf(stderr, "%d Error", AXIS2C_ERROR_OM_MEMORY_ALLOCATION);
+ }
+
+ node->data_element = comment;
+ node->element_type = OM_COMMENT;
+ return node;
+}
+
+
+void axis2c_om_comment_free(om_comment_t * comment)
+{
+ if (comment)
+ {
+ if (comment->value)
+ free(comment->value);
+ free(comment);
+ }
+}
+
+/*
+* returns a duplicated string as value
+*
+*/
+
+char *axis2c_om_comment_get_value(node_t * comment_node)
+{
+ if (!comment_node || comment_node->element_type != OM_COMMENT)
+ {
+ return NULL;
+ }
+ return strdup(((om_comment_t *) (comment_node->data_element))->value);
+}
+
+void axis2c_om_comment_set_value(node_t * comment_node, const char *value)
+{
+ om_comment_t *comm = NULL;
+
+ if (!comment_node || comment_node->element_type != OM_COMMENT)
+ {
+ return;
+ }
+ comm = ((om_comment_t *) (comment_node->data_element));
+
+ if (comm->value)
+ {
+ free(comm->value);
+ }
+ comm->value = strdup(value);
+}
Added: webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_doctype.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_doctype.c?rev=291854&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_doctype.c (added)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_doctype.c Tue Sep 27 01:03:18 2005
@@ -0,0 +1,104 @@
+/*
+ * 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 <axis2c_om_doctype.h>
+#include <stdlib.h>
+
+node_t *axis2c_create_om_doctype(node_t * parent, const char *value)
+{
+ om_doctype_t *doctype = NULL;
+ node_t *node = axis2c_create_node();
+ if (!node)
+ {
+ //fprintf(stderr,"Error");
+ return NULL;
+ }
+ doctype = (om_doctype_t *) malloc(sizeof(om_doctype_t));
+ if (!doctype)
+ {
+ free(node);
+ return NULL;
+ }
+ doctype->value = strdup(value);
+ node->data_element = doctype;
+ node->element_type = OM_DOCTYPE;
+ if (parent)
+ {
+ node->parent = parent;
+ axis2c_node_add_child(parent, node);
+ }
+ return node;
+}
+
+node_t *axis2c_create_empty_om_doctype(node_t * parent)
+{
+ node_t *node = NULL;
+ om_doctype_t *doctype = NULL;
+ if (!node)
+ { // error handling
+ return NULL;
+ }
+
+ doctype = (om_doctype_t *) malloc(sizeof(om_doctype_t));
+
+ if (!doctype)
+ {
+ free(node);
+ return NULL;
+ }
+ doctype->value = NULL;
+ node->data_element = doctype;
+ node->element_type = OM_DOCTYPE;
+ if (parent)
+ {
+ node->parent = parent;
+ axis2c_node_add_child(parent, node);
+ }
+ return node;
+}
+
+void axis2c_free_om_doctype(om_doctype_t * om_doc)
+{
+ if (om_doc)
+ {
+ if (om_doc->value)
+ free(om_doc->value);
+ free(om_doc);
+ }
+}
+
+char *axis2c_om_doctype_get_value(node_t * doctype_node)
+{
+ if (!doctype_node || doctype_node->element_type != OM_DOCTYPE)
+ {
+ return NULL;
+ }
+ return strdup(((om_doctype_t *) (doctype_node->data_element))->value);
+}
+void axis2c_om_doctype_set_value(node_t * doctype_node, const char *value)
+{
+ om_doctype_t *doctype = NULL;
+ if (!doctype_node || doctype_node->element_type != OM_DOCTYPE)
+ {
+ return;
+ }
+ doctype = (om_doctype_t *) (doctype_node->data_element);
+ if (doctype->value)
+ {
+ free(doctype->value);
+ }
+ doctype->value = strdup(value);
+}
Added: webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_document.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_document.c?rev=291854&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_document.c (added)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_document.c Tue Sep 27 01:03:18 2005
@@ -0,0 +1,110 @@
+/*
+ * 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 <axis2c_om_document.h>
+#include <stdlib.h>
+
+
+om_document_t *axis2c_create_om_document_with_root(node_t * root_ele,
+ stax_om_builder_t *
+ builder)
+{
+
+ om_document_t *doc = (om_document_t *) malloc(sizeof(om_document_t));
+ if (!doc)
+ {
+
+ }
+ doc->builder = builder;
+ doc->root_element = root_ele;
+ doc->first_child = NULL;
+ doc->last_child = NULL;
+ doc->char_set_encoding = CHAR_SET_ENCODING;
+ doc->xml_version = XML_VERSION;
+ return doc;
+}
+
+om_document_t *axis2c_create_om_document(stax_om_builder_t * builder)
+{
+ om_document_t *doc = (om_document_t *) malloc(sizeof(om_document_t));
+ if (!doc)
+ {
+ return NULL;
+ }
+ //doc->builder = builder;
+ doc->char_set_encoding = strdup(CHAR_SET_ENCODING);
+ doc->xml_version = strdup(XML_VERSION);
+ doc->done = FALSE;
+ doc->first_child = NULL;
+ doc->last_child = NULL;
+}
+
+void axis2c_free_om_document(om_document_t * doc)
+{
+
+
+
+}
+
+node_t *axis2c_om_document_get_document_element(om_document_t * document)
+{
+ //while(document->root_element == NULL)
+ //{}
+ return document->root_element;
+}
+
+void axis2c_om_document_set_charset_encoding(om_document_t * document,
+ char *charset_encoding)
+{
+ if (document)
+ {
+ if (document->char_set_encoding)
+ free(document->char_set_encoding);
+
+ document->char_set_encoding = strdup(charset_encoding);
+ }
+}
+
+char *axis2c_om_document_get_charset_encoding(om_document_t * document)
+{
+ if (document)
+ {
+ return strdup(document->char_set_encoding);
+ }
+}
+
+
+void axis2c_om_document_add_child(om_document_t * document, node_t * child)
+{
+ if (!document || !child || child->element_type != OM_ELEMENT)
+ {
+ //error
+ return;
+
+ }
+ if (document->first_child == NULL)
+ {
+ document->first_child = child;
+ child->prev_sibling = NULL;
+ }
+ else
+ {
+ child->prev_sibling = document->last_child;
+ document->last_child->next_sibling = child;
+ }
+ child->next_sibling = NULL;
+}
Added: webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_element.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_element.c?rev=291854&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_element.c (added)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_element.c Tue Sep 27 01:03:18 2005
@@ -0,0 +1,482 @@
+/*
+ * 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 <axis2c_om_element.h>
+#include <axis2c_om_attribute.h>
+#include <stdlib.h>
+
+node_t *axis2c_create_om_element(const char *localname,
+ om_namespace_t * ns)
+{
+ node_t *node = axis2c_create_node();
+ if (node)
+ {
+ om_element_t *element =
+ (om_element_t *) malloc(sizeof(om_element_t));
+ if (element)
+ {
+ element->localname = strdup(localname);
+ element->ns = ns;
+ element->pns_counter = 0;
+ element->attributes = NULL;
+ element->namespaces = NULL;
+ }
+ else
+ {
+ //could not allocate memory
+ free(node);
+ return NULL;
+ }
+
+ node->element_type = OM_ELEMENT;
+ node->data_element = element;
+ return node;
+ }
+ return NULL;
+}
+
+// create an om element using localname namespace and parent element
+
+node_t *axis2c_create_om_element_with_parent(const char *localname,
+ om_namespace_t * ns,
+ node_t * parent)
+{
+ node_t *curr_node = axis2c_create_om_element(localname, ns);
+ if (!curr_node)
+ {
+ //unable to create an element
+ return NULL;
+ }
+ curr_node->done = TRUE;
+ if (!parent)
+ return curr_node;
+
+ curr_node->parent = parent;
+ axis2c_node_add_child(parent, curr_node);
+
+ return curr_node;
+}
+
+// create an om_element using qname and parent
+node_t *axis2c_create_om_element_with_qname_parent(qname_t * qname,
+ node_t * parent)
+{
+ node_t *node = NULL;;
+ if (!qname)
+ {
+ return NULL; // can't create an element
+
+ }
+ node =
+ axis2c_create_om_element_with_parent(qname->localpart, NULL,
+ parent);
+ if (node)
+ {
+ ((om_element_t *) (node->data_element))->ns =
+ axis2c_om_element_handle_namespace_with_qname(node, qname);
+ }
+ return node;
+}
+
+
+om_namespace_t *axis2c_om_element_find_namespace(node_t * element_node,
+ const char *uri,
+ const char *prefix)
+{
+ //om_element_t *ele=NULL;
+ om_namespace_t *ns = NULL;
+ if (!element_node)
+ {
+ return NULL;
+ }
+ if (!(element_node->data_element)
+ || element_node->element_type != OM_ELEMENT)
+ {
+ // wrong element type or null node
+
+ return NULL;
+ }
+ //ele = (om_element_t *)(element_node->data_element);
+
+
+ ns = axis2c_om_element_find_declared_namespace(element_node, uri,
+ prefix);
+ if (!ns)
+ {
+ return ns;
+ }
+ if ((element_node->parent != NULL)
+ && (element_node->parent->element_type == OM_ELEMENT))
+ {
+ axis2c_om_element_find_namespace(element_node->parent, uri,
+ prefix);
+ }
+ return NULL;
+}
+
+
+// declare a namespace for this om element
+
+om_namespace_t *axis2c_om_element_declare_namespace(node_t * element_node,
+ om_namespace_t * ns)
+{
+ apr_status_t status;
+ om_element_t *element = NULL;
+ if (!element_node || !ns || !element_node->data_element
+ || element_node->element_type != OM_ELEMENT)
+ {
+ return NULL;
+ }
+ element = (om_element_t *) (element_node->data_element);
+ if (!element->namespaces)
+ {
+ 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;
+}
+
+
+om_namespace_t
+ *axis2c_om_element_declare_namespace_with_ns_uri_prefix(node_t *
+ element_node,
+ const char
+ *uri,
+ const char
+ *prefix)
+{
+ om_namespace_t *nsp = NULL;
+ nsp = axis2c_create_om_namespace(uri, prefix);
+ if (nsp)
+ return axis2c_om_element_declare_namespace(element_node, nsp);
+ return NULL;
+}
+
+/*
+* checks for the namespace in the current om element
+* can be used to retrive a prefix of a known namespace uri
+*
+*/
+om_namespace_t *axis2c_om_element_find_declared_namespace(node_t *
+ element_node,
+ const char *uri,
+ const char
+ *prefix)
+{
+ void *ns = NULL;
+ om_element_t *element = NULL;
+ if (!element_node || !ns || element_node->element_type != OM_ELEMENT)
+ {
+ return NULL;
+ }
+ element = (om_element_t *) (element_node->data_element);
+ if (!prefix || strcmp(prefix, "") == 0)
+ {
+ // should traverse through the namespaces
+
+
+ }
+ ns = apr_hash_get(element->namespaces, prefix, APR_HASH_KEY_STRING);
+ return (void *) ns;
+}
+
+/*
+* This will find a namespace with the given uri and prefix, in the scope of the docuemnt.
+* This will start to find from the current element and goes up in the hiararchy until this finds one.
+*
+*/
+
+
+
+static om_namespace_t *axis2c_om_element_handle_namespace_with_qname(node_t
+ *
+ element_node,
+ qname_t
+ *
+ qname)
+{
+ om_namespace_t *pns = NULL;
+ char *ns_uri = qname->ns_uri;
+ if (ns_uri != NULL)
+ {
+ pns =
+ axis2c_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 =
+ axis2c_om_element_declare_namespace_with_ns_uri_prefix
+ (element_node, ns_uri, qname->prefix);
+ }
+ }
+ }
+ return NULL;
+}
+
+
+
+
+
+
+
+static om_namespace_t *axis2c_om_element_handle_namespace(node_t *
+ element_node,
+ om_namespace_t *
+ ns)
+{
+ om_namespace_t *ns1 = NULL;
+ if (!ns || !element_node)
+ {
+ // namespace null handle condition
+
+ }
+ ns1 =
+ axis2c_om_element_find_namespace(element_node, ns->uri,
+ ns->prefix);
+
+ if (!ns1)
+ {
+ ns1 = axis2c_om_element_declare_namespace(element_node, ns);
+ }
+ return ns1;
+}
+
+
+om_attribute_t *axis2c_om_element_add_attribute(node_t * element_node,
+ om_attribute_t * attr)
+{
+ apr_status_t status;
+ qname_t *t = NULL;
+ om_element_t *element = NULL;
+ char *key = NULL;
+
+ if (!element_node || element_node->element_type != OM_ELEMENT)
+ {
+ //fprintf(stderr,"Error");
+ return NULL;
+ }
+ element = (om_element_t *) (element_node->data_element);
+
+ if (!(element->attributes))
+ {
+ if (!om_pool)
+ {
+ status = apr_pool_create(&om_pool, NULL);
+ // error handling should go hear
+ }
+ element->attributes = apr_hash_make(om_pool);
+ }
+
+ t = axis2c_om_attribute_get_qname(attr);
+ key = axis2c_construct_key_from_qname(t);
+ apr_hash_set(element->attributes, key, APR_HASH_KEY_STRING, attr);
+ return attr;
+}
+
+om_attribute_t *axis2c_om_element_get_attribute(node_t * element_node,
+ qname_t * qname)
+{
+ char *key = NULL;
+ om_element_t *element = NULL;
+ if (!element_node || !qname
+ || element_node->element_type != OM_ELEMENT)
+ {
+ return NULL;
+ }
+ element = (om_element_t *) (element_node->data_element);
+ key = axis2c_construct_key_from_qname(qname);
+ return (om_attribute_t
+ *) (apr_hash_get(element->attributes, key,
+ APR_HASH_KEY_STRING));
+}
+
+
+
+
+static char *axis2c_construct_key_from_qname(qname_t * qname)
+{
+
+ // concatanation order is localpart prefix namespaceuri
+ char *key = NULL;
+ size_t i = 0;
+ if (!qname)
+ {
+ //fprintf(stderr,"Error null value for qname ");
+ return NULL;
+ }
+ else
+ {
+ if (qname->localpart)
+ i += strlen(qname->localpart);
+ if (qname->ns_uri)
+ i += strlen(qname->ns_uri);
+ if (qname->prefix)
+ i += strlen(qname->prefix);
+ key = (char *) calloc(i + 1, sizeof(char));
+ if (qname->localpart)
+ strcat(key, qname->localpart);
+ if (qname->prefix)
+ strcat(key, qname->prefix);
+ if (qname->ns_uri)
+ strcat(key, qname->ns_uri);
+ return key;
+
+ }
+ return NULL;
+}
+
+/*
+* The node passed to the method should have the data element as of type OM_ELEMENT
+*
+*
+*
+*/
+
+om_attribute_t *axis2c_om_attribute_add_attribute_with_namespace(node_t *
+ element_node,
+ const char
+ *attribute_name,
+ const char
+ *value,
+ om_namespace_t
+ * ns)
+{
+ om_namespace_t *t = NULL;
+ if (!element_node)
+ {
+ return NULL;
+
+ }
+ else if (element_node->element_type != OM_ELEMENT)
+ {
+ return NULL;
+ }
+
+
+ if (ns)
+ {
+ t = axis2c_om_element_find_namespace(element_node, ns->uri,
+ ns->prefix);
+ if (t == NULL)
+ {
+ //fprintf(stderr,"prefix %s ns_uri %s This namespace is not in the scope of this element",ns->prefix,ns->uri);
+ return NULL;
+ }
+ }
+ return axis2c_om_element_add_attribute(element_node,
+ axis2c_create_om_attribute
+ (attribute_name, value, ns));
+}
+
+/*
+void om_element_remove_attribute(om_element_t *element,om_attribute_t *attribute)
+{
+ qname_t *qname=NULL;
+ char* key=NULL;
+ if(!element || !(element->attributes))
+ {
+ // error handling
+ return NULL;
+ }
+ qname = om_attribute_get_qname(attribute);
+ if(qname)
+ {
+ key=construct_key_from_qname(qname);
+ //apr_hash_
+
+
+
+ }
+
+
+
+
+
+
+}
+*/
+
+void axis2c_om_element_set_namespace(node_t * node, om_namespace_t * ns)
+{
+ om_namespace_t *nsp = NULL;
+ if (ns && node && (node->data_element))
+ {
+ nsp = axis2c_om_element_handle_namespace(node, ns);
+ }
+ ((om_element_t *) node->data_element)->ns = nsp;
+}
+
+
+void axis2c_free_om_element(om_element_t * element)
+{
+ if (element)
+ {
+ if (element->localname)
+ free(element->localname);
+ if (element->ns)
+ axis2c_free_om_namespace(element->ns);
+ if (element->attributes)
+ {
+ // should find out how to free hashtable
+ }
+ if (element->namespaces)
+ {
+
+ // same as above
+
+ }
+ free(element);
+ }
+}
+
+void axis2c_om_element_set_localname(node_t * element_node,
+ const char *localname)
+{
+ om_element_t *element = NULL;
+ if (!element_node || element_node->element_type != OM_ELEMENT)
+ {
+ // not correct element or null pointer
+ return;
+ }
+ element = (om_element_t *) (element_node->data_element);
+ if (element->localname)
+ {
+ free(element->localname);
+ }
+ element->localname = strdup(localname);
+}
+
+char *axis2c_om_element_get_localname(node_t * element_node)
+{
+ if (!element_node || element_node->element_type != OM_ELEMENT)
+ {
+ return NULL;
+ }
+ return strdup(((om_element_t *) (element_node->data_element))->
+ localname);
+}
Modified: webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_namespace.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_namespace.c?rev=291854&r1=291853&r2=291854&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_namespace.c (original)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_namespace.c Tue Sep 27 01:03:18 2005
@@ -51,18 +51,17 @@
int prefixes_differ = 0;
if (!ns1 || !ns2)
- return 0;
+ return 0;
if (ns1->uri && ns2->uri)
- uris_differ = strcmp(ns1->uri, ns2->uri);
+ uris_differ = strcmp(ns1->uri, ns2->uri);
else
- uris_differ = (ns1->uri || ns2->uri);
+ uris_differ = (ns1->uri || ns2->uri);
if (ns1->prefix && ns2->prefix)
- prefixes_differ = strcmp(ns1->prefix, ns2->prefix);
+ prefixes_differ = strcmp(ns1->prefix, ns2->prefix);
else
- prefixes_differ = (ns1->prefix || ns2->prefix);
+ prefixes_differ = (ns1->prefix || ns2->prefix);
return (!uris_differ && !prefixes_differ);
}
-
Added: webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_processing_instruction.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_processing_instruction.c?rev=291854&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_processing_instruction.c (added)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_processing_instruction.c Tue Sep 27 01:03:18 2005
@@ -0,0 +1,154 @@
+/*
+ * 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 <axis2c_om_processing_instruction.h>
+#include <axis2c_node.h>
+#include <stdlib.h>
+#include <axis2c_errno.h>
+
+/**
+* allocate memory for processing instruction structure and assign the values;
+* This structure is set to node_t structure and returned.
+* AXIS2C_ERROR_OM_MEMORY_ALLOCATION error is returned if malloc fails to allocate memory
+*
+*/
+
+node_t *axis2c_create_om_processing_instruction(node_t * parent,
+ const char *target,
+ const char *value)
+{
+ om_processing_instruction_t *pi = NULL;
+ node_t *pi_node = axis2c_create_node();
+ if (pi_node)
+ {
+ pi = (om_processing_instruction_t *)
+ malloc(sizeof(om_processing_instruction_t));
+ if (!pi)
+ {
+ free(pi_node);
+ fprintf(stderr, "%d error", AXIS2C_ERROR_OM_MEMORY_ALLOCATION);
+ return NULL;
+ }
+ pi->target = strdup(target);
+ pi->value = strdup(value);
+ }
+ pi_node->data_element = pi;
+ pi_node->element_type = OM_PROCESSING_INSTRUCTION;
+
+ if (parent)
+ {
+ pi_node->parent = parent;
+ axis2c_node_add_child(parent, pi_node);
+ }
+ return pi_node;
+}
+
+node_t *axis2c_create_empty_om_processing_instruction(node_t * parent)
+{
+ node_t *pi_node = NULL;
+ om_processing_instruction_t *pi = NULL;
+ pi_node = axis2c_create_node();
+ if (pi_node)
+ {
+ pi = (om_processing_instruction_t *)
+ malloc(sizeof(om_processing_instruction_t));
+ if (!pi)
+ {
+ free(pi_node);
+ return NULL;
+ }
+ pi->target = NULL;
+ pi->value = NULL;
+ }
+ // set node type
+ pi_node->data_element = pi;
+ pi_node->element_type = OM_PROCESSING_INSTRUCTION;
+ if (parent)
+ {
+ pi_node->parent = parent;
+ axis2c_node_add_child(parent, pi_node);
+ }
+ return pi_node;
+}
+
+
+char *axis2c_om_processing_instruction_get_value(node_t * pi_node)
+{
+ if (!pi_node || pi_node->element_type != OM_PROCESSING_INSTRUCTION)
+ {
+ // error handling
+ return NULL;
+ }
+ return ((om_processing_instruction_t *) (pi_node->data_element))->
+ value;
+}
+
+char *axis2c_om_processing_instruction_get_target(node_t * pi_node)
+{
+ if (!pi_node || pi_node->element_type != OM_PROCESSING_INSTRUCTION)
+ {
+ return NULL;
+ }
+ return ((om_processing_instruction_t *) (pi_node->data_element))->
+ target;
+}
+
+om_processing_instruction_t
+ *axis2c_om_processing_instruction_get_om_processing_instruction(node_t
+ *
+ pi_node)
+{
+ if (!pi_node || pi_node->element_type != OM_PROCESSING_INSTRUCTION)
+ {
+ return NULL;
+ }
+ return (om_processing_instruction_t *) (pi_node->data_element);
+}
+
+void axis2c_om_processing_instruction_set_value(node_t * pi_node,
+ const char *value)
+{
+ om_processing_instruction_t *pi = NULL;
+ if (!pi_node || pi_node->element_type != OM_PROCESSING_INSTRUCTION)
+ {
+ return;
+ }
+ pi = ((om_processing_instruction_t *) (pi_node->data_element));
+ if (pi->value)
+ {
+ free(pi->value);
+ }
+ pi->value = strdup(value);
+ pi = NULL;
+}
+
+void axis2c_om_processing_instruction_set_target(node_t * pi_node,
+ const char *value)
+{
+ om_processing_instruction_t *pi = NULL;
+ if (!pi_node || pi_node->element_type != OM_PROCESSING_INSTRUCTION)
+ {
+ return;
+ }
+ pi = (om_processing_instruction_t *) (pi_node->data_element);
+ if (pi->target)
+ {
+ free(pi->target);
+ }
+ pi->target = strdup(value);
+ pi = NULL;
+ return;
+}
Added: webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_text.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_text.c?rev=291854&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_text.c (added)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_text.c Tue Sep 27 01:03:18 2005
@@ -0,0 +1,80 @@
+/*
+ * 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 <axis2c_om_text.h>
+#include <string.h>
+#include <axis2c_node.h>
+
+node_t *axis2c_create_om_text(const char *value)
+{
+ om_text_t *text;
+ node_t *node = axis2c_create_node();
+ if (!node)
+ {
+ // error handling
+ return NULL;
+ }
+ text = (om_text_t *) malloc(sizeof(om_text_t));
+ if (!text)
+ {
+ // error handling
+ return NULL;
+ }
+ text->value = strdup(value);
+ text->attribute = NULL;
+ text->content_id = NULL;
+ text->mime_type = NULL;
+ node->data_element = text;
+ node->element_type = OM_TEXT;
+ return node;
+}
+
+node_t *axis2c_create_om_text_with_parent(node_t * parent,
+ const char *value)
+{
+ node_t *node;
+ if (!parent)
+ return NULL;
+ node = axis2c_create_om_text(value);
+ if (!node)
+ {
+ // error handling
+ return NULL;
+ }
+ node->done = TRUE;
+ // set parent as the parent of this text node
+ node->parent = parent;
+ axis2c_node_add_child(parent, node);
+ return node;
+}
+
+char *axis2c_om_text_get_text(om_text_t * text)
+{
+ if (!text)
+ {
+ // error
+ return NULL;
+ }
+ if (text->value)
+ return text->value;
+
+ else
+ {
+ //MTOM handling logic should go hear
+
+ }
+ return NULL;
+}
Added: webservices/axis2/trunk/c/modules/xml/om/src/axis2c_qname.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2c_qname.c?rev=291854&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2c_qname.c (added)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2c_qname.c Tue Sep 27 01:03:18 2005
@@ -0,0 +1,42 @@
+/*
+ * 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 <axis2c_qname.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+
+qname_t *axis2c_create_qname(const char *localname, const char *ns_uri,
+ const char *prefix)
+{
+ qname_t *qn = (qname_t *) malloc(sizeof(qname_t));
+ if (!qn)
+ {
+ //fprintf(stderr,"Error allocating memory");
+ return NULL;
+ }
+ qn->localpart = strdup(localname);
+ qn->ns_uri = strdup(ns_uri);
+ qn->prefix = strdup(prefix);
+ return qn;
+}
+
+void axis2c_free_qname(qname_t * qn)
+{
+ if (qn)
+ free(qn);
+}
Added: webservices/axis2/trunk/c/modules/xml/om/src/axis2c_stax_ombuilder.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2c_stax_ombuilder.c?rev=291854&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2c_stax_ombuilder.c (added)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2c_stax_ombuilder.c Tue Sep 27 01:03:18 2005
@@ -0,0 +1,45 @@
+/*
+ * 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 <axis2c_stax_ombuilder.h>
+#include <axis2c_node.h>
+#include <stdlib.h>
+#include <xmlpullparser.h>
+/*
+stax_om_builder_t *create_stax_om_builder(XML_PullParser *parser)
+{
+ stax_om_builder_t *builder = (stax_om_builder_t*)malloc(sizeof(stax_om_builder_t));
+ if(!builder)
+ {
+ return NULL;
+ }
+ builder->parser = NULL;
+ builder->document=NULL;
+ builder->lastnode=NULL;
+ return builder;
+}
+
+node_t *stax_om_builder_create_om_element(stax_om_builder_t *builder)
+{
+ node_t *om_element;
+
+
+
+
+
+}
+
+*/