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/24 05:00:31 UTC
svn commit: r327932 - in /webservices/axis2/trunk/c:
include/axis2_om_element.h modules/xml/om/src/axis2_om_element.c
Author: samisa
Date: Sun Oct 23 20:00:22 2005
New Revision: 327932
URL: http://svn.apache.org/viewcvs?rev=327932&view=rev
Log:
Updated the doc comments, dropped the unwanted comment blocks and fixed compiler warnings
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=327932&r1=327931&r2=327932&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_om_element.h (original)
+++ webservices/axis2/trunk/c/include/axis2_om_element.h Sun Oct 23 20:00:22 2005
@@ -38,162 +38,165 @@
*/
-/**
- * @brief OM element operations struct
- * Encapsulator struct for operations of axis2_om_element_t
-*/
-
-
+ /**
+ * @brief OM element operations struct
+ * Encapsulator struct for operations of axis2_om_element
+ */
typedef struct axis2_om_element_ops
{
- /*
- * Find a namespace in the scope of the document
- * start to find from current element and go up the hierarchy
- * @param environment Environment .MUST NOT be NULL, if NULL behaviour is undefined.
- * @param node om_node containing an instance of om_element
- * @param uri namespace uri
- * @param prefix namespace prefix
- * @return axis2_om_namespace_t pointer
- */
-
- axis2_om_namespace_t
- *(*axis2_om_element_ops_find_namespace) (axis2_environment_t *
+ /*
+ * Find a namespace in the scope of the document.
+ * Start to find from the given node and go up the hierarchy.
+ * @param environment Environment. MUST NOT be NULL, if NULL behaviour is undefined.
+ * @param node node containing an instance of an OM element. Mandatory, cannot be NULL.
+ * @param uri namespace uri. Mandatory, cannot be NULL.
+ * @param prefix namespace prefix. Optional, can be NULL.
+ * @return pointer to the namespace, if found, else NULL. On error, returns
+ * NULL and sets the errorno in environment.
+ */
+ AXIS2_DECLARE_DATA axis2_om_namespace_t *
+ (AXIS2_CALL *axis2_om_element_ops_find_namespace) (axis2_environment_t *
environment,
axis2_om_node_t * node,
const axis2_char_t * uri,
const axis2_char_t *
prefix);
- /**
- * declare a namespace in current element (in the scope of this element )
- * @param environment Environment .MUST NOT be NULL, if NULL behaviour is undefined.
- * @param element axis2_om_element_struct pointer
- * @param ns pointer to a om_namespace
- * @return status code
- */
-
- axis2_status_t (*axis2_om_element_ops_declare_namespace)
- (axis2_environment_t * environment, axis2_om_node_t * node,
+ /**
+ * Declare a namespace in current element (in the scope of this element ).
+ * It checks to see if it is already declared.
+ * @param environment Environment. MUST NOT be NULL, if NULL behaviour is undefined.
+ * @param node node containing an instance of an OM element. Mandatory, cannot be NULL.
+ * @param ns pointer to the namespace struct to be declared
+ * @return satus of the operation. AXIS2_SUCCESS on success else AXIS2_FAILURE.
+ */
+ AXIS2_DECLARE_DATA axis2_status_t (AXIS2_CALL *axis2_om_element_ops_declare_namespace)
+ (axis2_environment_t * environment, axis2_om_node_t *node,
axis2_om_namespace_t * ns);
- /**
- * find namespaces in the scope of current element
- * @param environment Environment .MUST NOT be NULL, if NULL behaviour is undefined.
- * @param element pointer to an om element
- * @param prefix namespace prefix
- * @param uri namespace uri
- */
- axis2_om_namespace_t
- *(*axis2_om_element_ops_find_declared_namespace)
+ /**
+ * find namespaces in the scope of current element
+ * @param environment Environment .MUST NOT be NULL, if NULL behaviour is undefined.
+ * @param element pointer to an om element
+ * @param prefix namespace prefix
+ * @param uri namespace uri
+ */
+ /* AXIS2_DECLARE_DATA axis2_om_namespace_t
+ *(AXIS2_CALL *axis2_om_element_ops_find_declared_namespace)
(axis2_environment_t * environment,
struct axis2_om_element * element, const axis2_char_t * uri,
const axis2_char_t * prefix);
+ */
- /**
- * Finds a namespace using qname
- * @param environment Environment .MUST NOT be NULL, if NULL behaviour is undefined.
-
- */
-
- axis2_om_namespace_t
- *(*axis2_om_element_ops_find_namespace_with_qname)
- (axis2_environment_t * environment, axis2_om_node_t * node,
- axis2_qname_t * qname);
-
- /**
- * add an attribute to current element
- * @param environment Environment .MUST NOT be NULL, if NULL behaviour is undefined.
-
- * @param ns namespace Optional
- */
-
- axis2_status_t (*axis2_om_element_ops_add_attribute)
+ /**
+ * Finds a namespace using qname
+ * Start to find from the given node and go up the hierarchy.
+ * @param environment Environment. MUST NOT be NULL, if NULL behaviour is undefined.
+ * @param node node containing an instance of an OM element. Mandatory, cannot be NULL.
+ * @param qname qname of the namespace to be found. Mandatory, cannot be NULL.
+ * @return pointer to the namespace, if found, else NULL. On error, returns
+ * NULL and sets the errorno in environment.
+ */
+ AXIS2_DECLARE_DATA axis2_om_namespace_t *
+ (AXIS2_CALL *axis2_om_element_ops_find_namespace_with_qname)
+ (axis2_environment_t *environment, axis2_om_node_t *node,
+ axis2_qname_t *qname);
+
+ /**
+ * Adds an attribute to current element
+ * @param environment Environment. MUST NOT be NULL, if NULL behaviour is undefined.
+ * @param element element to which the attribute is to be added. Mandatory, cannot be NULL.
+ * @param attribute attribute to be added.
+ * @return satus of the operation. AXIS2_SUCCESS on success else AXIS2_FAILURE.
+ */
+ AXIS2_DECLARE_DATA axis2_status_t (AXIS2_CALL *axis2_om_element_ops_add_attribute)
(axis2_environment_t * environment,
struct axis2_om_element * element,
axis2_om_attribute_t * attribute);
- /**
- * @param environment Environment .MUST NOT be NULL, if NULL behaviour is undefined.
- * @param element OM Element
- * @qname Qname
- * @return the requested attribute
- */
-
- axis2_om_attribute_t
- *(*axis2_om_element_ops_get_attribute) (axis2_environment_t *
+ /**
+ * Gets (finds) the attribute with the given qname
+ * @param environment Environment. MUST NOT be NULL, if NULL behaviour is undefined.
+ * @param element element whose attribute is to be found. Mandatory, cannot be NULL.
+ * @qname qname qname of the attribute to be found. Mandatory, cannot be NULL.
+ * @return a pointer to the attribute with given qname if found, else NULL.
+ * On error, returns NULL and sets the error.
+ */
+ AXIS2_DECLARE_DATA axis2_om_attribute_t *
+ (AXIS2_CALL *axis2_om_element_ops_get_attribute) (axis2_environment_t *
environment,
struct axis2_om_element *
element,
axis2_qname_t * qname);
- /**
- * Free Om element
- * @param environment Environment .MUST NOT be NULL, if NULL behaviour is undefined.
- * @param element OM element
- * @returns status code
- *
- */
-
- axis2_status_t (*axis2_om_element_ops_free) (axis2_environment_t *
+ /**
+ * Frees given element
+ * @param environment Environment. MUST NOT be NULL, if NULL behaviour is undefined.
+ * @param element OM element to be freed.
+ * @return satus of the operation. AXIS2_SUCCESS on success else AXIS2_FAILURE.
+ */
+ AXIS2_DECLARE_DATA axis2_status_t (AXIS2_CALL *axis2_om_element_ops_free) (axis2_environment_t *
environment,
struct axis2_om_element
* element);
- /**
- * serialize operation
- * @param environment Environment .MUST NOT be NULL, if NULL behaviour is undefined.
- * @param element OM Element
- * @param om_output OM output
- * @return status code
- */
-
- axis2_status_t (*axis2_om_element_ops_serialize_start_part)
+ /**
+ * Serializes the start part of the given element
+ * @param environment Environment. MUST NOT be NULL, if NULL behaviour is undefined.
+ * @param element element to be serialized.
+ * @param om_output OM output handler to be used in serializing
+ * @return satus of the operation. AXIS2_SUCCESS on success else AXIS2_FAILURE
+ */
+ AXIS2_DECLARE_DATA axis2_status_t (AXIS2_CALL *axis2_om_element_ops_serialize_start_part)
(axis2_environment_t * environment,
struct axis2_om_element * element,
axis2_om_output_t * om_output);
- /**
- * serialize operation
- * @param environment Environment .MUST NOT be NULL, if NULL behaviour is undefined.
- * @param element OM Element
- * @param om_output OM output
- * @return status code
- */
- axis2_status_t (*axis2_om_element_ops_serialize_end_part)
+ /**
+ * Serializes the end part of the given element. serialize_start_part must
+ * have been called before calling this method.
+ * @param environment Environment. MUST NOT be NULL, if NULL behaviour is undefined.
+ * @param element element to be serialized.
+ * @param om_output OM output handler to be used in serializing
+ * @return satus of the operation. AXIS2_SUCCESS on success else AXIS2_FAILURE
+ */
+ AXIS2_DECLARE_DATA axis2_status_t (AXIS2_CALL *axis2_om_element_ops_serialize_end_part)
(axis2_environment_t * environment,
struct axis2_om_element * element,
axis2_om_output_t * om_output);
} axis2_om_element_ops_t;
-/**
- \brief OM element struct
-
- Handles the XML element in OM
-*/
-
-
+
+ /**
+ * \brief OM element struct
+ * Handles the XML element in OM
+ */
typedef struct axis2_om_element
{
+ /** operations of attribute struct */
axis2_om_element_ops_t *ops;
- /** Element's namespace */
+ /** Element's namespace */
axis2_om_namespace_t *ns;
- /** Element's local name */
+ /** Element's local name */
axis2_char_t *localname;
- /** List of attributes */
+ /** List of attributes */
axis2_hash_t *attributes;
- /** List of namespaces */
+ /** List of namespaces */
axis2_hash_t *namespaces;
} axis2_om_element_t;
-
-/*
-* Create an om element using localname and namespace and parent
-*@param localname can't be null
-*@param ns namespace can be null
-*@param parent can be null
-*@return Returns axis2_om_element_t pointer If there isn't enough memory null is returned
-*/
- axis2_om_element_t *axis2_om_element_create (axis2_environment_t *
+ /**
+ * Creates an OM element with given local name
+ * @param environment Environment. MUST NOT be NULL, if NULL behaviour is undefined.
+ * @param parent parent of the element node to be created. Optional, can be NULL.
+ * @param localname local name of the elment. Mandatory, cannot be NULL.
+ * @param ns namespace of the element. Optional, can be NULL.
+ * @param node This is an out parameter. Mandatory, cannot be NULL.
+ * Returns the node corresponding to the comment created.
+ * Node type will be set to AXIS2_OM_ELEMENT
+ * @return a pointer to the newly created element struct
+ */
+ AXIS2_DECLARE(axis2_om_element_t *) axis2_om_element_create (axis2_environment_t *
environment,
axis2_om_node_t * parent,
const axis2_char_t *
@@ -201,29 +204,39 @@
axis2_om_namespace_t * ns,
axis2_om_node_t ** node);
-/**
- * create an om element using a qname
- * @param qname
- * @param parent
- * @return axis2_om_element_t pointer or NULL if there isn't enough memory
- */
-
-
- axis2_om_element_t
- *axis2_om_element_create_with_qname (axis2_environment_t *
+ /**
+ * Creates an OM element with given qname
+ * @param environment Environment. MUST NOT be NULL, if NULL behaviour is undefined.
+ * @param parent parent of the element node to be created. Optional, can be NULL.
+ * @param qname qname of the elment. Mandatory, cannot be NULL.
+ * @param node This is an out parameter. Mandatory, cannot be NULL.
+ * Returns the node corresponding to the comment created.
+ * Node type will be set to AXIS2_OM_ELEMENT
+ * @return a pointer to the newly created element struct
+ */
+ AXIS2_DECLARE(axis2_om_element_t *)
+ axis2_om_element_create_with_qname (axis2_environment_t *
environment,
axis2_om_node_t * parent,
axis2_qname_t * qname,
axis2_om_node_t ** node);
+/** finds given namespace with respect to given node */
#define axis2_om_element_find_namespace(environment, node, uri, prefix) (((axis2_om_element_t*)(node->data_element))->ops->axis2_om_element_ops_find_namespace(environment, node, uri, prefix))
+/** declares given namespace with respect to the given node */
#define axis2_om_element_declare_namespace(environment, node, ns) (((axis2_om_element_t*)(node->data_element))->ops->axis2_om_element_ops_declare_namespace(environment, node, ns) )
-#define axis2_om_element_find_namespace_with_qname (environment, element, qname) ((element)->ops->axis2_om_element_ops_find_namespace_with_qname (environment, element, qname))
+/** finds namespace with given qname */
+#define axis2_om_element_find_namespace_with_qname (environment, node, qname) ((element)->ops->axis2_om_element_ops_find_namespace_with_qname (environment, node, qname))
+/** adds given attribute to given element */
#define axis2_om_element_add_attribute(environment, element, attribute) ((element)->ops->axis2_om_element_ops_add_attribute(environment, element, attribute))
+/** gets (finds) given attribute in given element */
#define axis2_om_element_get_attribute(environment, element, qname) ((element)->ops->axis2_om_element_ops_get_attribute(environment, element, qname))
-#define axis2_om_element_find_declared_namespace(environment,element,uri,prefix) ((element)->ops->axis2_om_element_find_declared_namespace(environment,element,uri,prefix))
+/*#define axis2_om_element_find_declared_namespace(environment,element,uri,prefix) ((element)->ops->axis2_om_element_find_declared_namespace(environment,element,uri,prefix))*/
+/** frees given element */
#define axis2_om_element_free(environment, element) ((element)->ops->axis2_om_element_ops_free(environment, element))
+/** serialize the start part of given element */
#define axis2_om_element_serialize_start_part(environment, element, om_output) ((element)->ops->axis2_om_element_ops_serialize_start_part(environment, element, om_output))
+/** serialize the end part of given element */
#define axis2_om_element_serialize_end_part(environment, element, om_output) ((element)->ops->axis2_om_element_ops_serialize_end_part(environment, element, om_output))
/** @} */
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=327932&r1=327931&r2=327932&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 Sun Oct 23 20:00:22 2005
@@ -19,55 +19,62 @@
#include <axis2_om_namespace.h>
-axis2_om_namespace_t
- *axis2_om_element_impl_find_namespace (axis2_environment_t * environment,
+axis2_om_namespace_t *
+ AXIS2_CALL axis2_om_element_impl_find_namespace (axis2_environment_t * environment,
axis2_om_node_t * node,
const axis2_char_t * uri,
const axis2_char_t * prefix);
-axis2_status_t axis2_om_element_impl_declare_namespace (axis2_environment_t *
+
+axis2_status_t AXIS2_CALL axis2_om_element_impl_declare_namespace (axis2_environment_t *
environment,
axis2_om_node_t *
node,
axis2_om_namespace_t *
ns);
-axis2_om_namespace_t
- *axis2_om_element_impl_find_namespace_with_qname (axis2_environment_t *
+
+axis2_om_namespace_t *
+ AXIS2_CALL axis2_om_element_impl_find_namespace_with_qname (axis2_environment_t *
environment,
axis2_om_node_t *
element,
axis2_qname_t * qname);
-
-axis2_om_namespace_t
- *axis2_om_element_impl_find_declared_namespace (axis2_environment_t *
+/*
+axis2_om_namespace_t *
+ AXIS2_CALL axis2_om_element_impl_find_declared_namespace (axis2_environment_t *
environment,
struct axis2_om_element
*element,
const axis2_char_t * uri,
const axis2_char_t *
prefix);
+*/
-axis2_status_t axis2_om_element_impl_add_attribute (axis2_environment_t *
+axis2_status_t AXIS2_CALL axis2_om_element_impl_add_attribute (axis2_environment_t *
environment,
struct axis2_om_element
*element,
axis2_om_attribute_t *
attribute);
-axis2_om_attribute_t *axis2_om_element_impl_get_attribute (axis2_environment_t
+
+axis2_om_attribute_t * AXIS2_CALL axis2_om_element_impl_get_attribute (axis2_environment_t
* environment,
struct
axis2_om_element
*element,
axis2_qname_t *
qname);
-axis2_status_t axis2_om_element_impl_free (axis2_environment_t * environment,
+
+axis2_status_t AXIS2_CALL axis2_om_element_impl_free (axis2_environment_t * environment,
struct axis2_om_element *element);
-axis2_status_t axis2_om_element_impl_serialize_start_part (axis2_environment_t
+
+axis2_status_t AXIS2_CALL axis2_om_element_impl_serialize_start_part (axis2_environment_t
* environment,
axis2_om_element_t
* element,
axis2_om_output_t *
om_output);
-axis2_status_t axis2_om_element_impl_serialize_end_part (axis2_environment_t *
+
+axis2_status_t AXIS2_CALL axis2_om_element_impl_serialize_end_part (axis2_environment_t *
environment,
axis2_om_element_t *
element,
@@ -170,8 +177,8 @@
element->ops->axis2_om_element_ops_get_attribute =
axis2_om_element_impl_get_attribute;
element->ops->axis2_om_element_ops_free = axis2_om_element_impl_free;
- element->ops->axis2_om_element_ops_find_declared_namespace =
- axis2_om_element_impl_find_declared_namespace;
+ /*element->ops->axis2_om_element_ops_find_declared_namespace =
+ axis2_om_element_impl_find_declared_namespace;*/
element->ops->axis2_om_element_ops_serialize_start_part =
axis2_om_element_impl_serialize_start_part;
element->ops->axis2_om_element_ops_serialize_end_part =
@@ -181,8 +188,6 @@
}
-
-/* create an om_element using qname and parent */
axis2_om_element_t *
axis2_om_element_create_with_qname (axis2_environment_t * environment,
axis2_om_node_t * parent,
@@ -213,7 +218,7 @@
if (!(element->ns))
{
if (axis2_om_element_impl_declare_namespace
- (environment, element, ns) == AXIS2_SUCCESS)
+ (environment, *node, ns) == AXIS2_SUCCESS)
element->ns = ns;
}
}
@@ -280,9 +285,6 @@
return NULL;
}
-
-/* declare a namespace for this om element */
-
axis2_status_t
axis2_om_element_impl_declare_namespace (axis2_environment_t * environment,
axis2_om_node_t * node,
@@ -331,30 +333,7 @@
return AXIS2_SUCCESS;
}
-
-/*axis2_om_namespace_t *
-axis2_om_element_declare_namespace_with_ns_uri_prefix (axis2_om_node_t *
- element,
- const axis2_char_t *uri,
- const axis2_char_t *prefix)
-{
- axis2_om_namespace_t *nsp = NULL;
- nsp = axis2_om_namespace_create (uri, prefix);
- if (nsp)
- {
- return axis2_om_element_declare_namespace (element, nsp);
- }
- return NULL;
-}
-*/
-
/*
-* checks for the namespace in the current om element
-* can be used to retrive a prefix of a known namespace uri
-*
-*/
-
-
axis2_om_namespace_t *
axis2_om_element_impl_find_declared_namespace (axis2_environment_t *
environment,
@@ -391,18 +370,8 @@
return NULL;
}
-
-
-
-
-/*
-* 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.
-*
*/
-
-
axis2_om_namespace_t *
axis2_om_element_impl_find_namespace_with_qname (axis2_environment_t *
environment,
@@ -427,26 +396,6 @@
}
}
-/*
-static axis2_om_namespace_t *
-axis2_om_element_handle_namespace (axis2_om_node_t
- * element, axis2_om_namespace_t * ns)
-{
- axis2_om_namespace_t *ns1 = NULL;
- if (!ns || !element)
- {
- return NULL;
- }
- ns1 = axis2_om_element_find_namespace (element, ns->uri, ns->prefix);
-
- if (!ns1)
- {
- ns1 = axis2_om_element_declare_namespace (element, ns);
- }
- return ns1;
-}
-*/
-
axis2_status_t
axis2_om_element_impl_add_attribute (axis2_environment_t * environment,
struct axis2_om_element * element,
@@ -491,51 +440,6 @@
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_om_node_t * element,
- const axis2_char_t *attribute_name,
- const axis2_char_t *value,
- axis2_om_namespace_t * ns)
-{
- axis2_om_namespace_t *namespace1 = NULL;
- if (!element || element->element_type != AXIS2_OM_ELEMENT)
- {
- return NULL;
- }
- if (ns)
- {
- namespace1 = axis2_om_element_find_namespace (element, ns->uri,
- ns->prefix);
- if (namespace1 == NULL)
- {
- return NULL;
- }
- }
- return axis2_om_element_add_attribute (element,
- axis2_om_attribute_create
- (attribute_name, value, ns));
-}
-*/
-
-/*
-void
-axis2_om_element_set_namespace (axis2_om_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);
- }
- ((axis2_om_element_t *) (node->data_element))->ns = nsp;
- nsp = NULL;
-}
-*/
-
axis2_status_t
axis2_om_element_impl_free (axis2_environment_t * environment,
struct axis2_om_element *element)
@@ -559,7 +463,7 @@
if (element->attributes)
{
/* TODO: free attributes */
- /*need to eterate and free individual attributes */
+ /*need to iterate and free individual attributes */
}
if (element->namespaces)
{
@@ -571,35 +475,6 @@
}
return AXIS2_SUCCESS;
}
-
-/*void
-axis2_om_element_set_localname (axis2_om_node_t * element,
- const axis2_char_t *localname)
-{
- axis2_om_element_t *element = NULL;
- if (!element || element->element_type != AXIS2_OM_ELEMENT)
- {
- return;
- }
- element = (axis2_om_element_t *) (element->data_element);
-
- if (element->localname)
- {
- free (element->localname);
- }
- element->localname = strdup (localname);
-}
-
-axis2_char_t *
-axis2_om_element_get_localname (axis2_om_node_t * element)
-{
- if (!element || element->element_type != AXIS2_OM_ELEMENT)
- {
- return NULL;
- }
- return ((axis2_om_element_t *) (element->data_element))->localname;
-}
-*/
axis2_status_t
axis2_om_element_impl_serialize_start_part (axis2_environment_t * environment,