diff options
Diffstat (limited to 'axiom/include')
46 files changed, 9565 insertions, 0 deletions
diff --git a/axiom/include/Makefile.am b/axiom/include/Makefile.am new file mode 100644 index 0000000..d938299 --- /dev/null +++ b/axiom/include/Makefile.am @@ -0,0 +1 @@ +TESTS = diff --git a/axiom/include/axiom.h b/axiom/include/axiom.h new file mode 100644 index 0000000..38272d6 --- /dev/null +++ b/axiom/include/axiom.h @@ -0,0 +1,57 @@ + +/* + * 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_H +#define AXIOM_H +#include <axiom_node.h> +#include <axiom_attribute.h> +#include <axiom_child_element_iterator.h> +#include <axiom_children_iterator.h> +#include <axiom_children_qname_iterator.h> +#include <axiom_children_with_specific_attribute_iterator.h> +#include <axiom_comment.h> +#include <axiom_doctype.h> +#include <axiom_document.h> +#include <axiom_element.h> +#include <axiom_namespace.h> +#include <axiom_navigator.h> +#include <axiom_output.h> +#include <axiom_processing_instruction.h> +#include <axiom_stax_builder.h> +#include <axiom_text.h> +#include <axiom_data_source.h> +#include <axiom_xml_reader.h> +#include <axiom_xml_writer.h> +#include <axiom_defines.h> + +/** +* @file axiom.h +* @brief includes all headers in OM +*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_H */ diff --git a/axiom/include/axiom_attribute.h b/axiom/include/axiom_attribute.h new file mode 100644 index 0000000..b0a6e8e --- /dev/null +++ b/axiom/include/axiom_attribute.h @@ -0,0 +1,263 @@ + +/* +* 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_ATTRIBUTE_H +#define AXIOM_ATTRIBUTE_H + +/** +* @file axiom_attribute.h +* @brief om attribute struct represents an xml attribute +*/ +#include <axutil_env.h> +#include <axutil_qname.h> +#include <axiom_namespace.h> +#include <axiom_output.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_attribute attribute + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_attribute axiom_attribute_t; + + /** + * creates an om_attribute struct + * @param env Environment. MUST NOT be NULL + * @param localname localname of the attribute, should not be a null value. + * @param value normalized attribute value. cannot be NULL + * @param ns namespace, if any, of the attribute. Optional, can be NULL om_attribute wont free the ns + * @return a pointer to newly created attribute struct, returns NULL on error with + * error code set in environment's error. + */ + AXIS2_EXTERN axiom_attribute_t *AXIS2_CALL + axiom_attribute_create( + const axutil_env_t * env, + const axis2_char_t * localname, + const axis2_char_t * value, + axiom_namespace_t * ns); + + /** + * Free om attribute passed as void pointer. This will be + * cast into appropriate type and then pass the cast object + * into the om_attribute structure's free method + * @param om_attribute pointer to attribute struct to be freed + * @param env Environment. MUST NOT be NULL + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_attribute_free_void_arg( + void *om_attribute, + const axutil_env_t * env); + + /** + * Free an axiom_attribute struct + * @param om_attribute pointer to attribute struct to be freed + * @param env Environment. MUST NOT be NULL + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_attribute_free( + struct axiom_attribute *om_attribute, + const axutil_env_t * env); + + /** + * Creates and returns a qname struct for this attribute + * @param om_attribute pointer to attribute struct + * for which the qname is to be returned + * @param env Environment. MUST NOT be NULL + * @return returns qname for given attribute.NULL on error + */ + + AXIS2_EXTERN axutil_qname_t *AXIS2_CALL + axiom_attribute_get_qname( + struct axiom_attribute *om_attribute, + const axutil_env_t * env); + + /** + * Serialize op + * @param om_attribute pointer to attribute struct to be serialized + * @param env Environment. MUST NOT be NULL, + * @param om_output AXIOM output handler to be used in serializing + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + */ + + AXIS2_EXTERN int AXIS2_CALL + axiom_attribute_serialize( + struct axiom_attribute *om_attribute, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** Returns the localname of this attribute + * @param om_attribute pointer to attribute struct + * @param env environment. MUST NOT not be NULL. + * @return localname returns NULL on error. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_attribute_get_localname( + struct axiom_attribute *om_attribute, + const axutil_env_t * env); + + /** + * returns value of this attribute + *@param om_attribute pointer to om_attribute struct + *@param env environment N not be null + *@return value , null on error + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_attribute_get_value( + struct axiom_attribute *om_attribute, + const axutil_env_t * env); + + /** + * returns namespace of this attribute + *@param om_attribute + *@param env environment MUST NOT be NULL + *@return a pointer to om_namespace struct , returns NULL on error. + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_attribute_get_namespace( + struct axiom_attribute *om_attribute, + const axutil_env_t * env); + + /** sets the localname of the attribute + *@param om_attribute pointer to om attribute struct. + *@param env environment, MUST NOT be null. + *@param localname localname that should be set for this attribute + *@return status code AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_attribute_set_localname( + struct axiom_attribute *om_attribute, + const axutil_env_t * env, + const axis2_char_t * localname); + + /** set the attribute value + *@param om_attribute a pointer to om_attribute struct. + *@param env environment, MUST NOT be NULL. + *@param value value that should be set for this attribute + *@return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_attribute_set_value( + struct axiom_attribute *om_attribute, + const axutil_env_t * env, + const axis2_char_t * value); + + /** set namespace of the attribute + *@param om_attribute a pointer to om_attribute struct + *@param env environment, MUST NOT be NULL. + *@param om_namespace a pointer to om_namespace struct that should be set + * for this attribute + *@return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_attribute_set_namespace( + struct axiom_attribute *om_attribute, + const axutil_env_t * env, + axiom_namespace_t * om_namespace); + + /** + * clones an om attribute + * @param om_attibute + * @param env environment + * @returns pointer to cloned om attribute struct on success + * NULL otherwise + */ + AXIS2_EXTERN struct axiom_attribute *AXIS2_CALL + axiom_attribute_clone( + struct axiom_attribute *om_attribute, + const axutil_env_t * env); + + /** Increment the reference counter. + * @param om_attribute a pointer to om_attribute struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_attribute_increment_ref( + struct axiom_attribute *om_attribute, + const axutil_env_t * env); + + /** Create OM attribute + * @param om_attribute a pointer to om_attribute struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axiom_attribute_t *AXIS2_CALL + axiom_attribute_create_str( + const axutil_env_t * env, + axutil_string_t * localname, + axutil_string_t * value, + axiom_namespace_t * ns); + + /** Get the localname as a string + * @param om_attribute a pointer to om_attribute struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + axiom_attribute_get_localname_str( + axiom_attribute_t * attribute, + const axutil_env_t * env); + + /** Get the value as a string + * @param om_attribute a pointer to om_attribute struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + axiom_attribute_get_value_str( + axiom_attribute_t * attribute, + const axutil_env_t * env); + + /** Set the localname of the attribute + * @param om_attribute a pointer to om_attribute struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_attribute_set_localname_str( + axiom_attribute_t * attribute, + const axutil_env_t * env, + axutil_string_t * localname); + + /** Set the value of the attribute + * @param om_attribute a pointer to om_attribute struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_attribute_set_value_str( + axiom_attribute_t * attribute, + const axutil_env_t * env, + axutil_string_t * value); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_ATTRIBUTE_H */ diff --git a/axiom/include/axiom_child_element_iterator.h b/axiom/include/axiom_child_element_iterator.h new file mode 100644 index 0000000..627a347 --- /dev/null +++ b/axiom/include/axiom_child_element_iterator.h @@ -0,0 +1,124 @@ + +/* + * 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_CHILD_ELEMENT_ITERATOR_H +#define AXIOM_CHILD_ELEMENT_ITERATOR_H + +/** +*@file axiom_child_element_iterator.h +*@brief this is the iterator for om elemnts +*/ + +#include <axiom_node.h> +#include <axiom_text.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_child_element_iterator + axiom_child_element_iterator_t; + + /** + * @defgroup axiom_child_element_iterator child element iterator + * @ingroup axiom_om + * @{ + */ + + /** + * Free the iterator + * @param iterator a pointer to child element iterator struct + * @param env environment, MUST NOT be NULL. + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_child_element_iterator_free( + void *iterator, + const axutil_env_t * env); + + /** + * Removes from the underlying collection the last element returned by the + * iterator (optional op). This method can be called only once per + * call to <tt>next</tt>. The behavior of an iterator is unspecified if + * the underlying collection is modified while the iteration is in + * progress in any way other than by calling this method. + * @param iterator a pointer to child element iterator struct + * @param env environment, MUST NOT be NULL. + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_child_element_iterator_remove( + axiom_child_element_iterator_t * iterator, + const axutil_env_t * env); + + /** + * returns true if the iteration has more elements + * in otherwords it returns true if the next() would return an element + * rather than null with an error code set to environments error + * @param iterator a pointer to child element iterator struct + * @param env environment, MUST NOT be NULL. + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + + axiom_child_element_iterator_has_next( + axiom_child_element_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Returns the next element in the iteration. Returns null if there + * is no more elements + * @param iterator a pointer to child element iterator struct + * @param env environment, MUST NOT be NULL. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_child_element_iterator_next( + axiom_child_element_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Create a child element interator for the current child + * @param current child + * @param env environment, MUST NOT be NULL. + * return axiom_child_element_iterator_t + */ + + AXIS2_EXTERN axiom_child_element_iterator_t *AXIS2_CALL + axiom_child_element_iterator_create( + const axutil_env_t * env, + axiom_node_t * current_child); + +#define AXIOM_CHILD_ELEMENT_ITERATOR_FREE(iterator, env) \ + axiom_child_element_iterator_free(iterator, env) + +#define AXIOM_CHILD_ELEMENT_ITERATOR_REMOVE(iterator, env) \ + axiom_child_element_iterator_remove(iterator, env) + +#define AXIOM_CHILD_ELEMENT_ITERATOR_HAS_NEXT(iterator, env) \ + axiom_child_element_iterator_has_next(iterator, env) + +#define AXIOM_CHILD_ELEMENT_ITERATOR_NEXT(iterator, env) \ + axiom_child_element_iterator_next(iterator, env) + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_CHILD_ELEMENT_ITERATOR_H */ diff --git a/axiom/include/axiom_children_iterator.h b/axiom/include/axiom_children_iterator.h new file mode 100644 index 0000000..c0e802a --- /dev/null +++ b/axiom/include/axiom_children_iterator.h @@ -0,0 +1,123 @@ + +/* + * 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_CHILDREN_ITERATOR_H +#define AXIOM_CHILDREN_ITERATOR_H + +/** +*@file axiom_children_iterator.h +*@brief this is the iterator for om nodes +*/ + +#include <axiom_node.h> +#include <axiom_text.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_children_iterator axiom_children_iterator_t; + + /** + * @defgroup axiom_children_iterator children iterator + * @ingroup axiom_om + * @{ + */ + + /** + * @param current child + * @param env environment + * return axiom_children_iterator_t + */ + + AXIS2_EXTERN axiom_children_iterator_t *AXIS2_CALL + + axiom_children_iterator_create( + const axutil_env_t * env, + axiom_node_t * current_child); + + /** + * Free the om_children_iterator struct + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_children_iterator_free( + axiom_children_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Removes from the underlying collection the last element returned by the + * iterator (optional op). This method can be called only once per + * call to <tt>next</tt>. The behavior of an iterator is unspecified if + * the underlying collection is modified while the iteration is in + * progress in any way other than by calling this method. + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_children_iterator_remove( + axiom_children_iterator_t * iterator, + const axutil_env_t * env); + + /** + * @returns true if the iteration has more elements. In other + * words, returns true if next() would return an om_node_t struct + * rather than null with error code set in environment + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_children_iterator_has_next( + axiom_children_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Returns the next element in the iteration. Returns null if there are + * no more elements in the iteration + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_children_iterator_next( + axiom_children_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Resets the Iterator. This moves the cursor back to the initial. + * iterator chidren_iterator to be reset. + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_children_iterator_reset( + axiom_children_iterator_t * iterator, + const axutil_env_t * env); + + /************ Macros *********************************************/ + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_CHILDREN_ITERATOR_H */ diff --git a/axiom/include/axiom_children_qname_iterator.h b/axiom/include/axiom_children_qname_iterator.h new file mode 100644 index 0000000..f7daa66 --- /dev/null +++ b/axiom/include/axiom_children_qname_iterator.h @@ -0,0 +1,107 @@ + +/* + * 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_CHILDREN_QNAME_ITERATOR_H +#define AXIOM_CHILDREN_QNAME_ITERATOR_H + +/** + *@file axiom_children_qname_iterator.h + *@brief this is the iterator for om nodes using qname + */ + +#include <axiom_node.h> +#include <axiom_namespace.h> +#include <axutil_qname.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_children_qname_iterator + axiom_children_qname_iterator_t; + + /** + * @defgroup axiom_children_qname_iterator children qname iterator + * @ingroup axiom_om + * @{ + */ + + AXIS2_EXTERN axiom_children_qname_iterator_t *AXIS2_CALL + axiom_children_qname_iterator_create( + const axutil_env_t * env, + axiom_node_t * current_child, + axutil_qname_t * given_qname); + + /** + * free om_children_qname_iterator struct + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_children_qname_iterator_free( + axiom_children_qname_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Removes from the underlying collection the last element returned by the + * iterator (optional operation). This method can be called only once per + * call to <tt>next</tt>. The behavior of an iterator is unspecified if + * the underlying collection is modified while the iteration is in + * progress in any way other than by calling this method. + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_children_qname_iterator_remove( + axiom_children_qname_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Returns <tt>true</tt> if the iteration has more elements. (In other + * words, returns <tt>true</tt> if <tt>next</tt> would return an + * axiom_node_t struct rather than null with error code set in environment + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + + axiom_children_qname_iterator_has_next( + axiom_children_qname_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Returns the next element in the iteration. + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_children_qname_iterator_next( + axiom_children_qname_iterator_t * iterator, + const axutil_env_t * env); + + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_CHILDREN_QNAME_ITERATOR_H */ diff --git a/axiom/include/axiom_children_with_specific_attribute_iterator.h b/axiom/include/axiom_children_with_specific_attribute_iterator.h new file mode 100644 index 0000000..cbfb21d --- /dev/null +++ b/axiom/include/axiom_children_with_specific_attribute_iterator.h @@ -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_CHILDREN_WITH_SPECIFIC_ATTRIBUTE_ITERATOR_H +#define AXIOM_CHILDREN_WITH_SPECIFIC_ATTRIBUTE_ITERATOR_H + +/** +*@file axiom_children_with_specific_attribute_iterator.h +*@brief this is the iterator for om nodes +*/ + +#include <axiom_node.h> +#include <axiom_text.h> +#include <axutil_qname.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_children_with_specific_attribute_iterator + axiom_children_with_specific_attribute_iterator_t; + + /** + * @defgroup axiom_children_with_specific_attribute_iterator children with specific attribute iterator + * @ingroup axiom_om + * @{ + */ + + /** + * Free function free the om_children_with_specific_attribute_iterator struct + * @param iterator a pointer to axiom children with specific attribute iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_children_with_specific_attribute_iterator_free( + axiom_children_with_specific_attribute_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Removes from the underlying collection the last element returned by the + * iterator (optional op). This method can be called only once per + * call to <tt>next</tt>. The behavior of an iterator is unspecified if + * the underlying collection is modified while the iteration is in + * progress in any way other than by calling this method. + * @param iterator a pointer to axiom children with specific attribute iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_children_with_specific_attribute_iterator_remove( + axiom_children_with_specific_attribute_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Returns true< if the iteration has more elements. (In other + * words, returns true if next would return an axiom_node_t struct + * rather than NULL with error code set in environment + * @param iterator a pointer to axiom children with specific attribute iterator struct + * @param env environment, MUST NOT be NULL + */ + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_children_with_specific_attribute_iterator_has_next( + axiom_children_with_specific_attribute_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Returns the next element in the iteration. returns null if there is no + * more elements in the iteration + * @param iterator a pointer to axiom children with specific attribute iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_children_with_specific_attribute_iterator_next( + axiom_children_with_specific_attribute_iterator_t * iterator, + const axutil_env_t * env); + + /** + * @param env environment, MUST NOT be NULL + * @param current_child the current child for the interation + * @param attr_qname the qname for the attribute + * @param attr_value the value string for the attribute + * @param detach AXIS2_TRUE to detach AXIS2_FALSE not to + * return axiom_children_with_specific_attribute_iterator_t + */ + + AXIS2_EXTERN axiom_children_with_specific_attribute_iterator_t *AXIS2_CALL + axiom_children_with_specific_attribute_iterator_create( + const axutil_env_t * env, + axiom_node_t * current_child, + axutil_qname_t * attr_qname, + axis2_char_t * attr_value, + axis2_bool_t detach); + +#define AXIOM_CHILDREN_WITH_SPECIFIC_ATTRIBUTE_ITERATOR_FREE(iterator, env) \ + axiom_children_with_specific_attribute_iterator_free(iterator, env) + +#define AXIOM_CHILDREN_WITH_SPECIFIC_ATTRIBUTE_ITERATOR_REMOVE(iterator, env) \ + axiom_children_with_specific_attribute_iterator_remove(iterator, env) + +#define AXIOM_CHILDREN_WITH_SPECIFIC_ATTRIBUTE_ITERATOR_HAS_NEXT(iterator, env) \ + axiom_children_with_specific_attribute_iterator_has_next(iterator, env) + +#define AXIOM_CHILDREN_WITH_SPECIFIC_ATTRIBUTE_ITERATOR_NEXT(iterator, env) \ + axiom_children_with_specific_attribute_iterator_next(iterator, env) + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_CHILDREN_WITH_SPECIFIC_ATTRIBUTE_ITERATOR_H */ diff --git a/axiom/include/axiom_comment.h b/axiom/include/axiom_comment.h new file mode 100644 index 0000000..63d048e --- /dev/null +++ b/axiom/include/axiom_comment.h @@ -0,0 +1,115 @@ + +/* + * 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_COMMENT_H +#define AXIOM_COMMENT_H + +/** + * @file axiom_comment.h + * @brief defines axiom_comment_t struct, and manipulation functions + */ + +#include <axiom_node.h> +#include <axiom_output.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_comment comment + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_comment axiom_comment_t; + + /** + * Creates a comment struct + * @param env Environment. MUST NOT be NULL, + * @param parent This is the parent node of the comment is any, can be NULL. + * @param value comment text + * @param node This is an out parameter.cannot be NULL. + * Returns the node corresponding to the comment created. + * Node type will be set to AXIOM_COMMENT + * @return a pointer to the newly created comment struct + */ + AXIS2_EXTERN axiom_comment_t *AXIS2_CALL + axiom_comment_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * value, + axiom_node_t ** node); + + /** + * Free a axis2_comment_t struct + * @param om_comment pointer to axis2_commnet_t struct to be freed + * @param env Environment. MUST NOT be NULL. + * @return satus of the op. + * AXIS2_SUCCESS on success ,AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_comment_free( + struct axiom_comment *om_comment, + const axutil_env_t * env); + + /** get the comments data + * @param om_comment a pointer to axiom_comment_t struct + * @param env environment, MUST NOT be NULL + * @returns comment text + */ + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_comment_get_value( + struct axiom_comment *om_comment, + const axutil_env_t * env); + + /** + * set comment data + * @param om_comment pointer to axiom_comment_t struct + * @param env environment, MUST NOT be NULL. + * @param value comment text + * @returns AXIS2_SUCCESS on success , AXIS2_FAILURE on error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_comment_set_value( + struct axiom_comment *om_comment, + const axutil_env_t * env, + const axis2_char_t * value); + + /** + * serialize function + * @param om_comment pointer to axiom_comment_t struct + * @param env environment, MUST NOT be NULL. + * @param om_output pointer to om_output_t struct + * @return AXIS2_SUCCESS on success, AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_comment_serialize( + struct axiom_comment *om_comment, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_COMMENT_H */ diff --git a/axiom/include/axiom_data_handler.h b/axiom/include/axiom_data_handler.h new file mode 100644 index 0000000..0cf65c9 --- /dev/null +++ b/axiom/include/axiom_data_handler.h @@ -0,0 +1,260 @@ + +/* + * 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_DATA_HANDLER_H +#define AXIOM_DATA_HANDLER_H + +/** + * @file axiom_data_handler.h + * @brief axis2 data_handler interface + */ + +#include <axutil_utils.h> +#include <axutil_error.h> +#include <axutil_utils_defines.h> +#include <axutil_env.h> +#include <axutil_allocator.h> +#include <axutil_string.h> +#include <axutil_array_list.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef enum axiom_data_handler_type + { + AXIOM_DATA_HANDLER_TYPE_FILE, + AXIOM_DATA_HANDLER_TYPE_BUFFER, + AXIOM_DATA_HANDLER_TYPE_CALLBACK + } axiom_data_handler_type_t; + + typedef struct axiom_data_handler axiom_data_handler_t; + + /** @defgroup axiom_data_handler Flow + * @ingroup axiom_data_handler + * @{ + */ + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_data_handler_get_content_type( + axiom_data_handler_t * data_handler, + const axutil_env_t * env); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @param mime type, + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_data_handler_set_content_type( + axiom_data_handler_t * data_handler, + const axutil_env_t * env, + const axis2_char_t *mime_type); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return bool whether attachment is cached or not + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_data_handler_get_cached( + axiom_data_handler_t * data_handler, + const axutil_env_t * env); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @param cached, + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_data_handler_set_cached( + axiom_data_handler_t * data_handler, + const axutil_env_t * env, + axis2_bool_t cached); + + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_byte_t *AXIS2_CALL + + axiom_data_handler_get_input_stream( + axiom_data_handler_t * data_handler, + const axutil_env_t * env); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN size_t AXIS2_CALL + axiom_data_handler_get_input_stream_len( + axiom_data_handler_t * data_handler, + const axutil_env_t * env); + + /** + * The data_handler is responsible for memory occupied by the stream + * returned + * @param output_stream parameter to store reference to output byte stream. + * @param output_stream_size parameter to store reference to output byte + * stream length + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_data_handler_read_from( + axiom_data_handler_t * data_handler, + const axutil_env_t * env, + axis2_byte_t ** output_stream, + size_t *output_stream_size); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_data_handler_set_binary_data( + axiom_data_handler_t * data_handler, + const axutil_env_t * env, + axis2_byte_t * input_stream, + size_t input_stream_len); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_data_handler_write_to( + axiom_data_handler_t * data_handler, + const axutil_env_t * env); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_data_handler_set_file_name( + axiom_data_handler_t * data_handler, + const axutil_env_t * env, + axis2_char_t * file_name); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return file name, in the case of file type data handler. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_data_handler_get_file_name( + axiom_data_handler_t * data_handler, + const axutil_env_t * env); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_data_handler_free( + axiom_data_handler_t * data_handler, + const axutil_env_t * env); + + /** + * Creates data_handler struct + * @return pointer to newly created data_handler + */ + AXIS2_EXTERN axiom_data_handler_t *AXIS2_CALL + axiom_data_handler_create( + const axutil_env_t * env, + const axis2_char_t * file_name, + const axis2_char_t * mime_type); + + /* Add the binary to the array_list + * @param data_handler, a pointer to data handler struct + * data_handler, a pointer to data handler struct + * list, a pointer to an array_list which containing some message parts need + * to be written to the wire + * data_handler, a pointer to data handler struct + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_data_handler_add_binary_data( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + axutil_array_list_t *list); + + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_data_handler_get_mime_id( + axiom_data_handler_t *data_handler, + const axutil_env_t *env); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @param mime id, + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_data_handler_set_mime_id( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + const axis2_char_t *mime_id); + + + AXIS2_EXTERN axiom_data_handler_type_t AXIS2_CALL + axiom_data_handler_get_data_handler_type( + axiom_data_handler_t *data_handler, + const axutil_env_t *env); + + AXIS2_EXTERN void AXIS2_CALL + axiom_data_handler_set_data_handler_type( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + axiom_data_handler_type_t data_handler_type); + + AXIS2_EXTERN void *AXIS2_CALL + axiom_data_handler_get_user_param( + axiom_data_handler_t *data_handler, + const axutil_env_t *env); + + AXIS2_EXTERN void AXIS2_CALL + axiom_data_handler_set_user_param( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + void *user_param); + + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_DATA_HANDLER_H */ diff --git a/axiom/include/axiom_data_source.h b/axiom/include/axiom_data_source.h new file mode 100644 index 0000000..f892682 --- /dev/null +++ b/axiom/include/axiom_data_source.h @@ -0,0 +1,111 @@ + +/* + * 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_DATA_SOURCE_H +#define AXIOM_DATA_SOURCE_H + +/** + * @file axiom_data_source.h + * @brief Axis2 AXIOM XML data_source + */ + +#include <axutil_env.h> +#include <axiom_node.h> +#include <axiom_output.h> +#include <axutil_stream.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_data_source data_source + * @ingroup axiom_om + * @{ + */ + + /** + * \brief data_source struct + * Handles the XML data_source in OM + */ + typedef struct axiom_data_source axiom_data_source_t; + + /** + * Creates a new data_source struct + * @param env Environment. MUST NOT be NULL, . + * @param parent parent of the new node. Optinal, can be NULL. + * The parent element must be of type AXIOM_ELEMENT + * @param value Text value. Optinal, can be NULL. + * @param comment_node This is an out parameter. cannot be NULL. + * Returns the node corresponding to the data_source struct created. + * Node type will be set to AXIOM_DATA_SOURCE + * @return pointer to newly created data_source struct + */ + AXIS2_EXTERN axiom_data_source_t *AXIS2_CALL + axiom_data_source_create( + const axutil_env_t * env, + axiom_node_t * parent, + axiom_node_t ** node); + + /** + * Free an axiom_data_source struct + * @param env environment. MUST NOT be NULL. + * @param om_data_source pointer to om data_source struct to be freed. + * @return satus of the op. AXIS2_SUCCESS on success + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_data_source_free( + struct axiom_data_source *om_data_source, + const axutil_env_t * env); + + /** + * Serialize op + * @param env environment. MUST NOT be NULL. + * @param om_data_source pointer to om data_source struct to be serialized. + * @param om_output AXIOM output handler to be used in serializing. + * @return satus of the op. AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_data_source_serialize( + struct axiom_data_source *om_data_source, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** + * set the data_source value + * @param om_data_source om_data_source struct + * @param env environment , MUST NOT be NULL. + * @param value data_source + * @return status of the op. AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axutil_stream_t *AXIS2_CALL + axiom_data_source_get_stream( + struct axiom_data_source *om_data_source, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_DATA_SOURCE_H */ diff --git a/axiom/include/axiom_defines.h b/axiom/include/axiom_defines.h new file mode 100644 index 0000000..9cf4b51 --- /dev/null +++ b/axiom/include/axiom_defines.h @@ -0,0 +1,40 @@ + +/* + * 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_DEFINES_H +#define AXIOM_DEFINES_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * This enum is used to decide the type of storage used + */ + typedef enum _axis2_xml_parser_type + { + AXIS2_XML_PARSER_TYPE_BUFFER = 1, + AXIS2_XML_PARSER_TYPE_FILE, + AXIS2_XML_PARSER_TYPE_DOC + } axis2_xml_parser_type; + +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_DEFINES_H */ diff --git a/axiom/include/axiom_doctype.h b/axiom/include/axiom_doctype.h new file mode 100644 index 0000000..a054c6e --- /dev/null +++ b/axiom/include/axiom_doctype.h @@ -0,0 +1,120 @@ + +/* + * 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_DOCTYPE_H +#define AXIOM_DOCTYPE_H + +/** + *@file axiom_doctype.h + *@brief defines struct representing xml DTD and its manipulation functions + */ + +#include <axiom_node.h> +#include <axiom_output.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + struct axiom_doctype; + struct axiom_doctype_ops; + + /** + * @defgroup axiom_doctype doctype + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_doctype axiom_doctype_t; + + /** + * Creates a axiom_doctype_t struct + * @param env Environment. MUST NOT be NULL, + * @param parent parent of the new node. Optinal, can be NULL. + * @param value doctype text + * @param node This is an out parameter.cannot be NULL. + * Returns the node corresponding to the doctype created. + * Node type will be set to AXIOM_DOCTYPE + * @return pointer to newly created doctype struct + */ + AXIS2_EXTERN axiom_doctype_t *AXIS2_CALL + axiom_doctype_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * value, + axiom_node_t ** node); + + /** + * free doctype struct + * @param om_doctype pointer to axiom_doctype_t struct to be freed + * @param env Environment. MUST NOT be NULL, + * @return satus of the op. AXIS2_SUCCESS on success + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_doctype_free( + struct axiom_doctype *om_doctype, + const axutil_env_t * env); + + /** + * @param om_doctype pointer to a axiom_doctype_t struct + * @param env environment must not be null + * @return DTD text + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_doctype_get_value( + struct axiom_doctype *om_doctype, + const axutil_env_t * env); + + /** + * @param om_doctype pointer to axiom doctype_t struct + * @param env environment , MUST NOT be NULL. + * @param value doctype text value + * @return status of the op, + * AXIS2_SUCCESS on success, AXIS2_FAILURE on error. + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_doctype_set_value( + struct axiom_doctype *om_doctype, + const axutil_env_t * env, + const axis2_char_t * value); + + /** + * serialize op + * @param om_doctype pointer to axiom_doctype_t struct + * @param env environment , MUST NOT be NULL + * @param om_output pointer to axiom_output_t struct + * @returns status of the op, + * AXIS2_SUCCESS on success, AXIS2_FAILURE on error. + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_doctype_serialize( + struct axiom_doctype *om_doctype, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_DOCTYPE_H */ diff --git a/axiom/include/axiom_document.h b/axiom/include/axiom_document.h new file mode 100644 index 0000000..ac014df --- /dev/null +++ b/axiom/include/axiom_document.h @@ -0,0 +1,173 @@ + +/* + * 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_H +#define AXIOM_DOCUMENT_H + +#include <axutil_env.h> +#include <axiom_node.h> +#include <axutil_utils_defines.h> +#include <axiom_output.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @file axiom_document.h + * @brief om_document represents an XML document + */ + +#define CHAR_SET_ENCODING "UTF-8" +#define XML_VERSION "1.0" + + struct axiom_stax_builder; + + /** + * @defgroup axiom_document document + * @ingroup axiom_om + * @{ + */ + + 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. + * @return returns a pointer to the root node. If no root present, + * this method tries to build the root. Returns NULL on error. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_document_get_root_element( + 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_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. + * @param env environment MUST NOT be NULL. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_document_build_all( + 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 +} +#endif + +#endif /* AXIOM_DOCUMENT_H */ diff --git a/axiom/include/axiom_element.h b/axiom/include/axiom_element.h new file mode 100644 index 0000000..ceb4417 --- /dev/null +++ b/axiom/include/axiom_element.h @@ -0,0 +1,747 @@ + +/* + * 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_ELEMENT_H +#define AXIOM_ELEMENT_H + +#include <axiom_namespace.h> +#include <axiom_attribute.h> +#include <axiom_output.h> +#include <axiom_node.h> +#include <axiom_children_iterator.h> +#include <axiom_children_qname_iterator.h> +#include <axiom_child_element_iterator.h> +#include <axutil_hash.h> +#include <axutil_utils.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_element axiom_element_t; + + /** + * @defgroup axiom_element element + * @ingroup axiom_om + * @{ + */ + + /** + * Creates an AXIOM element with given local name + * @param env Environment. MUST NOT be NULL. + * @param parent parent of the element node to be created. can be NULL. + * @param localname local name of the elment. cannot be NULL. + * @param ns namespace of the element. can be NULL. + * If the value of the namespace has not already been declared + * then the namespace structure ns will be declared and will be + * freed when the tree is freed. + * If the value of the namespace has already been declared using + * another namespace structure then the namespace structure ns + * will be freed. + * @param node This is an out parameter. cannot be NULL. + * Returns the node corresponding to the comment created. + * Node type will be set to AXIOM_ELEMENT + * @return a pointer to the newly created element struct + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_element_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * localname, + axiom_namespace_t * ns, + axiom_node_t ** node); + + /** + * Creates an AXIOM element with given qname + * @param env Environment. MUST NOT be NULL. + * @param parent parent of the element node to be created. can be NULL. + * @param qname qname of the elment.cannot be NULL. + * @param node This is an out parameter. cannot be NULL. + * Returns the node corresponding to the comment created. + * Node type will be set to AXIOM_ELEMENT + * @return a pointer to the newly created element struct + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_element_create_with_qname( + const axutil_env_t * env, + axiom_node_t * parent, + const axutil_qname_t * qname, + axiom_node_t ** node); + /* + * Find a namespace in the scope of the document. + * Start to find from the given node and go up the hierarchy. + * @param om_element pointer to om_element_struct contained in + * node , + * @param env Environment. MUST NOT be NULL. + * @param node node containing an instance of an AXIOM element,cannot be NULL. + * @param uri namespace uri.. + * @param prefix namespace prefix. can be NULL. + * @return pointer to the namespace, if found, else NULL. On error, returns + * NULL and sets error code in environment,s error + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_element_find_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_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 ). + * It checks to see if it is already declared. + * @param om_element contained in the om node struct + * @param env Environment. MUST NOT be NULL. + * @param node node containing an instance of an AXIOM element. + * @param ns pointer to the namespace struct to be declared + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_declare_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * node, + axiom_namespace_t * ns); + /** + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + * + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_declare_namespace_assume_param_ownership( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_namespace_t * ns); + + /** + * Finds a namespace using qname + * Start to find from the given node and go up the hierarchy. + * @param om_element om_element contained in node + * @param env Environment. MUST NOT be NULL. + * @param node node containing an instance of an AXIOM element, cannot be NULL. + * @param qname qname of the namespace to be found. cannot be NULL. + * @return pointer to the namespace, if found, else NULL. On error, returns + * NULL and sets the error code in environment's error struct. + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_element_find_namespace_with_qname( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * node, + axutil_qname_t * qname); + + /** + * Adds an attribute to current element The current element takes responsibility of the assigned attribute + * @param om_element element to which the attribute is to be added.cannot be NULL. + * @param env Environment. MUST NOT be NULL. + * @param attribute attribute to be added. + * @param node axiom_node_t node that om_element is contained in + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_add_attribute( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_attribute_t * attribute, + axiom_node_t * node); + + /** + * Gets (finds) the attribute with the given qname + * @param element element whose attribute is to be found. + * @param env Environment. MUST NOT be NULL. + * @qname qname qname of the attribute to be found. should not be NULL. + * @return a pointer to the attribute with given qname if found, else NULL. + * On error, returns NULL and sets the error code in environment's error struct. + */ + AXIS2_EXTERN axiom_attribute_t *AXIS2_CALL + axiom_element_get_attribute( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_qname_t * qname); + + /** + * Gets (finds) the attribute value with the given qname + * @param element element whose attribute is to be found. + * @param env Environment. MUST NOT be NULL. + * @qname qname qname of the attribute to be found. should not be NULL. + * @return the attribute value with given qname if found, else NULL. + * On error, returns NULL and sets the error code in environment's error struct. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_element_get_attribute_value( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_qname_t * qname); + + /** + * Frees given element + * @param element AXIOM element to be freed. + * @param env Environment. MUST NOT be NULL. + * @return satus of the op. AXIS2_SUCCESS on success ,AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_element_free( + axiom_element_t * element, + const axutil_env_t * env); + + /** + * Serializes the start part of the given element + * @param element element to be serialized. + * @param env Environment. MUST NOT be NULL. + * @param om_output AXIOM output handler to be used in serializing + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_serialize_start_part( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_output_t * om_output, + axiom_node_t * ele_node); + + /** + * Serializes the end part of the given element. serialize_start_part must + * have been called before calling this method. + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * @param om_output AXIOM output handler to be used in serializing + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_serialize_end_part( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** + * finds a namespace in current element's scope, + * by uri or prefix or both + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param uri namespace uri, may be null + * @param prefix prefix + * @return axiom_namespace_t if found, else return NULL + */ + + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_element_find_declared_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + const axis2_char_t * uri, + const axis2_char_t * prefix); + + /** + * returns the localname of this element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @returns localname of element, returns NULL on error. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_element_get_localname( + axiom_element_t * om_element, + const axutil_env_t * env); + + /** + * set the localname of this element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @localname text value to be set as localname + * @returns status code of op, AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_set_localname( + axiom_element_t * om_element, + const axutil_env_t * env, + const axis2_char_t * localname); + + /** + * get the namespace of om_element + * @param om_element om_element struct + * @param env environemt, MUST NOT be NULL. + * @returns pointer to axiom_namespace_t struct + * NULL if there is no namespace associated with the element, + * NULL on error with error code set to environment's error + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_element_get_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * ele_node); + + /** + * set the namespace of the element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param ns pointer to namespace + * If the value of the namespace has not already been declared + * then the namespace structure ns will be declared and will be + * freed when the tree is freed. + * @returns status code of the op, with error code + * set to environment's error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_set_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_namespace_t * ns, + axiom_node_t * node); + + + /** + * unconditionally set the namespace of the element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param ns pointer to namespace + * The namespace ns is assumed to have been declared already. + * @returns status code of the op, with error code + * set to environment's error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_set_namespace_assume_param_ownership( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_namespace_t * ns); + + /** + * get the attribute list of the element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @returns axutil_hash poiner to attributes hash + * This hash table is read only + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_element_get_all_attributes( + axiom_element_t * om_element, + const axutil_env_t * env); + + /** + * get the namespace list of the element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @returns axutil_hash pointer to namespaces hash + * this hash table is read only + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_element_get_namespaces( + axiom_element_t * om_element, + const axutil_env_t * env); + + /** + *@return qname of this element + * the returned qname should not be externaly freed + * when om_element struct is freed qname is also + * freed + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param ele_node pointer to this element node + * + * @returns axutil_qname_t struct , NULL on failure + */ + AXIS2_EXTERN axutil_qname_t *AXIS2_CALL + axiom_element_get_qname( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * ele_node); + + /** + * returns a list of children iterator + * returned iterator is freed when om_element struct + * is freed + * iterators reset function must be called by user + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param element_node pointer to this element node + * + */ + AXIS2_EXTERN axiom_children_iterator_t *AXIS2_CALL + axiom_element_get_children( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node); + + /** + * returns a list of children iterator with qname + * returned iterator is freed when om element struct + * is freed + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param element_node pointer to this element node + * @returns children qname iterator struct + */ + + AXIS2_EXTERN axiom_children_qname_iterator_t *AXIS2_CALL + axiom_element_get_children_with_qname( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_qname_t * element_qname, + axiom_node_t * element_node); + + /** + * Returns the om_element corresponding to element_qname + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param element_qname qname of the element + * @param om_node pointer to this element node + * @param element_node + * @param child_node + * @returns children qname iterator struct + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_element_get_first_child_with_qname( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_qname_t * element_qname, + axiom_node_t * element_node, + axiom_node_t ** child_node); + + /** + * removes an attribute from the element attribute list + * user must free this attribute, element free function does not free + * attributes that are not is it's attribute list + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_attribute attribute to be removed + * @return AXIS2_SUCCESS if attribute was found and removed, else + * AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_remove_attribute( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_attribute_t * om_attribute); + + /** + * Sets the text of the given element. + * caution - This method will wipe out all the text elements (and hence any + * mixed content) before setting the text + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param text text to set. + * @param element_node node of element. + * @return AXIS2_SUCCESS if attribute was found and removed, else + * AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_set_text( + axiom_element_t * om_element, + const axutil_env_t * env, + const axis2_char_t * text, + axiom_node_t * element_node); + + /** + * Select all the text children and concat them to a single string. The string + * returned by this method call will be free by axiom when this method is called again. + * So it is recomended to have a copy of the return value if this method is going to + * be called more that once and the return values of the earlier calls are important. + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param element node , the container node of this om element + * @return the contanated text of all text childrens text values + * return null if no text children is avilable or on error + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_element_get_text( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node); + + /** + * returns the first child om element of this 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 + * @return om_element if one is availble otherwise return NULL + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_element_get_first_element( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node, + axiom_node_t ** first_element_node); + + /** + * returns the serilized text of this element and its children + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param element_node the container node this on element is contained + * @return a char array of xml , returns NULL on error + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_element_to_string( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node); + + /** + * returns an iterator with child elements of type AXIOM_ELEMENT + * iterator is freed when om_element node is freed + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param element_node + * @returns axiom_child_element_iterator_t , NULL on error + */ + AXIS2_EXTERN axiom_child_element_iterator_t *AXIS2_CALL + axiom_element_get_child_elements( + axiom_element_t * om_element, + 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, + * @param om_element pointer to om element + * @param env axutil_environment MUST Not be NULL + * @param element_node corresponding om element node of this om element + * @returns pointer to default namespace if availale , NULL otherwise + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_element_get_default_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node); + + /** + * declared a default namespace explicitly + * @param om_element pointer to om element + * @param env environment MUST not be NULL + * @param uri namespace uri of the default namespace + * @returns the declared namespace + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_element_declare_default_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axis2_char_t * uri); + + /** + * checks for the namespace in the context of this element + * with the given prefix + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_element_node pointer to this element node + * @returns pointer to relevent namespace + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_element_find_namespace_uri( + axiom_element_t * om_element, + const axutil_env_t * env, + const axis2_char_t * prefix, + axiom_node_t * element_node); + + /** + *This will not search the namespace in the scope nor will + * declare in the current element, as in set_namespace. This will + * just assign the given namespace to the element. + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * @param om_ns pointer to namespace to be set + * @returns + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_set_namespace_with_no_find_in_current_scope( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_namespace_t * om_ns); + + /** + * Extract attributes , returns a clones hash table of attributes, + * if attributes are associated with a namespace it is also cloned + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_element_extract_attributes( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * ele_node); + + /** + * Returns the attribute value as a string for the given element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param attr_name the attribute name + * + * @return the attribute value as a string + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_element_get_attribute_value_by_name( + axiom_element_t * om_ele, + const axutil_env_t * env, + axis2_char_t * attr_name); + + /** + * Create an OM Element and an OM node from given string params + * @param env environment MUST not be NULL + * @param parent pointer to this parent element node + * @param localname the locanmae of the element + * @param ns the namespace of the element + * @param node the reference ot the created node + * @return + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_element_create_str( + const axutil_env_t * env, + axiom_node_t * parent, + axutil_string_t * localname, + axiom_namespace_t * ns, + axiom_node_t ** node); + + /** + * Returns the Local name of the element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * + * @return the Local name of the element + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + axiom_element_get_localname_str( + axiom_element_t * om_element, + const axutil_env_t * env); + + /** + * Set the Local name of the element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param localname the Local name of the element + * + * @return + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_set_localname_str( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_string_t * localname); + + /** + * Return whether the element is empty or not + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * + * @return AXIS2_TRUE if empty AXIS2_FALSE if not empty + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_element_get_is_empty( + axiom_element_t * om_element, + const axutil_env_t * env); + + /** + * Set whether the element is empty or not + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param is_empty AXIS2_TRUE if empty AXIS2_FALSE if not empty + * + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_element_set_is_empty( + axiom_element_t * om_element, + const axutil_env_t * env, + axis2_bool_t is_empty); + + /** + * Collect all the namespaces with distinct prefixes in + * the parents of the given element. Effectively this + * is the set of namespaces declared above this element + * that are inscope at this element and might be used + * by it or its children. + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * @returns pointer to hash of relevent namespaces + */ + AXIS2_EXTERN axutil_hash_t * AXIS2_CALL + axiom_element_gather_parent_namespaces( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * om_node); + + /** + * If the provided namespace used by the provided element + * is one of the namespaces from the parent of the root + * root element, redeclares that namespace at the root element + * and removes it from the hash of parent namespaces + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * @param ns pointer to namespace to redeclare + * @param root_element pointer to the subtree root element node + * @param inscope_namespaces pointer to hash of parent namespaces + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_element_use_parent_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * om_node, + axiom_namespace_t *ns, + axiom_element_t * root_element, + axutil_hash_t *inscope_namespaces); + + /** + * Examines the subtree beginning at the provided element + * For each element or attribute, if it refers to a namespace + * declared in a parent of the subtree root element, redeclares + * that namespace at the level of the subtree root and removes + * it from the set of parent namespaces in scope and not yet + * declared + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * + * @param root_element pointer to the subtree root element node + * @param inscope_namespaces pointer to hash of parent namespaces + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_element_redeclare_parent_namespaces( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * om_node, + axiom_element_t * root_element, + axutil_hash_t *inscope_namespaces); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_ELEMENT_H */ diff --git a/axiom/include/axiom_mime_const.h b/axiom/include/axiom_mime_const.h new file mode 100644 index 0000000..e75fbd7 --- /dev/null +++ b/axiom/include/axiom_mime_const.h @@ -0,0 +1,56 @@ + +/* + * 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_MIME_CONST_H +#define AXIOM_MIME_CONST_H + +/** +* @file axiom.h +* @brief includes all headers in MIME_CONST +*/ +#ifdef __cplusplus +extern "C" +{ +#endif + +#define AXIOM_MIME_BOUNDARY_BYTE 45 +#define AXIOM_MIME_CRLF_BYTE 13 + +#define AXIOM_MIME_TYPE_XOP_XML "application/xop+xml" +#define AXIOM_MIME_TYPE_MULTIPART_RELATED "multipart/related" +#define AXIOM_MIME_TYPE_OCTET_STREAM "application/octet-stream" + +#define AXIOM_MIME_HEADER_FIELD_CHARSET "charset" +#define AXIOM_MIME_HEADER_FIELD_TYPE "type" +#define AXIOM_MIME_HEADER_FIELD_BOUNDARY "boundary" +#define AXIOM_MIME_HEADER_FIELD_START_INFO "start-info" +#define AXIOM_MIME_HEADER_FIELD_START "start" + +#define AXIOM_MIME_HEADER_CONTENT_TYPE "content-type" +#define AXIOM_MIME_HEADER_CONTENT_TRANSFER_ENCODING "content-transfer-encoding" +#define AXIOM_MIME_HEADER_CONTENT_ID "content-id" + +#define AXIOM_MIME_CONTENT_TRANSFER_ENCODING_BINARY "binary" + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_MIME_CONST_H */ diff --git a/axiom/include/axiom_mime_parser.h b/axiom/include/axiom_mime_parser.h new file mode 100644 index 0000000..b7f4f00 --- /dev/null +++ b/axiom/include/axiom_mime_parser.h @@ -0,0 +1,220 @@ + +/* + * 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_MIME_PARSER_H +#define AXIOM_MIME_PARSER_H + +/** + * @file axiom_mime_parser.h + * @brief axis2 mime_parser interface + */ + +#include <axutil_utils.h> +#include <axutil_error.h> +#include <axutil_utils_defines.h> +#include <axutil_env.h> +#include <axutil_allocator.h> +#include <axutil_string.h> +#include <axutil_hash.h> +#include <axiom_mime_const.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define AXIOM_MIME_PARSER_BUFFER_SIZE (1024 * 1024/2) +#define AXIOM_MIME_PARSER_MAX_BUFFERS 1000 + +#define AXIOM_MIME_PARSER_END_OF_MIME_MAX_COUNT 100 + + + typedef struct axiom_mime_parser axiom_mime_parser_t; + + /** @defgroup axiom_mime_parser Flow + * @ingroup axiom_mime_parser + * @{ + */ + + /** + * Parse and returns mime parts as a hash map + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @param callback_ctx the callback context + * @param mime_boundary the MIME boundary + * @return mime parts as a hash map + */ + /*AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_mime_parser_parse( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK, + void *callback_ctx, + axis2_char_t * mime_boundary);*/ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_mime_parser_parse_for_soap( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback, + void *callback_ctx, + axis2_char_t * mime_boundary); + + + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_mime_parser_parse_for_attachments( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback, + void *callback_ctx, + axis2_char_t * mime_boundary, + void *user_param); + + + /** + * Returns mime parts as a hash map + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @return mime parts as a hash map + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_mime_parser_get_mime_parts_map( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env); + + /** + * Deallocate memory. Free the mime parser struct + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_parser_free( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env); + + /** + * Returns the length of the SOAP Body + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @return the length of the SOAP Body + */ + AXIS2_EXTERN size_t AXIS2_CALL + axiom_mime_parser_get_soap_body_len( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env); + + /** + * Get the SOAP Body as a string + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @return the SOAP Body as a string + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_mime_parser_get_soap_body_str( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env); + + /** + * Create a mime parser struct + * @param env Environment. MUST NOT be NULL. + * @return created mime parser + */ + AXIS2_EXTERN axiom_mime_parser_t *AXIS2_CALL + axiom_mime_parser_create( + const axutil_env_t * env); + + /** + * Set the size of the chink buffer + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @param size the size of the chink buffer + * @return mime parts as a hash map + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_parser_set_buffer_size( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env, + int size); + + /** + * Set maximum number of chunk buffers + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @param num maximum number of chunk buffers + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_parser_set_max_buffers( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env, + int num); + + + /** + * Set attachment dir specified in the axis2.xml + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @param attachment_dir is string containg the directory path + * @return VOID + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_parser_set_attachment_dir( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + axis2_char_t *attachment_dir); + + + /** + * Set Caching callback name specified in the axis2.xml + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @param callback_name is string containg the dll path + * @return VOID + */ + + + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_parser_set_caching_callback_name( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + axis2_char_t *callback_name); + + + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_parser_set_mime_boundary( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + axis2_char_t *mime_boundary); + + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_mime_parser_get_mime_boundary( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env); + + + + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_MIME_PARSER_H */ diff --git a/axiom/include/axiom_mime_part.h b/axiom/include/axiom_mime_part.h new file mode 100644 index 0000000..e4cfc36 --- /dev/null +++ b/axiom/include/axiom_mime_part.h @@ -0,0 +1,131 @@ +/* + * 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_MIME_PART_H +#define AXIOM_MIME_PART_H + +/** + * @file axiom_mime_part.h + * @brief axis2 mime_part interface + */ + +#include <axutil_utils.h> +#include <axutil_error.h> +#include <axutil_utils_defines.h> +#include <axutil_env.h> +#include <axutil_allocator.h> +#include <axutil_string.h> +#include <axutil_array_list.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_mime_part_t axiom_mime_part_t; + + + /* An enum to keep different mime_part types */ + + typedef enum axiom_mime_part_type_t + { + + /** Char buffer */ + AXIOM_MIME_PART_BUFFER = 0, + + /* A file */ + AXIOM_MIME_PART_FILE, + + /* User specified callback */ + AXIOM_MIME_PART_CALLBACK, + + /* unknown type*/ + AXIOM_MIME_PART_UNKNOWN + + } axiom_mime_part_type_t; + + struct axiom_mime_part_t + { + /* This is when the mime part is a buffer. + * This will be null when the part is a file */ + axis2_byte_t *part; + + /* This is to keep file name when the part is a file + * NULL when the part is a buffer */ + axis2_char_t *file_name; + + /* Size of the part. In the case of buffer this is + * the buffer size and in the case of file this is + the file size */ + size_t part_size; + + /* This is one from the above defined enum */ + axiom_mime_part_type_t type; + + /* This is required in the case of the callback */ + void *user_param; + }; + + + + + AXIS2_EXTERN const axis2_char_t *AXIS2_CALL + axiom_mime_part_get_content_type_for_mime( + const axutil_env_t * env, + axis2_char_t * boundary, + axis2_char_t * content_id, + axis2_char_t * char_set_encoding, + const axis2_char_t * soap_content_type); + + + /** + * Creates mime_part struct + * @return pointer to newly created mime_part + */ + + AXIS2_EXTERN axiom_mime_part_t *AXIS2_CALL + axiom_mime_part_create( + const axutil_env_t *env); + + /* This method will create the output part + * list.*/ + + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + axiom_mime_part_create_part_list( + const axutil_env_t *env, + axis2_char_t *soap_body, + axutil_array_list_t *binary_node_list, + axis2_char_t *boundary, + axis2_char_t *content_id, + axis2_char_t *char_set_encoding, + const axis2_char_t *soap_content_type); + + + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_part_free( + axiom_mime_part_t *mime_part, + const axutil_env_t *env); + + + + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_MIME_PART_H */ diff --git a/axiom/include/axiom_mtom_caching_callback.h b/axiom/include/axiom_mtom_caching_callback.h new file mode 100644 index 0000000..e432b2f --- /dev/null +++ b/axiom/include/axiom_mtom_caching_callback.h @@ -0,0 +1,114 @@ +/* +* 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_MTOM_CACHING_CALLBACK_H +#define AXIOM_MTOM_CACHING_CALLBACK_H + +/** + * @file axiom_mtom_caching_callback.h + * @brief Caching callback for mime parser + */ + +/** +* @defgroup caching_callback +* @ingroup axiom +* @{ +*/ + +#include <axutil_env.h> +#include <axutil_param.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * Type name for struct axiom_mtom_caching_callback_ops + */ + typedef struct axiom_mtom_caching_callback_ops axiom_mtom_caching_callback_ops_t; + + /** + * Type name for struct axiom_mtom_caching_callback + */ + typedef struct axiom_mtom_caching_callback axiom_mtom_caching_callback_t; + + + /** + * init_handler will init the caching storage + */ + + /** + * cache will write the data to the storage + */ + + /** + * close_handler will close the storage + */ + + struct axiom_mtom_caching_callback_ops + { + void* (AXIS2_CALL* + init_handler)(axiom_mtom_caching_callback_t *mtom_caching_callback, + const axutil_env_t* env, + axis2_char_t *key); + + axis2_status_t (AXIS2_CALL* + cache)(axiom_mtom_caching_callback_t *mtom_caching_callback, + const axutil_env_t* env, + axis2_char_t *data, + int length, + void *handler); + + axis2_status_t (AXIS2_CALL* + close_handler)(axiom_mtom_caching_callback_t *mtom_caching_callback, + const axutil_env_t* env, + void *handler); + + axis2_status_t (AXIS2_CALL* + free)(axiom_mtom_caching_callback_t *mtom_caching_callback, + const axutil_env_t* env); + }; + + struct axiom_mtom_caching_callback + { + axiom_mtom_caching_callback_ops_t *ops; + axutil_param_t *param; + void *user_param; + }; + + /*************************** Function macros **********************************/ +#define AXIOM_MTOM_CACHING_CALLBACK_INIT_HANDLER(mtom_caching_callback, env, key) \ + ((mtom_caching_callback)->ops->init_handler(mtom_caching_callback, env, key)) + +#define AXIOM_MTOM_CACHING_CALLBACK_CACHE(mtom_caching_callback, env, data, length, handler) \ + ((mtom_caching_callback)->ops->cache(mtom_caching_callback, env, data, length, handler)) + +#define AXIOM_MTOM_CACHING_CALLBACK_CLOSE_HANDLER(mtom_caching_callback, env, handler) \ + ((mtom_caching_callback)->ops->close_handler(mtom_caching_callback, env, handler)) + +#define AXIOM_MTOM_CACHING_CALLBACK_FREE(mtom_caching_callback, env) \ + ((mtom_caching_callback)->ops->free(mtom_caching_callback, env)) + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_MTOM_CACHING_CALLBACK */ + + diff --git a/axiom/include/axiom_mtom_sending_callback.h b/axiom/include/axiom_mtom_sending_callback.h new file mode 100644 index 0000000..ce2587e --- /dev/null +++ b/axiom/include/axiom_mtom_sending_callback.h @@ -0,0 +1,112 @@ +/* +* 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_MTOM_SENDING_CALLBACK_H +#define AXIOM_MTOM_SENDING_CALLBACK_H + +/** + * @file axiom_mtom_sending_callback.h + * @brief sending callback for attachment sending + */ + +/** +* @defgroup mtom_sending_callback +* @ingroup axiom +* @{ +*/ + +#include <axutil_env.h> +#include <axutil_param.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * Type name for struct axiom_mtom_sending_callback_ops + */ + typedef struct axiom_mtom_sending_callback_ops axiom_mtom_sending_callback_ops_t; + + /** + * Type name for struct axiom_mtom_sending_callback + */ + typedef struct axiom_mtom_sending_callback axiom_mtom_sending_callback_t; + + + /** + * init_handler will init the attachment storage + */ + + /** + * load will read the attachemnt by part from the storage + */ + + /** + * close_handler will close the storage + */ + + struct axiom_mtom_sending_callback_ops + { + void* (AXIS2_CALL* + init_handler)(axiom_mtom_sending_callback_t *mtom_sending_callback, + const axutil_env_t* env, + void *user_param); + + int (AXIS2_CALL* + load_data)(axiom_mtom_sending_callback_t *mtom_sending_callback, + const axutil_env_t* env, + void *handler, + axis2_char_t **buffer); + + axis2_status_t (AXIS2_CALL* + close_handler)(axiom_mtom_sending_callback_t *mtom_sending_callback, + const axutil_env_t* env, + void *handler); + + axis2_status_t (AXIS2_CALL* + free)(axiom_mtom_sending_callback_t *mtom_sending_callback, + const axutil_env_t* env); + }; + + struct axiom_mtom_sending_callback + { + axiom_mtom_sending_callback_ops_t *ops; + axutil_param_t *param; + }; + + /*************************** Function macros **********************************/ +#define AXIOM_MTOM_SENDING_CALLBACK_INIT_HANDLER(mtom_sending_callback, env, user_param) \ + ((mtom_sending_callback)->ops->init_handler(mtom_sending_callback, env, user_param)) + +#define AXIOM_MTOM_SENDING_CALLBACK_LOAD_DATA(mtom_sending_callback, env, handler, buffer) \ + ((mtom_sending_callback)->ops->load_data(mtom_sending_callback, env, handler, buffer)) + +#define AXIOM_MTOM_SENDING_CALLBACK_CLOSE_HANDLER(mtom_sending_callback, env, handler) \ + ((mtom_sending_callback)->ops->close_handler(mtom_sending_callback, env, handler)) + +#define AXIOM_MTOM_SENDING_CALLBACK_FREE(mtom_sending_callback, env) \ + ((mtom_sending_callback)->ops->free(mtom_sending_callback, env)) + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_MTOM_SENDING_CALLBACK */ + + diff --git a/axiom/include/axiom_namespace.h b/axiom/include/axiom_namespace.h new file mode 100644 index 0000000..73ccf17 --- /dev/null +++ b/axiom/include/axiom_namespace.h @@ -0,0 +1,201 @@ + +/* + * 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_NAMESPACE_H +#define AXIOM_NAMESPACE_H + +#include <axutil_utils_defines.h> +#include <axutil_env.h> +#include <axiom_output.h> +#include <axutil_string.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_namespace namespace + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_namespace axiom_namespace_t; + + /** + * Creates a namespace struct + * @param uri namespace URI + * @param prefix namespace prefix + * @return a pointer to newly created namespace struct + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_namespace_create( + const axutil_env_t * env, + const axis2_char_t * uri, + const axis2_char_t * prefix); + + /** + * Frees given AXIOM namespcae + * @param om_namespace namespace 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_namespace_free( + struct axiom_namespace *om_namespace, + const axutil_env_t * env); + + /** + * Compares two namepsaces + * @param om_namespace first namespase to be compared + * @param env Environment. MUST NOT be NULL. + * @param om_namespace1 second namespace to be compared + * @return AXIS2_TRUE if the two namespaces are equal,AXIS2_FALSE otherwise + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_namespace_equals( + struct axiom_namespace *om_namespace, + const axutil_env_t * env, + struct axiom_namespace *om_namespace1); + + /** + * Serializes given namespace + * @param om_namespace namespace to be serialized. + * @param env Environment. MUST NOT be NULL. + * @param om_output AXIOM output handler to be used in serializing + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_namespace_serialize( + struct axiom_namespace *om_namespace, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** + * @param om_namespace pointer to om_namespace struct + * @param env environment , MUST NOT be NULL. + * @returns namespace uri , NULL on error + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_namespace_get_uri( + struct axiom_namespace *om_namespace, + const axutil_env_t * env); + + /** + * @param om_namespace pointer to om namespace struct + * @param env environment, MUST NOT be NULL + * @return prefix , NULL on error + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_namespace_get_prefix( + struct axiom_namespace *om_namespace, + const axutil_env_t * env); + + /** + * Clones an om_namespace struct + * @param om_namespace pointer to namespace struct + * @param env Environment. MUST NOT be NULL + * @returns axiom_namespace on success , NULL on error + */ + AXIS2_EXTERN struct axiom_namespace *AXIS2_CALL + axiom_namespace_clone( + struct axiom_namespace *om_namespace, + const axutil_env_t * env); + + /** + * to string , returns the string by combining namespace_uri, + * and prefix seperated by a '|' character + * @param om_namespace + * @param env Environment. MUST NOT be NULL + * @returns pointer to string , This is a property of namespace, + * should not be freed by user + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_namespace_to_string( + struct axiom_namespace *om_namespace, + const axutil_env_t * env); + + /** + * Incerament the reference value. The struct will be freed when the ref value is zero + * @param om_namespace pointer to the axiom namespace struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_namespace_increment_ref( + struct axiom_namespace *om_namespace, + const axutil_env_t * env); + + /** + * Create an OM namespace from a URI and a Prefix + * @param om_namespace pointer to the axiom namespace struct + * @param env Environment. MUST NOT be NULL + * + * @return created OM namespace + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_namespace_create_str( + const axutil_env_t * env, + axutil_string_t * uri, + axutil_string_t * prefix); + + /** + * Set the uri string + * @param om_namespace pointer to the axiom namespace struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_namespace_set_uri_str( + axiom_namespace_t * om_namespace, + const axutil_env_t * env, + axutil_string_t * uri); + + /** + * Get the uri as a string + * @param om_namespace pointer to the axiom namespace struct + * @param env Environment. MUST NOT be NULL + * + * @return the uri as a string + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + axiom_namespace_get_uri_str( + axiom_namespace_t * om_namespace, + const axutil_env_t * env); + + /** + * Get the prefix as a string + * @param om_namespace pointer to the axiom namespace struct + * @param env Environment. MUST NOT be NULL + * + * @return the prefix as a string + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + axiom_namespace_get_prefix_str( + axiom_namespace_t * om_namespace, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_NAMESPACE */ diff --git a/axiom/include/axiom_navigator.h b/axiom/include/axiom_navigator.h new file mode 100644 index 0000000..6ff8b53 --- /dev/null +++ b/axiom/include/axiom_navigator.h @@ -0,0 +1,121 @@ + +/* + * 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_NAVIGATOR_H +#define AXIOM_NAVIGATOR_H + +#include <axutil_utils.h> +#include <axutil_env.h> +#include <axiom_node.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_navigator navigator + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_navigator axiom_navigator_t; + + /** Creates an axiom_navigator + * @param env environment MUST not be NULL + * @param node a pointer to axiom_node_t struct + * which is to be navigated + * @returns a pointer to axiom_navigator_t struct + * or returns NULL on error + */ + AXIS2_EXTERN axiom_navigator_t *AXIS2_CALL + axiom_navigator_create( + const axutil_env_t * env, + axiom_node_t * node); + + /** + * free function , free the axiom_navigator struct + * @param om_navigator axiom_navigator_struct + * @param env environment MUST not be NULL + * @returns AXIS2_SUCCESS + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_navigator_free( + axiom_navigator_t * om_navigator, + const axutil_env_t * env); + + /** + * Returns the navigable status + * @param om_navigator axiom_navigator_struct + * @param env environment MUST not be NULL + * @returns AXIS2_TRUE if the om is navigable + * otherwise returns AXIS2_FALSE + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_navigator_is_navigable( + axiom_navigator_t * om_navigator, + const axutil_env_t * env); + + /** + * Returns the build status of this node + * if the node is completly build returns AXIS2_TRUE + * otherwise AXIS2_FALSE + * @param om_navigator axiom_navigator struct + * @param env environment MUST not be NULL + * @return AXIS2_TRUE if this node is completly built + * otherwise return AXIS2_FALSE + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_navigator_is_completed( + axiom_navigator_t * om_navigator, + const axutil_env_t * env); + + /** + * gets the next node + * @param om_navigator om_navigaot struct + * @param env environment MUST not be NULL + * @returns axiom_node_t pointer in the sequence of preorder travasal + * however the an element node is treated slightly differently + * Once the om_element type om node is passed it returns the same om_node + * pointer in the next , returns NULL on error or if there is no more nodes + */ + + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_navigator_next( + axiom_navigator_t * om_navigator, + const axutil_env_t * env); + + /** + * method visited + * @param om_navigator om_navigaot struct + * @param env environment MUST not be NULL + * @returns AXIS2_TRUE if this node is alrady visited + * otherwise AXIS2_FALSE + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_navigator_visited( + axiom_navigator_t * om_navigator, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_NAVIGATOR_H */ diff --git a/axiom/include/axiom_node.h b/axiom/include/axiom_node.h new file mode 100644 index 0000000..dd5c320 --- /dev/null +++ b/axiom/include/axiom_node.h @@ -0,0 +1,379 @@ + +/* + * 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_NODE_H +#define AXIOM_NODE_H + +/** + * @defgroup axiom AXIOM project + * @{ + * @} + */ + +/** + * @defgroup axiom_om AXIOM + * @ingroup axiom + * @{ + * @} + */ + +/** + * @file axiom_node.h + * @brief defines axiom_node struct + */ +#include <axutil_env.h> +#include <axutil_utils.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_node axiom_node_t; + struct axiom_output; + struct axiom_document; + struct axiom_stax_builder; + + /** + * @defgroup axiom_node node + * @ingroup axiom_om + * @{ + */ + + /** + * @brief AXIOM types + */ + typedef enum axiom_types_t + { + + /** Invalid node type */ + AXIOM_INVALID = 0, + + /** AXIOM document type */ + AXIOM_DOCUMENT, + + /** AXIOM element type */ + AXIOM_ELEMENT, + + /** AXIOM doctype type */ + AXIOM_DOCTYPE, + + /** AXIOM comment type */ + AXIOM_COMMENT, + + /** AXIOM attribute type */ + AXIOM_ATTRIBUTE, + + /** AXIOM namespace type */ + AXIOM_NAMESPACE, + + /** AXIOM processing instruction type */ + AXIOM_PROCESSING_INSTRUCTION, + + /** AXIOM text type */ + AXIOM_TEXT, + + /** AXIOM data source, represent a serialized XML fragment with a stream */ + AXIOM_DATA_SOURCE + } axiom_types_t; + + /** + * Creates a node struct. + * @param env Environment. MUST NOT be NULL, . + * @return a pointer to newly created node struct. NULL on error. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_create( + const axutil_env_t * env); + + /** + * Creates a node struct from a character buffer. + * @param env Environment. MUST NOT be NULL, . + * @param buffer string. buffer to make the node + * @return a pointer to newly created node struct. NULL on error. + */ + AXIS2_EXTERN axiom_node_t* AXIS2_CALL + axiom_node_create_from_buffer( + const axutil_env_t * env, + axis2_char_t *buffer); + + + /** + * Frees an om node and all of its children. Please note that the attached + * data_element will also be freed along with the node. If the node is + * still attached to a parent, it will be detached first, then freed. + * @param om_node node 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_node_free_tree( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * Adds given node as child to parent. child should not have a parent + * if child has a parent it will be detached from existing parent + * @param om_node parent node. cannot be NULL. + * @param env Environment. MUST NOT be NULL, . + * @param child child node. + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_add_child( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * child); + + /** + * Detaches given node from the parent and reset the links + * @param om_node node to be detached, cannot be NULL. + * @param env Environment. MUST NOT be NULL, . + * @return a pointer to detached node,returns NULL on error with error + * code set to environment's error struct + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_detach( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * Inserts a sibling node after the given node + * @param om_node node to whom the sibling to be inserted. , cannot be NULL. + * @param env Environment. MUST NOT be NULL, . + * @param node_to_insert the node to be inserted. , cannot be NULL. + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_insert_sibling_after( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * node_to_insert); + + /** + * Inserts a sibling node before the given current node + * @param om_node node to whom the sibling to be inserted. , cannot be NULL. + * @param env Environment. MUST NOT be NULL, . + * @param node_to_insert the node to be inserted. , cannot be NULL. + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_insert_sibling_before( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * node_to_insert); + + /** + * Serializes the given node. This op makes the node go + * through its children and serialize them in order. + * @param om_node node to be serialized. cannot be NULL. + * @param env Environment .MUST NOT be NULL. + * @param om_output AXIOM output handler to be used in serializing + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_serialize( + axiom_node_t * om_node, + const axutil_env_t * env, + struct axiom_output *om_output); + + /** get parent of om_node + *@om_node node + *@param env environment + *@return pointer to parent node of om_node, return NULL if no parent exists or + * when an error occured. + */ + + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_get_parent( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * get the first child of om_node + * @param om_node node + * @param env environment must not be null. + * @returns pointer to first child node , NULL is returned on error with + * error code set in environments error + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_get_first_child( + axiom_node_t * om_node, + const axutil_env_t * env); + + /**get the first AXIOM_ELEMENT in om_node + * @param om_node node + * @param env environment must not be null + * @returns pointer to first child om element, NULL is returned on error + * with error code set in environments error. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_get_first_element( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * get the last child + * @param om_node node + * @param env environment, MUST NOT be NULL + * @return pointer to last child of this node , return NULL on error. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_get_last_child( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * get the previous sibling + * @param om_node om_node struct + * @param env environment , must node be null + * @returns a pointer to previous sibling , NULL if a previous sibling does not exits + * (happens when this node is the first child of a node ) + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_get_previous_sibling( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * get next sibling + * @param om_node om_node struct + * @param env environment, MUST NOT be NULL. + * @return next sibling of this node. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_get_next_sibling( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * get the node type of this element + * Node type can be one of AXIOM_ELEMENT, AXIOM_COMMENT, AXIOM_TEXT + * AXIOM_DOCTYPE, AXIOM_PROCESSING_INSTRUCTION + * @param om_node node of which node type is required + * @param env environment + * @return node type + */ + AXIS2_EXTERN axiom_types_t AXIS2_CALL + axiom_node_get_node_type( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * get the struct contained in the node + * IF the node is on type AXIOM_ELEMENT , this method returns + * a pointer to axiom_element_t struct contained + * @param om_node node + * @param env environment, MUST NOT be NULL. + * @returns pointer to struct contained in the node + * returns NULL if no struct is contained + */ + AXIS2_EXTERN void *AXIS2_CALL + axiom_node_get_data_element( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * Indicates whether parser has parsed this information item completely or not + * @param om_node om_node struct + * @param env environment, MUST NOT be NULL. + * @returns AXIS2_TRUE if node is completly build, + * AXIS2_FALSE if node is not completed + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_node_is_complete( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * returns the associated document, + * only valid if built using builder and for a node of type + * AXIOM_ELEMENT + * returns null if no document is available + * @param om_node + * @param env environment, MUST NOT be NULL. + * + * @return the OM document of the node + */ + AXIS2_EXTERN struct axiom_document *AXIS2_CALL + axiom_node_get_document( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * + * @param om_node pointer to the OM node struct + * @param env environment, MUST NOT be NULL + * + * @return the string representation of the node + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_node_to_string( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * + * @param om_node pointer to the OM node struct + * @param env environment, MUST NOT be NULL + * @param om_output the serialized output will be placed here + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_serialize_sub_tree( + axiom_node_t * om_node, + const axutil_env_t * env, + struct axiom_output *om_output); + + /** + * + * @param om_node pointer to the OM node struct + * @param env environment, MUST NOT be NULL + * + * @return the tree as a string + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_node_sub_tree_to_string( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * Convert the node to string, treating the binary contents, if any, + * as non-optimized content. + * @param om_node pointer to the OM node struct + * @param env environment, MUST NOT be NULL + * + * @return the none optimized string + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_node_to_string_non_optimized( + axiom_node_t * om_node, + const axutil_env_t * env); + + AXIS2_EXTERN struct axiom_stax_builder *AXIS2_CALL + axiom_node_get_builder( + axiom_node_t * om_node, + const axutil_env_t * env); + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_NODE_H */ diff --git a/axiom/include/axiom_output.h b/axiom/include/axiom_output.h new file mode 100644 index 0000000..18b524b --- /dev/null +++ b/axiom/include/axiom_output.h @@ -0,0 +1,254 @@ + +/* + * 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_OUTPUT_H +#define AXIOM_OUTPUT_H + +#include <axutil_utils_defines.h> +#include <axutil_utils.h> +#include <axutil_env.h> +#include <axiom_node.h> +#include <axiom_xml_writer.h> +#include <axutil_array_list.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_output output + * @ingroup axiom_om + * @{ + */ + + /** + * \brief output struct + * The XML writer interface struct of om + */ + typedef struct axiom_output axiom_output_t; + struct axiom_text; + + /** + * Creates AXIOM output struct + * @param env Environment. MUST NOT be NULL, . + * @param xml_writer XML writer. OM output takes + * ownership of the xml_writer. + * @return a pointer to newly created output struct. + */ + AXIS2_EXTERN axiom_output_t *AXIS2_CALL + axiom_output_create( + const axutil_env_t * env, + axiom_xml_writer_t * xml_writer); + + /** + * Performs xml writing. + * Accepts variable number of args depending on the on AXIOM type to be serialized + * @param om_output Output struct to be used + * @param env Environment. MUST NOT be NULL, + * @param type one of the AXIOM types + * @param no_of_args number of arguments passed in the variable parameter list + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_write( + axiom_output_t * om_output, + const axutil_env_t * env, + axiom_types_t type, + int no_of_args, + ...); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_write_optimized( + axiom_output_t * om_output, + const axutil_env_t * env, + struct axiom_text *om_text); + + /** + * Free om_output + * @param om_output om_output struct + * @param env environment + * @return status code AXIS2_SUCCESS on success, + * AXIS2_FAILURE otherwise + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_output_free( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * If the xml to be serialized is soap 11, this property is set to true + * @param om_output pointer to om_output struct + * @param env environment must not be NULL + * @returns the output soap version + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_output_is_soap11( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * @returns true if the ignore_xml_declaration property is true + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + + axiom_output_is_ignore_xml_declaration( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * Sets the ignore_xml_declaration property is true + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_output_set_ignore_xml_declaration( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_bool_t ignore_xml_dec); + + /** + * Sets the soap11 property to true + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_set_soap11( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_bool_t soap11); + + /** + * Sets xml_version property + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_set_xml_version( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_char_t * xml_version); + + /** + * @returns xml version property + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_output_get_xml_version( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * Sets the char set encoding property + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_set_char_set_encoding( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_char_t * char_set_encoding); + + /** + * @returns the char set encoding property + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_output_get_char_set_encoding( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * Sets the do optimize property true + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_set_do_optimize( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_bool_t optimize); + + /** + * Returns the xml writer + */ + AXIS2_EXTERN axiom_xml_writer_t *AXIS2_CALL + axiom_output_get_xml_writer( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * Returns the content type + * for soap11 'text/xml' etc.. + * @param om_output + * @param env environemnt + * @returns content id + */ + AXIS2_EXTERN const axis2_char_t *AXIS2_CALL + axiom_output_get_content_type( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * Writes the xml versio encoding + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_write_xml_version_encoding( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * @returns whether the output is to be optimized + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_output_is_optimized( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * Returns the next content id + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_output_get_next_content_id( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * root content id + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_output_get_root_content_id( + axiom_output_t * om_output, + const axutil_env_t * env); + /** + * + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_output_get_mime_boundry( + axiom_output_t * om_output, + const axutil_env_t * env); + /** + * + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_flush( + axiom_output_t * om_output, + const axutil_env_t * env); + + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + axiom_output_get_mime_parts( + axiom_output_t * om_output, + const axutil_env_t * env); + + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_OUTPUT_H */ diff --git a/axiom/include/axiom_processing_instruction.h b/axiom/include/axiom_processing_instruction.h new file mode 100644 index 0000000..24fcdc9 --- /dev/null +++ b/axiom/include/axiom_processing_instruction.h @@ -0,0 +1,136 @@ + +/* + * 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_PI_H +#define AXIOM_PI_H + +#include <axiom_node.h> +#include <axiom_output.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_processing_instruction pocessing instruction + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_processing_instruction + axiom_processing_instruction_t; + + /** + * Creates a processing instruction + * @param environment Environment. MUST NOT be NULL. + * @param parent parent of the element node to be created. Optional, can be NULL. + * @param target target of the processing instruction.cannot be NULL. + * @param value value of the processing instruction.cannot be NULL. + * @param node This is an out parameter. cannot be NULL. + * Returns the node corresponding to the comment created. + * Node type will be set to AXIOM_PROCESSING_INSTRUCTION + * @return a pointer tonewly created processing instruction struct + */ + AXIS2_EXTERN axiom_processing_instruction_t *AXIS2_CALL + axiom_processing_instruction_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * target, + const axis2_char_t * value, + axiom_node_t ** node); + + /** + * Frees an instance of axiom_processing_instruction + * @param om_pi processing instruction 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_processing_instruction_free( + struct axiom_processing_instruction *om_pi, + const axutil_env_t * env); + + /** + * Set processing instruction data + * @param om_pi + * @param env Environment. MUST NOT be NULL, . + * @param value + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_processing_instruction_set_value( + struct axiom_processing_instruction *om_pi, + const axutil_env_t * env, + const axis2_char_t * value); + + /** + * Set processing instruction target + * @param om_pi processing_instruction struct + * @param env environment, MUST NOT be NULL. + * @param target + * @return status of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_processing_instruction_set_target( + struct axiom_processing_instruction *om_pi, + const axutil_env_t * env, + const axis2_char_t * target); + + /** + * Get PI target + * @param om_pi processing_instruction struct + * @param env Environment. MUST NOT be NULL, . + * @return target text , NULL on error or if target is null + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_processing_instruction_get_target( + struct axiom_processing_instruction *om_pi, + const axutil_env_t * env); + + /** + * Get data part of processing_instruction + * @param om_pi processing instruction + * @param env environment , MUST NOT be NULL. + * @return data text , NULL if there is no data, + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_processing_instruction_get_value( + struct axiom_processing_instruction *om_pi, + const axutil_env_t * env); + + /** + * Serialize function + * @param om_pi processing_instruction struct + * @param env environment, MUST NOT be NULL. + * @param om_output om_output handler struct + * @return status of the op, AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_processing_instruction_serialize( + struct axiom_processing_instruction *om_pi, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_PI_H */ diff --git a/axiom/include/axiom_soap.h b/axiom/include/axiom_soap.h new file mode 100644 index 0000000..be0d956 --- /dev/null +++ b/axiom/include/axiom_soap.h @@ -0,0 +1,53 @@ + +/* + * 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_SOAP_H +#define AXIOM_SOAP_H + +#include <axiom_soap_body.h> +#include <axiom_soap_builder.h> +#include <axiom_soap_const.h> +#include <axiom_soap_envelope.h> +#include <axiom_soap_fault_code.h> +#include <axiom_soap_fault_detail.h> +#include <axiom_soap_fault.h> +#include <axiom_soap_fault_node.h> +#include <axiom_soap_fault_reason.h> +#include <axiom_soap_fault_role.h> +#include <axiom_soap_fault_sub_code.h> +#include <axiom_soap_fault_text.h> +#include <axiom_soap_fault_value.h> +#include <axiom_soap_header_block.h> +#include <axiom_soap_header.h> + +/** +* @file axiom_soap.h +* @brief includes all SOAP related headers +*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_H */ diff --git a/axiom/include/axiom_soap_body.h b/axiom/include/axiom_soap_body.h new file mode 100644 index 0000000..203b584 --- /dev/null +++ b/axiom/include/axiom_soap_body.h @@ -0,0 +1,184 @@ + +/* + * 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_SOAP_BODY_H +#define AXIOM_SOAP_BODY_H + +/** + * @file axiom_soap_body.h + * @brief axiom_soap_body struct + */ + +#include <axutil_env.h> +#include <axiom_node.h> +#include <axiom_element.h> +#include <axiom_namespace.h> +#include <axiom_soap_fault.h> +#include <axiom_soap_envelope.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_body axiom_soap_body_t; + struct axiom_soap_builder; + + /** + * @defgroup axiom_soap_body soap body + * @ingroup axiom_soap + * @{ + */ + + /** + * a struct that represents the contents of the SOAP body + * element in a SOAP message. SOAP body element consists of XML data + * that affects the way the application-specific content is processed. + * soap_body_struct contains soap_header and + * which have the content for the SOAP body. + * this also contains axiom_soap_fault_t struct , which carries status and/or + * error information. + */ + + /** + * creates a soap body struct + * @param env Environment. MUST NOT be NULL + * @param envelope the SOAP envelope to set the SOAP Body + * @return created SOAP Body + */ + + AXIS2_EXTERN axiom_soap_body_t *AXIS2_CALL + axiom_soap_body_create_with_parent( + const axutil_env_t * env, + struct axiom_soap_envelope *envelope); + + /** + * Deallocate all the resources associated to soap_body + * But it does not deallocate the underlying om structure + * @param body soap_body struct + * @param env must not be null + * @return status code AXIS2_SUCCESS + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_body_free( + axiom_soap_body_t * body, + const axutil_env_t * env); + + /** + * Indicates whether a soap fault is available with this + * soap body + * @param body soap_body struct + * @param env environment must not be null + * @return AXIS2_TRUE if fault is available, AXIS2_FALSE otherwise + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_soap_body_has_fault( + axiom_soap_body_t * body, + const axutil_env_t * env); + + /** + * returns the soap fault in this soap_body + * IF a soap_builder is associated with the soap_body + * Pulling will take place + * @param body soap_body + * @param env environment must not be null + * @return axiom_soap_fault_t if available, NULL otherwise + */ + AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL + axiom_soap_body_get_fault( + axiom_soap_body_t * body, + const axutil_env_t * env); + + /** + * get the underlying om_node + * @param body soap_body + * @param env environment must not be null + * @returns axiom_node_t + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_body_get_base_node( + axiom_soap_body_t * body, + const axutil_env_t * env); + + /** + * return the soap version + * @param body soap_body + * @param env environment must not be null + * @return one of AXIOM_SOAP11 or AXIOM_SOAP12 + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_soap_body_get_soap_version( + axiom_soap_body_t * body, + const axutil_env_t * env); + + /** + * build the soap body completely . return the status code, + * @param body pointer to soap_body struct + * @param env axutil_environment struct MUST not be NULL + * @returns status code , AXIS2_SUCCESS on success , AXIS2_ERROR + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_body_build( + axiom_soap_body_t * body, + const axutil_env_t * env); + + /** add an om node as the child to this soap_body + * the child is added to as the first child + * @param body pointer to soap_body struct + * @param env axutil_environment struct MUST not be NULL + * @returns status code , AXIS2_SUCCESS on success , AXIS2_ERROR + * otherwise + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_body_add_child( + axiom_soap_body_t * body, + const axutil_env_t * env, + axiom_node_t * child); + + /** + * SOAP builder construct a SOAP 1.2 fault all the time. + * So when SOAP 1.1 is in use, we should convert SOAP fault to + * SOAP 1.1 fault format before use. + * @param body pointer to soap_body struct + * @param env axutil_environment struct MUST not be NULL + * @returns status code , AXIS2_SUCCESS on success , AXIS2_ERROR + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_body_convert_fault_to_soap11( + axiom_soap_body_t * soap_body, + const axutil_env_t * env); + + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_body_process_attachments( + axiom_soap_body_t * soap_body, + const axutil_env_t * env, + void *user_param, + axis2_char_t *callback_name); + + AXIS2_EXTERN struct axiom_soap_builder *AXIS2_CALL + axiom_soap_body_get_builder( + axiom_soap_body_t * soap_body, + const axutil_env_t * env); + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_BODY_H */ diff --git a/axiom/include/axiom_soap_builder.h b/axiom/include/axiom_soap_builder.h new file mode 100644 index 0000000..9fffb78 --- /dev/null +++ b/axiom/include/axiom_soap_builder.h @@ -0,0 +1,253 @@ + +/* + * 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_SOAP_BUILDER_H +#define AXIOM_SOAP_BUILDER_H + +#include <axiom_stax_builder.h> +#include <axiom_soap_envelope.h> +#include <axiom_mime_parser.h> + +/** + * @file axiom_soap_builder.h + * @brief axiom_soap_builder struct + */ + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_builder axiom_soap_builder_t; + + /** + * @defgroup axiom_soap_builder soap builder + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a axiom_soap_builder struct + * @param env Environment. MUST NOT be NULL + * @param builder Stax builder + * @return the created SOAP Builder + */ + AXIS2_EXTERN axiom_soap_builder_t *AXIS2_CALL + axiom_soap_builder_create( + const axutil_env_t * env, + axiom_stax_builder_t * builder, + const axis2_char_t * soap_version); + /** + * Free the SOAP Builder + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_builder_free( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * Get the SOAP envelope of the SOAP builder + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return the SOAP envelope + */ + AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL + axiom_soap_builder_get_soap_envelope( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * Get the OM document of the SOAP Buidler + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return the OM document + */ + AXIS2_EXTERN axiom_document_t *AXIS2_CALL + axiom_soap_builder_get_document( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * Builds next element of the OM structure + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * @return AXIS2_SUCCESS if the next element is present else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_builder_next( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return the axiom_node of the OM document + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_builder_get_document_element( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_builder_set_bool_processing_mandatory_fault_elements( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + axis2_bool_t value); + + /** + * + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_builder_set_processing_detail_elements( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + axis2_bool_t value); + + /** + * + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_TRUE if the the element is present, AXIS2_FALSE otherwise + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_soap_builder_is_processing_detail_elements( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * Get the SOAP version + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return the SOAP version + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_soap_builder_get_soap_version( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * Set the MIME body parts + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_builder_set_mime_body_parts( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + axutil_hash_t * map); + + /** + * Get the MIME body parts + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return hash of mime body parts + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_soap_builder_get_mime_body_parts( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * Set the mime_parser + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * @paran mime_parser pointer to a axiom_mime_parser_t instance + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_builder_set_mime_parser( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + axiom_mime_parser_t *mime_parser); + + /** + * Set the callback function + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * @param callback to the callback function pointer + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_builder_set_callback_function( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback); + + /** + * Set the callback_ctx + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * @param void pointer to the callback_ctx + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_builder_set_callback_ctx( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + void *callback_ctx); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_builder_create_attachments( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + void *user_param, + axis2_char_t *callback_name); + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_soap_builder_replace_xop( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + axiom_node_t *om_element_node, + axiom_element_t *om_element); + + AXIS2_EXTERN axiom_stax_builder_t *AXIS2_CALL + axiom_soap_builder_get_om_builder( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + + + /** @} */ +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_SOAP_BUILDER_H */ diff --git a/axiom/include/axiom_soap_const.h b/axiom/include/axiom_soap_const.h new file mode 100644 index 0000000..3d5933b --- /dev/null +++ b/axiom/include/axiom_soap_const.h @@ -0,0 +1,176 @@ + +/* + * 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_SOAP_CONST_H +#define AXIOM_SOAP_CONST_H + +/** +* @file axiom_soap.h +* @brief defines SOAP constants +*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap SOAP + * @ingroup axiom + * @{ + * @} + */ + typedef enum soap_version + { + AXIOM_SOAP_VERSION_NOT_SET = 0, + + AXIOM_SOAP11, + + AXIOM_SOAP12 + } axiom_soap_version; + + /** soap 11 constants */ + +#define AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI "http://schemas.xmlsoap.org/soap/envelope/" + +#define AXIOM_SOAP11_ATTR_ACTOR "actor" + +#define AXIOM_SOAP11_SOAP_FAULT_CODE_LOCAL_NAME "faultcode" + +#define AXIOM_SOAP11_SOAP_FAULT_STRING_LOCAL_NAME "faultstring" + +#define AXIOM_SOAP11_SOAP_FAULT_ACTOR_LOCAL_NAME "faultactor" + +#define AXIOM_SOAP11_SOAP_FAULT_DETAIL_LOCAL_NAME "detail" + +#define AXIOM_SOAP11_CONTENT_TYPE "text/xml" + +#define AXIOM_SOAP11_FAULT_CODE_SENDER "Client" + +#define AXIOM_SOAP11_FAULT_CODE_RECEIVER "Server" + +#define AXIOM_SOAP11_SOAP_ACTOR_NEXT "http://schemas.xmlsoap.org/soap/actor/next" + + /** soap12 constants */ + +#define AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI "http://www.w3.org/2003/05/soap-envelope" + +#define AXIOM_SOAP12_SOAP_ROLE "role" + +#define AXIOM_SOAP12_SOAP_RELAY "relay" + +#define AXIOM_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME "Code" + +#define AXIOM_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME "Subcode" + +#define AXIOM_SOAP12_SOAP_FAULT_VALUE_LOCAL_NAME "Value" + +#define AXIOM_SOAP12_SOAP_FAULT_VALUE_VERSION_MISMATCH "VersionMismatch" + +#define AXIOM_SOAP12_SOAP_FAULT_VALUE_MUST_UNDERSTAND "MustUnderstand" + +#define AXIOM_SOAP12_SOAP_FAULT_VALUE_DATA_ENCODING_UKNOWN "DataEncodingUnknown" + +#define AXIOM_SOAP12_SOAP_FAULT_VALUE_SENDER "Sender" + +#define AXIOM_SOAP12_SOAP_FAULT_VALUE_RECEIVER "Receiver" + + /** SOAP Fault */ + +#define AXIOM_SOAP12_SOAP_FAULT_REASON_LOCAL_NAME "Reason" + +#define AXIOM_SOAP12_SOAP_FAULT_TEXT_LOCAL_NAME "Text" + +#define AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME "lang" + +#define AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_NS_URI "http://www.w3.org/XML/1998/namespace" + +#define AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_NS_PREFIX "xml" + +#define AXIOM_SOAP12_SOAP_FAULT_NODE_LOCAL_NAME "Node" + +#define AXIOM_SOAP12_SOAP_FAULT_DETAIL_LOCAL_NAME "Detail" + +#define AXIOM_SOAP12_SOAP_FAULT_ROLE_LOCAL_NAME "Role" + +#define AXIOM_SOAP12_CONTENT_TYPE "application/soap+xml" + +#define AXIOM_SOAP12_FAULT_CODE_SENDER "Sender" + +#define AXIOM_SOAP12_FAULT_CODE_RECEIVER "Receiver" + +#define AXIOM_SOAP12_SOAP_ROLE_NEXT "http://www.w3.org/2003/05/soap-envelope/role/next" + +#define AXIOM_SOAP12_SOAP_ROLE_NONE "http://www.w3.org/2003/05/soap-envelope/role/none" + +#define SOAP12_SOAP_ROLE_ULTIMATE_RECEIVER "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver" + +#define AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX "soapenv" + +#define AXIOM_SOAP_ENVELOPE_LOCAL_NAME "Envelope" + +#define AXIOM_SOAP_HEADER_LOCAL_NAME "Header" + +#define AXIOM_SOAP_BODY_LOCAL_NAME "Body" + +#define AXIOM_SOAP_BODY_NAMESPACE_PREFIX AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX + +#define AXIOM_SOAP_BODY_FAULT_LOCAL_NAME "Fault" + + /** attribute must understand */ + +#define AXIOM_SOAP_ATTR_MUST_UNDERSTAND "mustUnderstand" + +#define AXIOM_SOAP_ATTR_MUST_UNDERSTAND_TRUE "true" + +#define AXIOM_SOAP_ATTR_MUST_UNDERSTAND_FALSE "false" + +#define AXIOM_SOAP_ATTR_MUST_UNDERSTAND_0 "0" + +#define AXIOM_SOAP_ATTR_MUST_UNDERSTAND_1 "1" + +#define AXIOM_SOAP_FAULT_LOCAL_NAME "Fault" + +#define AXIOM_SOAP_FAULT_DETAIL_LOCAL_NAME "detail" + +#define AXIOM_SOAP_FAULT_NAMESPACE_PREFIX AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX + +#define AXIOM_SOAP_FAULT_DETAIL_EXCEPTION_ENTRY "Exception" + +#define AXIOM_SOAP_FAULT_CODE_VERSION_MISMATCH "soapenv:VersionMismatch" + +#define AXIOM_SOAP_FAULT_CODE_MUST_UNDERSTAND "soapenv:MustUnderstand" + +#define AXIOM_SOAP_FAULT_CODE_DATA_ENCODING_UNKNOWN "soapenv:DataEncodingUnknown" + +#define AXIOM_SOAP_FAULT_CODE_SENDER "" + +#define AXIOM_SOAP_FAULT_CODE_RECEIVER "" + + /* MTOM related */ + +#define AXIS2_XOP_NAMESPACE_URI "http://www.w3.org/2004/08/xop/include" + +#define AXIS2_XOP_INCLUDE "Include" + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_CONSTANTS_H */ diff --git a/axiom/include/axiom_soap_envelope.h b/axiom/include/axiom_soap_envelope.h new file mode 100644 index 0000000..24b8645 --- /dev/null +++ b/axiom/include/axiom_soap_envelope.h @@ -0,0 +1,244 @@ + +/* + * 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_SOAP_ENVELOPE_H +#define AXIOM_SOAP_ENVELOPE_H + +/** + * @file axiom_soap_envelope.h + * @brief axiom_soap_envelope struct + * corresponds to root element of soap message + */ +#include <axutil_env.h> +#include <axiom_node.h> +#include <axiom_element.h> +#include <axiom_namespace.h> +#include <axutil_array_list.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_envelope axiom_soap_envelope_t; + + struct axiom_soap_body; + struct axiom_soap_header; + struct axiom_soap_header_block; + struct axiom_soap_builder; + + /** + * @defgroup axiom_soap_envelope soap envelope + * @ingroup axiom_soap + * @{ + */ + + /** + * create a soap_envelope with the given namespace prefix and uri + * as the prefix and uri, The uri of ns should be valid soap uri + * @param env Environment. MUST NOT be NULL + * @param ns The OM namespace + * + * @return Created SOAP envelope + */ + AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL + axiom_soap_envelope_create( + const axutil_env_t * env, + axiom_namespace_t * ns); + + /** + * create a soap_envelope with the given namespace prefix and uri is selected + * according to soap_version, soap version should be one of AXIOM_SOAP11 + * or AXIOM_SOAP12 + * @param env Environment. MUST NOT be NULL + * @param prefix soap envelope prefix + * if prefix is NULL default prefix is used + * + * @return a pointer to soap envelope struct + */ + AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL + axiom_soap_envelope_create_with_soap_version_prefix( + const axutil_env_t * env, + int soap_version, + const axis2_char_t * prefix); + + /** + * Create the default SOAP envelope + * @param envelope OM SOAP Envelope + * @param env Environment. MUST NOT be NULL + * + * @return Created SOAP envelope + */ + AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL + axiom_soap_envelope_create_default_soap_envelope( + const axutil_env_t * env, + int soap_version); + + /** + * Create the default SOAP fault envelope + * @param envelope OM SOAP Envelope + * @param env Environment. MUST NOT be NULL + * + * @return Created SOAP fault envelope + */ + AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL + axiom_soap_envelope_create_default_soap_fault_envelope( + const axutil_env_t * env, + const axis2_char_t * code_value, + const axis2_char_t * reason_text, + const int soap_version, + axutil_array_list_t * sub_codes, + axiom_node_t * detail_node); + + /** + * gets the soap header of this soap envelope + * @param envelope soap envelope + * @param env environment must not be null + * @return soap header null it no header is present + */ + AXIS2_EXTERN struct axiom_soap_header *AXIS2_CALL + axiom_soap_envelope_get_header( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** + * Returns the soap body associated with this soap envelope + * @param envelope soap_envelope + * @param env environment + * @return soap_body + */ + AXIS2_EXTERN struct axiom_soap_body *AXIS2_CALL + axiom_soap_envelope_get_body( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** + * serialize function , serialize the soap envelope + * IF the soap version it set to soap11 the soap fault part is converted + * to soap11 fault even is the underlying soap fault is of soap12 type + * @param envelope soap envelope + * @param env environment must not be null + * @param om_output + * @param cache whether caching is enabled or not + * @return status code , AXIS2_SUCCESS if success , + * AXIS2_FAILURE otherwise + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_envelope_serialize( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env, + axiom_output_t * om_output, + axis2_bool_t cache); + + /** + * Free function, This function deallocate all the resources associated + * with the soap_envelope + * IT frees it's soap body and soap headers as well as the underlying + * om node tree by calling axiom_node_free_tree function + * @param envelope soap_envelope + * @param env environment + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_envelope_free( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** + * returns the om_node associated with this soap envelope + * @param envelope soap_envelope + * @param env environment + * @return axiom_node_t pointer + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_envelope_get_base_node( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** returns the soap version of this soap envelope + * @param envelope soap_envelope + * @param env environment must not be null + * @return soap_version AXIOM_SOAP12 or AXIOM_SOAP11 + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_soap_envelope_get_soap_version( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** + * Return the soap envelope namespace + * @param envelope + * @param env + * @return axiom_namespace_t + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_soap_envelope_get_namespace( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** + * Set the SOAP version + * @param envelope OM SOAP Envelope + * @param env Environment. MUST NOT be NULL + * @param soap_version, the SOAP version number. + * Must be either AXIOM_SOAP11 or AXIOM_SOAP12 + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_envelope_set_soap_version( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env, + int soap_version); + + /** + * Increment the reference number for the created instance + * @param envelope OM SOAP Envelope + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_envelope_increment_ref( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** + * get the soap builder of the envelope + * @param envelope OM SOAP Envelope + * @param env Environment. MUST NOT be NULL + * + * @return soap_builder struct related to the envelope + */ + AXIS2_EXTERN struct axiom_soap_builder *AXIS2_CALL + axiom_soap_envelope_get_soap_builder( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + AXIS2_EXTERN struct axiom_soap_builder *AXIS2_CALL + axiom_soap_envelope_get_builder( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_ENVELOPE_H */ diff --git a/axiom/include/axiom_soap_fault.h b/axiom/include/axiom_soap_fault.h new file mode 100644 index 0000000..d75ea3c --- /dev/null +++ b/axiom/include/axiom_soap_fault.h @@ -0,0 +1,215 @@ + +/* + * 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_SOAP_FAULT_H +#define AXIOM_SOAP_FAULT_H + +/** + * @file axiom_soap_fault.h + * @brief axiom_soap_fault struct + */ +#include <axiom_soap_const.h> +#include <axutil_env.h> +#include <axiom_node.h> +#include <axiom_element.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault axiom_soap_fault_t; + + struct axiom_soap_fault_reason; + struct axiom_soap_fault_detail; + struct axiom_soap_fault_sub_code; + struct axiom_soap_fault_code; + struct axiom_soap_fault_node; + struct axiom_soap_fault_role; + struct axiom_soap_fault_text; + struct axiom_soap_fault_value; + struct axiom_soap_body; + struct axiom_soap_builder; + + /** + * @defgroup axiom_soap_fault soap fault + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap fault struct + * @param env environment must not be NULL + * @param parent soap body struct to which this soap + * fault is the child + * @param env Environment. MUST NOT be NULL + * @returns pointer to axiom_soap_fault_t struct on success + * otherwise return NULL with error code set in environments error + */ + AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL + axiom_soap_fault_create_with_parent( + const axutil_env_t * env, + struct axiom_soap_body *parent); + + /** create an returns a axiom_soap_fault_t struct with a soap fault detail + * element and have this exceptio string as a text of a child of soap fault + * detail + * @param env environment must not be NULL + * @param parent soap body struct must not be NULL + * @param exceptio an error string must not be NULL + * @returns pointer to axiom_soap_fault_t on success , + * otherwise return NULL + */ + AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL + axiom_soap_fault_create_with_exception( + const axutil_env_t * env, + struct axiom_soap_body *parent, + axis2_char_t * exception); + + /** + * + * @param env environment must not be NULL + * @param parent soap body struct must not be NULL + * @param code_value + * @param reason_text + * @param soap_version + * + * @return the created default OM SOAP fault + */ + AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL + axiom_soap_fault_create_default_fault( + const axutil_env_t * env, + struct axiom_soap_body *parent, + const axis2_char_t * code_value, + const axis2_char_t * reason_text, + const int soap_version); + + /** + * Free an axiom_soap_fault + * @param fault pointer to soap_fault struct + * @param env Environment. MUST NOT be NULL + * @return status of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_fault_free( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** + * this function returns a axiom_soap_fault_code struct + * if a fault code is associated with this soap fault + * only valid when called after building the soap fault + * @param fault soap fault struct + * @param env environment must not be NULL + * @returns pointer to soap_fault_code struct if one is associated + * with this soap_fault struct , NULL is returned otherwise + */ + AXIS2_EXTERN struct axiom_soap_fault_code *AXIS2_CALL + axiom_soap_fault_get_code( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** + * @param fault soap fault struct + * @param env environment must not be NULL + * @returns pointer to soap_fault_reason struct if one is associated + * with this soap_fault struct , NULL is returned otherwise + */ + + AXIS2_EXTERN struct axiom_soap_fault_reason *AXIS2_CALL + axiom_soap_fault_get_reason( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** + * @param fault soap fault struct + * @param env environment must not be NULL + * @returns pointer to soap_fault_node struct if one is associated + * with this soap_fault struct , NULL is returned otherwise + */ + AXIS2_EXTERN struct axiom_soap_fault_node *AXIS2_CALL + axiom_soap_fault_get_node( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** + * @param fault soap fault struct + * @param env environment must not be NULL + * @returns pointer to soap_fault_code struct if one is associated + * with this soap_fault struct , NULL is returned otherwise + */ + AXIS2_EXTERN struct axiom_soap_fault_role *AXIS2_CALL + axiom_soap_fault_get_role( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** + * @param fault soap fault struct + * @param env environment must not be NULL + * @returns a pointer to soap_fault_code struct if one is + * associated with this soap_fault struct , NULL is returned otherwise + */ + AXIS2_EXTERN struct axiom_soap_fault_detail *AXIS2_CALL + axiom_soap_fault_get_detail( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** + * @param fault soap fault struct + * @param env enviroment must not be NULL + * @returns a pointer to soap_fault_code struct if one is + * associated with this soap_fault struct , NULL is returned otherwise + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_fault_get_exception( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** + * set an error string + * @param fualt soap fault struct + * @param env enviroment must not be NULL + * @param exception error message to be stored on soap fault + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_set_exception( + axiom_soap_fault_t * fault, + const axutil_env_t * env, + axis2_char_t * exception); + + /** + * returns the axiom_node_t struct which is wrapped by + * this soap fault struct + * @param fault soap fault struct + * @param env environment must not be NULL + * @returns a pointer to axiom_node_t struct if an om node is associated + * with this soap fault struct, otherwise return NULL + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_get_base_node( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_H */ diff --git a/axiom/include/axiom_soap_fault_code.h b/axiom/include/axiom_soap_fault_code.h new file mode 100644 index 0000000..ccc2b46 --- /dev/null +++ b/axiom/include/axiom_soap_fault_code.h @@ -0,0 +1,120 @@ + +/* + * 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_SOAP_FAULT_CODE_H +#define AXIOM_SOAP_FAULT_CODE_H + +/** + * @file axiom_soap_fault_code.h + * @brief axiom_soap_fault_code struct + */ +#include <axutil_env.h> +#include <axiom_soap_fault.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_code axiom_soap_fault_code_t; + + struct axiom_soap_fault_value; + struct axiom_soap_fault_sub_code; + struct axiom_soap_builder; + + /** + * @defgroup axiom_soap_fault_code soap fault code + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap fault code struct + * @param env Environment. MUST NOT be NULL + * @param fault_code the pointer to the AXIOM fault code struct + * + * @return + */ + AXIS2_EXTERN axiom_soap_fault_code_t *AXIS2_CALL + axiom_soap_fault_code_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault); + /** + * + * @param fault_code the pointer to the AXIOM fault code struct + * @param env Environment. MUST NOT be NULL + * + * @return + */ + AXIS2_EXTERN axiom_soap_fault_code_t *AXIS2_CALL + axiom_soap_fault_code_create_with_parent_value( + const axutil_env_t * env, + axiom_soap_fault_t * fault, + axis2_char_t * value); + + /** + * Free an axiom_soap_fault_code + * @param fault_code pointer to soap_fault_code struct + * @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_soap_fault_code_free( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env); + + /** + * @param fault_code the pointer to the AXIOM fault code struct + * @param env Environment. MUST NOT be NULL + * @returns axiom_soap_fault_sub_code struct if one is associated with + * this fault_code struct , otherwise teturns NULL + */ + + AXIS2_EXTERN struct axiom_soap_fault_sub_code *AXIS2_CALL + axiom_soap_fault_code_get_sub_code( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env); + + /** + * @param fault_code the pointer to the AXIOM fault code struct + * @param env Environment. MUST NOT be NULL + * @returns soap_fault_value if available + */ + AXIS2_EXTERN struct axiom_soap_fault_value *AXIS2_CALL + axiom_soap_fault_code_get_value( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env); + /** + * Get the base node of the SOAP fault + * @param fault_code the pointer to the AXIOM fault code struct + * @param env Environment. MUST NOT be NULL + * + * @return retrns the base node of the SOAP fault + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_code_get_base_node( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_SOAP_FAULT_CODE_H */ diff --git a/axiom/include/axiom_soap_fault_detail.h b/axiom/include/axiom_soap_fault_detail.h new file mode 100644 index 0000000..6d17a77 --- /dev/null +++ b/axiom/include/axiom_soap_fault_detail.h @@ -0,0 +1,111 @@ + +/* + * 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_SOAP_FAULT_DETAIL_H +#define AXIOM_SOAP_FAULT_DETAIL_H + +/** + * @file axiom_soap_fault_detail.h + * @brief axiom_soap_fault_detail struct + */ + +#include <axutil_env.h> +#include <axiom_soap_fault.h> +#include <axiom_children_iterator.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_detail axiom_soap_fault_detail_t; + + /** + * @defgroup axiom_soap_fault_detail soap fault detail + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap struct + * @param env Environment. MUST NOT be NULL + * @param fault The SOAP fault + * + * @return the created OM SOAP fault detail + */ + AXIS2_EXTERN axiom_soap_fault_detail_t *AXIS2_CALL + axiom_soap_fault_detail_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault); + + /** + * Free an axiom_soap_fault_detail + * @param fault_detail pointer to soap_fault_detail struct + * @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_soap_fault_detail_free( + axiom_soap_fault_detail_t * fault_detail, + const axutil_env_t * env); + + /** + * Adds a detail entry to the SOAP fault detail + * @param fault_detail pointer to soap_fault_detail struct + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_detail_add_detail_entry( + axiom_soap_fault_detail_t * fault_detail, + const axutil_env_t * env, + axiom_node_t * ele_node); + + /** + * Return all detail entries in the SOAP fault detail + * @param fault_detail pointer to soap_fault_detail struct + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axiom_children_iterator_t *AXIS2_CALL + axiom_soap_fault_detail_get_all_detail_entries( + axiom_soap_fault_detail_t * fault_detail, + const axutil_env_t * env); + + /** + * Returns the base node of the SOAP fault detail + * @param fault_detail pointer to soap_fault_detail struct + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_detail_get_base_node( + axiom_soap_fault_detail_t * fault_code, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_DETAIL_H */ diff --git a/axiom/include/axiom_soap_fault_node.h b/axiom/include/axiom_soap_fault_node.h new file mode 100644 index 0000000..b0a8313 --- /dev/null +++ b/axiom/include/axiom_soap_fault_node.h @@ -0,0 +1,112 @@ + +/* + * 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_SOAP_FAULT_NODE_H +#define AXIOM_SOAP_FAULT_NODE_H + +/** + * @file axiom_soap_fault_node.h + * @brief axiom_soap_fault_node struct + */ +#include <axutil_env.h> +#include <axiom_soap_fault.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_node axiom_soap_fault_node_t; + + /** + * @defgroup axiom_soap_fault_node soap fault node + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap fault node struct + * @param env Environment. MUST NOT be NULL + * @param fault_node pointer to soap_fault_node struct + * + * @return the created SOAP fault node + */ + AXIS2_EXTERN axiom_soap_fault_node_t *AXIS2_CALL + axiom_soap_fault_node_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault); + + /** + * Free an axiom_soap_fault_node + * @param fault_node pointer to soap_fault_node struct + * @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_soap_fault_node_free( + axiom_soap_fault_node_t * fault_node, + const axutil_env_t * env); + + /** + * Set the fault string value of the SOAP fault node + * @param fault_node pointer to soap_fault_node struct + * @param env Environment. MUST NOT be NULL + * @param fault_val the fault string value + * + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_node_set_value( + axiom_soap_fault_node_t * fault_node, + const axutil_env_t * env, + axis2_char_t * fault_val); + + /** + * Get the string value of the SOAP fault node + * @param fault_node pointer to soap_fault_node struct + * @param env Environment. MUST NOT be NULL + * + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_fault_node_get_value( + axiom_soap_fault_node_t * fault_node, + const axutil_env_t * env); + + /** + * Get the base node of the SOAP fault node + * @param fault_node pointer to soap_fault_node struct + * @param env Environment. MUST NOT be NULL + * + * @return the base node of the fault node + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_node_get_base_node( + axiom_soap_fault_node_t * fault_node, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_NODE_H */ diff --git a/axiom/include/axiom_soap_fault_reason.h b/axiom/include/axiom_soap_fault_reason.h new file mode 100644 index 0000000..e9e8da3 --- /dev/null +++ b/axiom/include/axiom_soap_fault_reason.h @@ -0,0 +1,139 @@ + +/* + * 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_SOAP_FAULT_REASON_H +#define AXIOM_SOAP_FAULT_REASON_H + +/** +* @file axiom_soap_fault_reason.h +* @brief axiom_soap_fault_reason +*/ +#include <axutil_env.h> +#include <axiom_soap_fault.h> +#include <axutil_array_list.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_reason axiom_soap_fault_reason_t; + struct axiom_soap_fault_text; + struct axiom_soap_builder; + + /** + * @defgroup axiom_soap_fault_reason soap fault reason + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a SOAP fault reason struct + * @param env Environment. MUST NOT be NULL + * @param fault the SOAP fault + * + * @return the created SOAP fault reason struct + */ + AXIS2_EXTERN axiom_soap_fault_reason_t *AXIS2_CALL + axiom_soap_fault_reason_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault); + + /** + * Free an axiom_soap_fault_reason + * @param fault_reason pointer to soap_fault_reason struct + * @param env Environment. MUST NOT be NULL + * + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_fault_reason_free( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env); + + /** + * Get the SOAP fault text by comparing the given string + * @param fault_reason pointer to soap_fault_reason struct + * @param env Environment. MUST NOT be NULL + * @param lang string to be compares + * + * @return the SOAP fault text of the SOAP fault string + */ + AXIS2_EXTERN struct axiom_soap_fault_text *AXIS2_CALL + axiom_soap_fault_reason_get_soap_fault_text( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + axis2_char_t * lang); + + /** + * Returns all the SOAP fault reason strings as an array list + * @param fault_reason pointer to soap_fault_reason struct + * @param env Environment. MUST NOT be NULL + * + * @return all the SOAP fault reason strings as an array list + */ + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + axiom_soap_fault_reason_get_all_soap_fault_texts( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env); + + /** + * Retuens the first SOAP fault reason string + * @param fault_reason pointer to soap_fault_reason struct + * @param env Environment. MUST NOT be NULL + * + * @return The first SOAP fault reason string + */ + AXIS2_EXTERN struct axiom_soap_fault_text *AXIS2_CALL + axiom_soap_fault_reason_get_first_soap_fault_text( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env); + + /** + * Add a string as a SOAP fault reason + * @param fault_reason pointer to soap_fault_reason struct + * @param env Environment. MUST NOT be NULL + * @param fault_text The text to be added as the SOAP fault reason + * + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_reason_add_soap_fault_text( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + struct axiom_soap_fault_text *fault_text); + + /** + * Get the base node of the SOAP fault reason + * @param fault_reason pointer to soap_fault_reason struct + * @param env Environment. MUST NOT be NULL + * @return the base node of the SOAP fault reason + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_reason_get_base_node( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_REASON_H */ diff --git a/axiom/include/axiom_soap_fault_role.h b/axiom/include/axiom_soap_fault_role.h new file mode 100644 index 0000000..7cfa82c --- /dev/null +++ b/axiom/include/axiom_soap_fault_role.h @@ -0,0 +1,109 @@ + +/* + * 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_SOAP_FAULT_ROLE_H +#define AXIOM_SOAP_FAULT_ROLE_H + +/** + * @file axiom_soap_fault_role.h + * @brief axiom_soap_fault_role + */ +#include <axutil_env.h> +#include <axiom_soap_fault.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_role axiom_soap_fault_role_t; + + /** + * @defgroup axiom_soap_fault_role soap fault role + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap struct + * @param env Environment. MUST NOT be NULL + */ + AXIS2_EXTERN axiom_soap_fault_role_t *AXIS2_CALL + axiom_soap_fault_role_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault); + + /** + * Free an axiom_soap_fault_role + * @param fault_role pointer to soap_fault_role struct + * @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_soap_fault_role_free( + axiom_soap_fault_role_t * fault_role, + const axutil_env_t * env); + + /** + * Set the SOAP fault role value + * @param fault_role pointer to soap_fault_role struct + * @param env Environment. MUST NOT be NULL + * @param uri the URI to be set + * + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_role_set_role_value( + axiom_soap_fault_role_t * fault_role, + const axutil_env_t * env, + axis2_char_t * uri); + + /** + * Get the SOAP fault role value + * @param fault_role pointer to soap_fault_role struct + * @param env Environment. MUST NOT be NULL + * + * @return the SOAP fault role value + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_fault_role_get_role_value( + axiom_soap_fault_role_t * fault_role, + const axutil_env_t * env); + + /** + * Get the base node of the OM SOAP fault role + * @param fault_role pointer to soap_fault_role struct + * @param env Environment. MUST NOT be NULL + * + * @return the base node of the OM SOAP fault role + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_role_get_base_node( + axiom_soap_fault_role_t * fault_role, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_ROLE_H */ diff --git a/axiom/include/axiom_soap_fault_sub_code.h b/axiom/include/axiom_soap_fault_sub_code.h new file mode 100644 index 0000000..6d4723c --- /dev/null +++ b/axiom/include/axiom_soap_fault_sub_code.h @@ -0,0 +1,123 @@ + +/* + * 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_SOAP_FAULT_SUB_CODE_H +#define AXIOM_SOAP_FAULT_SUB_CODE_H + +/** + * @file axiom_soap_fault_sub_code.h + * @brief axiom_soap_fault_sub_code struct + */ +#include <axutil_env.h> +#include <axiom_soap_fault_code.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_sub_code axiom_soap_fault_sub_code_t; + struct axiom_soap_fault_value; + struct axiom_soap_builder; + + /** + * @defgroup axiom_soap_fault_sub_code soap fault sub code + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap struct + * @param env Environment. MUST NOT be NULL + * @param fault_code SOAP fault code + * + * @return Created SOAP fault sub code + */ + AXIS2_EXTERN axiom_soap_fault_sub_code_t *AXIS2_CALL + axiom_soap_fault_sub_code_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_code_t * fault_code); + + /** + * Create a SOAP fault sub code from the given SOAP fault and value + * @param fault_sub_code pointer to soap_fault_sub_code struct + * @param env Environment. MUST NOT be NULL + * @param value the value to be set to the SOAP fault + * + * @return Created SOAP sub code + */ + AXIS2_EXTERN axiom_soap_fault_sub_code_t *AXIS2_CALL + axiom_soap_fault_sub_code_create_with_parent_value( + const axutil_env_t * env, + axiom_soap_fault_code_t * fault_code, + axis2_char_t * value); + + /** + * Free an axiom_soap_fault_sub_code + * @param fault_sub_code pointer to soap_fault_sub_code struct + * @param env Environment. MUST NOT be NULL + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_fault_sub_code_free( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env); + + /** + * Get the SOAP fault sub code + * @param fault_sub_code pointer to soap_fault_sub_code struct + * @param env Environment. MUST NOT be NULL + * + * @return the SOAP fault sub code + */ + AXIS2_EXTERN axiom_soap_fault_sub_code_t *AXIS2_CALL + axiom_soap_fault_sub_code_get_sub_code( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env); + + /** + * Get the value of the SOAP fault sub code + * @param fault_sub_code pointer to soap_fault_sub_code struct + * @param env Environment. MUST NOT be NULL + * + * @return the SOAP fault value + */ + AXIS2_EXTERN struct axiom_soap_fault_value *AXIS2_CALL + axiom_soap_fault_sub_code_get_value( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env); + + /** + * Get the base node of the SOAP fault sub code + * @param fault_sub_code pointer to soap_fault_sub_code struct + * @param env Environment. MUST NOT be NULL + * + * @return the base node of the SOAP fault sub code as OM node + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_sub_code_get_base_node( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_SUB_CODE_H */ diff --git a/axiom/include/axiom_soap_fault_text.h b/axiom/include/axiom_soap_fault_text.h new file mode 100644 index 0000000..10a0465 --- /dev/null +++ b/axiom/include/axiom_soap_fault_text.h @@ -0,0 +1,138 @@ + +/* + * 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_SOAP_FAULT_TEXT_H +#define AXIOM_SOAP_FAULT_TEXT_H + +/** + * @file axiom_soap_fault_text.h + * @brief axiom_soap_fault_text + */ +#include <axutil_env.h> +#include <axiom_soap_fault_reason.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_text axiom_soap_fault_text_t; + + /** + * @defgroup axiom_soap_fault_text soap fault text + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap fault struct + * @param env Environment. MUST NOT be NULL + * @param fault the SOAP fault reason + * + * @return Created SOAP fault text + */ + AXIS2_EXTERN axiom_soap_fault_text_t *AXIS2_CALL + axiom_soap_fault_text_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_reason_t * fault); + + /** + * Free an axiom_soap_fault_text + * @param fault_text pointer to soap_fault_text struct + * @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_soap_fault_text_free( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env); + + /** + * Set the lang of the SOAP fault text + * @param fault_text pointer to soap_fault_text struct + * @param env Environment. MUST NOT be NULL + * @param lang the string to be set + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_text_set_lang( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env, + const axis2_char_t * lang); + + /** + * Get the lang of the SOAP fault + * @param fault_text pointer to soap_fault_text struct + * @param env Environment. MUST NOT be NULL + * + * @return the lang of the SOAP fault + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_fault_text_get_lang( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env); + + /** + * Get the base node of the SOAP fault text + * @param fault_text pointer to soap_fault_text struct + * @param env Environment. MUST NOT be NULL + * + * @return the base node of the SOAP fault text + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_text_get_base_node( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env); + + /** + * Set the SOAP fault text + * @param fault_text pointer to soap_fault_text struct + * @param env Environment. MUST NOT be NULL + * @param value the text value + * @param lang string to be compared + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_text_set_text( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env, + axis2_char_t * value, + axis2_char_t * lang); + + /** + * get the SOAP fault text + * @param fault_text pointer to soap_fault_text struct + * @param env Environment. MUST NOT be NULL + * + * @return the Text of the SOAP fault + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_fault_text_get_text( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_TEXT_H */ diff --git a/axiom/include/axiom_soap_fault_value.h b/axiom/include/axiom_soap_fault_value.h new file mode 100644 index 0000000..446a89e --- /dev/null +++ b/axiom/include/axiom_soap_fault_value.h @@ -0,0 +1,120 @@ + +/* + * 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_SOAP_FAULT_VALUE_H +#define AXIOM_SOAP_FAULT_VALUE_H + +/** +* @file axiom_soap_fault_value.h +* @brief axiom_soap_fault_value +*/ +#include <axutil_env.h> +#include <axiom_soap_fault.h> +#include <axiom_soap_fault_sub_code.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_value axiom_soap_fault_value_t; + + /** + * @defgroup axiom_soap_fault_value soap fault value + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap struct + * @param env Environment. MUST NOT be NULL + */ + AXIS2_EXTERN axiom_soap_fault_value_t *AXIS2_CALL + axiom_soap_fault_value_create_with_subcode( + const axutil_env_t * env, + axiom_soap_fault_sub_code_t * parent); + + /** + * Create s SOAP fault value givn a SOAP fault code + * @param fault_value pointer to soap_fault_value struct + * @param env Environment. MUST NOT be NULL + * + * @return Created SOAP fault value + */ + AXIS2_EXTERN axiom_soap_fault_value_t *AXIS2_CALL + axiom_soap_fault_value_create_with_code( + const axutil_env_t * env, + axiom_soap_fault_code_t * parent); + + /** + * Free an axiom_soap_fault_value + * @param fault_value pointer to soap_fault_value struct + * @param env Environment. MUST NOT be NULL + * + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_fault_value_free( + axiom_soap_fault_value_t * fault_value, + const axutil_env_t * env); + + /** + * Get the text value of the soapenv:Value element directly under soapenv:Code element + * @param fault_value pointer to axiom_soap_fault_t + * @param env Environment. MUST NOT BE NULL + * @return text value + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_fault_value_get_text( + axiom_soap_fault_value_t * fault_value, + const axutil_env_t * env); + + /** + * Set the text value of the soapenv:Value element directly under soapenv:Code element + * @param fault_value pointer to axiom_soap_fault_t + * @param env Environment. MUST NOT BE NULL + * @param text value to be set + * + * @return the base node + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_value_get_base_node( + axiom_soap_fault_value_t * fault_value, + const axutil_env_t * env); + + /** + * set the text value of soap_fault_value element + * @param fault_value pointer to soap fault value struct + * @param env environment MUST not be NULL + * @param text Text value to be set + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_value_set_text( + axiom_soap_fault_value_t * fault_value, + const axutil_env_t * env, + axis2_char_t * text); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_VALUE_H */ diff --git a/axiom/include/axiom_soap_header.h b/axiom/include/axiom_soap_header.h new file mode 100644 index 0000000..f0ed2f5 --- /dev/null +++ b/axiom/include/axiom_soap_header.h @@ -0,0 +1,205 @@ + +/* + * 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_SOAP_HEADER_H +#define AXIOM_SOAP_HEADER_H + +/** + * @file axiom_soap_header.h + * @brief axiom_soap_header struct + */ +#include <axutil_env.h> +#include <axiom_node.h> +#include <axiom_element.h> +#include <axutil_array_list.h> +#include <axiom_children_qname_iterator.h> +#include <axiom_children_with_specific_attribute_iterator.h> +#include <axutil_hash.h> +#include <axiom_soap_envelope.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_header axiom_soap_header_t; + + struct axiom_soap_header_block; + struct axiom_soap_builder; + + /** + * @defgroup axiom_soap_header soap header + * @ingroup axiom_soap + * @{ + */ + + AXIS2_EXTERN axiom_soap_header_t *AXIS2_CALL + axiom_soap_header_create_with_parent( + const axutil_env_t * env, + struct axiom_soap_envelope *envelope); + + /** + * Free an axiom_soap_header + * @param header pointer to soap_header struct + * @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_soap_header_free( + axiom_soap_header_t * header, + const axutil_env_t * env); + + /** + * create a new axiom_soap_header_block_t struct initialized with the + * specified name and adds it to passed axiom_soap_header_t struct. + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * @param localName the localname of the SOAP header block + * @param ns the namespace of the SOAP header block + * @return The newly created axiom_soap_header_block_t struct + */ + AXIS2_EXTERN struct axiom_soap_header_block *AXIS2_CALL + + axiom_soap_header_add_header_block( + axiom_soap_header_t * header, + const axutil_env_t * env, + const axis2_char_t * localname, + axiom_namespace_t * ns); + + /** + * returns a hash_table of all the soap_header_block_t struct in this + * soap_header_t object that have the the specified actor. An + * actor is a global attribute that indicates the intermediate parties to + * whom the message should be sent. An actor receives the message and then + * sends it to the next actor. The default actor is the ultimate intended + * recipient for the message, so if no actor attribute is set in a + * axiom_soap_header_t struct the message is sent to its ultimate + * destination. + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * @param role the role value for the examination + * + * @return hash_table of all the soap_header_block_t struct + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_soap_header_examine_header_blocks( + axiom_soap_header_t * header, + const axutil_env_t * env, + axis2_char_t * param_role); + + /** + * returns an arraylist of header_blocks which has a given namesapce uri + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * @param ns_uri namespace uri + * @return pointer to axutil_array_list_t, or null if no header_blocks with + * given namespace uri exists + * The returned array_list must be freed by the user. + */ + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + axiom_soap_header_get_header_blocks_with_namespace_uri( + axiom_soap_header_t * header, + const axutil_env_t * env, + const axis2_char_t * ns_uri); + + /** + * returns an iterator to iterate through all soap header block's om nodes + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * @returns axiom_children_qname_iterator_t or null if no header blocks + * present + */ + AXIS2_EXTERN axiom_children_qname_iterator_t *AXIS2_CALL + axiom_soap_header_examine_all_header_blocks( + axiom_soap_header_t * header, + const axutil_env_t * env); + + /** + * returns an iterator to iterate through all header blocks om_nodes + * with the matching role attribute + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * @param role + * @returns iterator or null if no header blocks present with matching + * role attribute + */ + AXIS2_EXTERN axiom_children_with_specific_attribute_iterator_t + *AXIS2_CALL + axiom_soap_header_extract_header_blocks( + axiom_soap_header_t * header, + const axutil_env_t * env, + axis2_char_t * role); + + /** + * returns the axiom_node_t struct wrapped in soap_header + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * + * @return the base node of the SOAP header + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_header_get_base_node( + axiom_soap_header_t * header, + const axutil_env_t * env); + + /** + * return the soap_version of this soap_header + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIOM_SOAP11 or AXIOM_SOAP12 + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_soap_header_get_soap_version( + axiom_soap_header_t * header, + const axutil_env_t * env); + + /** + * Get all the SOAP headers + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * + * @returns a hash table of all header_blocks in this header + * the returned hash is a readonly hash should not be modified + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_soap_header_get_all_header_blocks( + axiom_soap_header_t * header, + const axutil_env_t * env); + + /** + * remove header block that matches to the given qname + * qname should not be null + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * + * @return status of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_header_remove_header_block( + axiom_soap_header_t * header, + const axutil_env_t * env, + axutil_qname_t * qname); + + /** @} */ +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_SOAP_HEADER_H */ diff --git a/axiom/include/axiom_soap_header_block.h b/axiom/include/axiom_soap_header_block.h new file mode 100644 index 0000000..30ba4b0 --- /dev/null +++ b/axiom/include/axiom_soap_header_block.h @@ -0,0 +1,228 @@ + +/* + * 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_SOAP_HEADER_BLOCK_H +#define AXIOM_SOAP_HEADER_BLOCK_H + +/** + * @file axiom_soap_header_block.h + * @brief axiom_soap_header_block struct + */ +#include <axutil_env.h> +#include <axiom_node.h> +#include <axiom_element.h> +#include <axutil_array_list.h> +#include <axiom_soap_header.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_header_block axiom_soap_header_block_t; + + /** + * @defgroup axiom_soap_header_block soap header block + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap struct + * @param env Environment. MUST NOT be NULL + * this is an internal function. + * + * @return the created SOAP header block + */ + AXIS2_EXTERN axiom_soap_header_block_t *AXIS2_CALL + axiom_soap_header_block_create_with_parent( + const axutil_env_t * env, + const axis2_char_t * localname, + axiom_namespace_t * ns, + struct axiom_soap_header *parent); + + /** + * Free an axiom_soap_header_block + * @param header_block pointer to soap_header_block struct + * @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_soap_header_block_free( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env); + + /** + * Set the SOAP role + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * @param uri the role URI + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_header_block_set_role( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + axis2_char_t * uri); + + /** + * Set the mustunderstand attribute of the SOAP header + * If must_understand=TRUE its set to 1, otherwise set to 0 + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * @param must_understand SOAP mustunderstand attribute value + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_header_block_set_must_understand_with_bool( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + axis2_bool_t must_understand); + + /** + * Set the SOAP mustunderstand attribute + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * @param must_understand SOAP mustunderstand attribute + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_header_block_set_must_understand_with_string( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + axis2_char_t * must_understand); + + /** + * To check the SOAP mustunderstand attribute + * If must_understand=TRUE its set to 1, otherwise set to 0 + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_TRUE if mustunderstand is set true. AXIS2_FALSE otherwise + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_soap_header_block_get_must_understand( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env); + + /** + * To chk if the SOAP header is processed or not + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_TRUE if checked AXIS2_FALSE otherwise + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_soap_header_block_is_processed( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env); + + /** + * Set the SOAP header as processed + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_header_block_set_processed( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env); + + /** + * Get the SOAP role of the header block + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * + * @return the SOAP role of the header block + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_header_block_get_role( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env); + + /** + * Set the attribute of the header block + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * @param attr_name the attribute name + * @param attr_value the attribute value + * @param soap_envelope_namespace_uri the namsepace URI value + * + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_header_block_set_attribute( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + const axis2_char_t * attr_name, + const axis2_char_t * attr_value, + const axis2_char_t * soap_envelope_namespace_uri); + + /** + * Get the attribute of the header block + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * @param attr_name the attribute name + * @param the namespace URI of the SOAP envelope + * + * @return the attribute of the header block + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_header_block_get_attribute( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + const axis2_char_t * attr_name, + const axis2_char_t * soap_envelope_namespace_uri); + + /** + * Get the base node of the header block + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * + * @return the base node of the of the header block + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_header_block_get_base_node( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env); + + /** + * Get the SOAP version of the header block + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * + * @return the SOAP version of the header block + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_soap_header_block_get_soap_version( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_SOAP_HEADER_BLOCK_H */ diff --git a/axiom/include/axiom_stax_builder.h b/axiom/include/axiom_stax_builder.h new file mode 100644 index 0000000..fb4a1ec --- /dev/null +++ b/axiom/include/axiom_stax_builder.h @@ -0,0 +1,154 @@ + +/* + * 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_STAX_BUILDER_H +#define AXIOM_STAX_BUILDER_H + +#include <axiom_node.h> +#include <axiom_xml_reader.h> +#include <axiom_document.h> +#include <axutil_env.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_stax_builder stax builder + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_stax_builder axiom_stax_builder_t; + + /** + * Creates an stax builder + * @param environment Environment. MUST NOT be NULL. + * @param parser parser to be used with builder. The builder + * will take ownership of the parser. + * @return a pointer to the newly created builder struct. + */ + AXIS2_EXTERN axiom_stax_builder_t *AXIS2_CALL + axiom_stax_builder_create( + const axutil_env_t * env, + 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 + * @return status of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_stax_builder_free( + struct axiom_stax_builder *builder, + const axutil_env_t * env); + + /** + * Free the build struct instance and its associated document. + does not free the associated axiom tree. + * @param builder pointer to builder struct + * @param env environment, MUST NOT be NULL + * @return status of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_stax_builder_free_self( + struct axiom_stax_builder *builder, + const axutil_env_t * env); + + /** Gets the document associated with the builder + * @param builder axiom_stax_builder + * @param env environment + * @return pointer to document struct associated with builder + * NULL if there is no document associated with the builder, + * NULL if an error occured. + */ + AXIS2_EXTERN axiom_document_t *AXIS2_CALL + axiom_stax_builder_get_document( + 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 +} +#endif + +#endif /* AXIOM_STAX_BUILDER_H */ diff --git a/axiom/include/axiom_text.h b/axiom/include/axiom_text.h new file mode 100644 index 0000000..3768d90 --- /dev/null +++ b/axiom/include/axiom_text.h @@ -0,0 +1,265 @@ + +/* + * 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_TEXT_H +#define AXIOM_TEXT_H + +#include <axutil_env.h> +#include <axiom_node.h> +#include <axiom_output.h> +#include <axiom_data_handler.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_text text + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_text axiom_text_t; + + /** + * Creates a new text struct + * @param env Environment. + * @param parent parent of the new node. Optinal, can be NULL. + * The parent element must be of type AXIOM_ELEMENT + * @param value Text value. Optinal, can be NULL. + * @param comment_node This is an out parameter. cannot be NULL. + * Returns the node corresponding to the text struct created. + * Node type will be set to AXIOM_TEXT + * @return pointer to newly created text struct + */ + AXIS2_EXTERN axiom_text_t *AXIS2_CALL + axiom_text_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * value, + axiom_node_t ** node); + + /** + * Creates a new text struct + * @param env Environment. + * @param parent parent of the new node. Optinal, can be NULL. + * The parent element must be of type AXIOM_ELEMENT + * @param value Text value string. Optinal, can be NULL. + * @param comment_node This is an out parameter. cannot be NULL. + * Returns the node corresponding to the text struct created. + * Node type will be set to AXIOM_TEXT + * @return pointer to newly created text struct + */ + AXIS2_EXTERN axiom_text_t *AXIS2_CALL + axiom_text_create_str( + const axutil_env_t * env, + axiom_node_t * parent, + axutil_string_t * value, + axiom_node_t ** node); + + /** + * Creates a new text struct for binary data (MTOM) + * @param env Environment. + * @param parent parent of the new node. Optinal, can be NULL. + * The parent element must be of type AXIOM_ELEMENT + * @param data_handler data handler. Optinal, can be NULL. + * @param comment_node This is an out parameter. cannot be NULL. + * Returns the node corresponding to the text struct created. + * Node type will be set to AXIOM_TEXT + * @return pointer to newly created text struct + */ + AXIS2_EXTERN axiom_text_t *AXIS2_CALL + axiom_text_create_with_data_handler( + const axutil_env_t * env, + axiom_node_t * parent, + axiom_data_handler_t * data_handler, + axiom_node_t ** node); + + /** + * Free an axiom_text struct + * @param env environment. + * @param om_text pointer to om text struct to be freed. + * @return satus of the op. AXIS2_SUCCESS on success + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_text_free( + struct axiom_text *om_text, + const axutil_env_t * env); + + /** + * Serialize op + * @param env environment. + * @param om_text pointer to om text struct to be serialized. + * @param om_output AXIOM output handler to be used in serializing. + * @return satus of the op. AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_text_serialize( + struct axiom_text *om_text, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** + * Sets the text value + * @param om_text om_text struct + * @param env environment. + * @param value text + * @return status of the op. AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_text_set_value( + struct axiom_text *om_text, + const axutil_env_t * env, + const axis2_char_t * value); + + /** + * Gets text value + * @param om_text om_text struct + * @param env environment. + * @return text value , NULL is returned if there is no text value. + */ + AXIS2_EXTERN const axis2_char_t *AXIS2_CALL + axiom_text_get_value( + struct axiom_text *om_text, + const axutil_env_t * env); + + /** + * Sets the text value + * @param om_text om_text struct + * @param env environment. + * @param value string + * @return status of the op. AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_text_set_value_str( + struct axiom_text *om_text, + const axutil_env_t * env, + axutil_string_t * value); + + /** + * Gets text value from the text node even when MTOM optimized + * @param om_text om_text struct + * @param env environment. + * @return text value base64 encoded text when MTOM optimized, + * NULL is returned if there is no text value. + */ + AXIS2_EXTERN const axis2_char_t *AXIS2_CALL + axiom_text_get_text( + axiom_text_t * om_text, + const axutil_env_t * env); + + /** + * Gets text value + * @param om_text om_text struct + * @param env environment. + * @return text valu stringe , NULL is returned if there is no text value. + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + axiom_text_get_value_str( + struct axiom_text *om_text, + const axutil_env_t * env); + + /** + * Sets optimized + * @param om_text pointer to om_text struct + * @param env environment + * @optimize optimize value + * @returns AXIS2_SUCCESS + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_text_set_optimize( + struct axiom_text *om_text, + const axutil_env_t * env, + axis2_bool_t optimize); + + /** + * @param om_text text value + * @param env environment + * @param is_binary + * @returns AXIS2_SUCCESS + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_text_set_is_binary( + struct axiom_text *om_text, + const axutil_env_t * env, + const axis2_bool_t is_binary); + + /** + * Get the data handler of the OM text + * @param om_text pointer to the OM Text struct + * @param environment Environment. MUST NOT be NULL + * + * @return the data handler of the OM text + */ + AXIS2_EXTERN axiom_data_handler_t *AXIS2_CALL + axiom_text_get_data_handler( + struct axiom_text *om_text, + const axutil_env_t * env); + + /** + * Get the Content ID of the OM text + * @param om_text pointer to the OM Text struct + * @param environment Environment. MUST NOT be NULL + * + * @return the content id of the OM text + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_text_get_content_id( + struct axiom_text *om_text, + const axutil_env_t * env); + + /** + * Set the content ID of the OM text + * @param om_text pointer to the OM Text struct + * @param environment Environment. MUST NOT be NULL + * @param content_id the content ID + * @return status of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_text_set_content_id( + axiom_text_t * om_text, + const axutil_env_t * env, + const axis2_char_t * content_id); + + /** + * Sets the boolean value indicating if the binary data associated with the text + * node should be sent in SOAP with Attachment (SwA) format or not. + * @param om_text text node + * @param env environment + * @param is_swa bool value, AXIS2_TRUE means use SwA format, else AXIS2_FALSE + * @returns AXIS2_SUCCESS + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_text_set_is_swa( + struct axiom_text *om_text, + const axutil_env_t * env, + const axis2_bool_t is_swa); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_TEXT_H */ diff --git a/axiom/include/axiom_util.h b/axiom/include/axiom_util.h new file mode 100644 index 0000000..9c87877 --- /dev/null +++ b/axiom/include/axiom_util.h @@ -0,0 +1,396 @@ + +/* + * 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_UTIL_H +#define AXIOM_UTIL_H + +#include <axutil_array_list.h> +#include <axutil_string.h> +#include <axiom.h> +#include <axutil_uri.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + /** + * After calling this method the variable child points to + * the node of the returning element + * @param ele_node axiom node + * @param env environment, MUST not be NULL + * @param uri uri + * return the first child element which has the given uri + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_first_child_element_with_uri( + axiom_node_t * ele_node, + const axutil_env_t * env, + axis2_char_t * uri, + axiom_node_t ** child); + /** + * After calling this method next_node will point to the + * previous sibling node to the returning node + * @param ele_node axiom node + * @param env environment, MUST not be NULL + * @param uri uri + * @param next_node + * return the next sibling element to the element which contains + * the give namespace uri + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_next_sibling_element_with_uri( + axiom_node_t * ele_node, + const axutil_env_t * env, + axis2_char_t * uri, + axiom_node_t ** next_node); + /** + * @param eleaxiom node + * @param env environment, MUST not be NULL + * @param ele_node + * @param child_node + * return the first child element this calls the method + * axiom_element_get_first_child_element + * + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_first_child_element( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axiom_node_t ** child_node); + /** + * @param ele axiom element + * @param env environment, MUST not be NULL + * @param ele_node + * @param child_node + * return the last child element of the given element ele_node + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_last_child_element( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axiom_node_t ** child_node); + /** + * @param ele axiom node + * @param env environment, MUST not be NULL + * @param ele_node + * @param next_node + * return the first child element which has the given uri + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_next_sibling_element( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axiom_node_t ** next_node); + /** + * @param ele axiom element + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param localname localname to find the first child element + * @param child_node + * + * return the first child element from ele_node which contains the + * given local name + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_first_child_element_with_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param localname to find the last child element + * @param child_node + * return the last child element which having the given local name + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_last_child_element_with_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param localname to find the last child element + * @param next_node + * return the next sibling element which is having the given local name + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_next_siblng_element_with_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axiom_node_t ** next_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param localname to find the last child element + * @param uri uri to of the namespace to find the first element + * @param next_node + * return the first child element which is having the given local + * name and the given namespace uri + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_first_child_element_with_uri_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * uri, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param localname to find the last child element + * @param uri uri of the namespace to find the last element + * @param next_node + * return the last child element which is having the given local name and + * the given namespace uri + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_last_child_element_with_uri_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * uri, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param localname to find the last child element + * @param uri uri of the namespace to find the last element + * @param next_node + * return next sibling element which is having the given local name and + * the given namespace uri + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_next_sibling_element_with_uri_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * uri, + axiom_node_t ** next_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param names local names to find the child element + * @param child_node + * return the first child element which is having all the localnames given + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_first_child_element_with_localnames( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axutil_array_list_t * names, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param names local names to find the last child element + * @param child_node + * return the last child element which is having all the localnames given + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_last_child_element_with_localnames( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axutil_array_list_t * names, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param names local names to find the next sibling + * @param child_node + * return the next sibling element which is having all the localnames given + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_next_siblng_element_with_localnames( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axutil_array_list_t * names, + axiom_node_t ** next_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node + * @param localname local name to find the first child + * @param attr_name attribute name to find first child + * @param attr_value attribute value of attr_name attribute + * @param child_node + * return the first child element which is having the given local + * name and the given attribute (attribute name and attribute value) + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_first_child_element_with_localname_attr( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * attr_name, + axis2_char_t * attr_value, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node + * @param localname local name to find the last child + * @param attr_name attribute name to find last child + * @param attr_value attribute value of attr_name attribute + * @param child_node + * return the last child element which is having the given local + * name and the given attribute (attribute name and attribute value) + */ + + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_last_child_element_with_localname_attr( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * attr_name, + axis2_char_t * attr_value, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node + * @param localname local name to find the next sibling child + * @param attr_name attribute name to find the next sibling child + * @param attr_value attribute value of attr_name attribute + * @param child_node + * return the next sibling child element which is having the given local + * name and the given attribute (attribute name and attribute value) + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_next_siblng_element_with_localname_attr( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * attr_name, + axis2_char_t * attr_value, + axiom_node_t ** next_node); + /** + * @param node axiom node + * @param env environment, MUST not be NULL + * + * return the element text of axiom_node + */ + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_util_get_child_text( + axiom_node_t * node, + const axutil_env_t * env); + /** + * @param node axiom node + * @param env environment, MUST not be NULL + * + * return the local name of axiom_node + */ + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_util_get_localname( + axiom_node_t * node, + const axutil_env_t * env); + /** + * @param om_node axiom node + * @param env environment, MUST not be NULL + * + * return the namespace uri of the give node variable om_node if + * there's no namespace in that particular om_node this method + * returns NULL + */ + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_util_get_node_namespace_uri( + axiom_node_t * om_node, + const axutil_env_t * env); + /** + * @param om_ele axiom node + * @param env environment, MUST not be NULL + * @param om_node + * return all the child element using the method + * axiom_child_element_iterator_create + */ + + AXIS2_EXTERN axiom_child_element_iterator_t *AXIS2_CALL + axiom_util_get_child_elements( + axiom_element_t * om_ele, + const axutil_env_t * env, + axiom_node_t * om_node); + + AXIS2_EXTERN axiom_document_t *AXIS2_CALL + axiom_util_new_document( + const axutil_env_t * env, + const axutil_uri_t * uri); + + AXIS2_EXTERN axiom_node_t* AXIS2_CALL + axiom_util_get_node_by_local_name( + const axutil_env_t *env, + axiom_node_t *node, + axis2_char_t *local_name); + + /** + * Creates a clone of given node + * @param env environment, MUST not be NULL + * @param node node to be cloned + * @return cloned node + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_util_clone_node( + const axutil_env_t *env, + axiom_node_t *node); + +#ifdef __cplusplus + } +#endif +#endif /* AXIOM_UTIL_H */ diff --git a/axiom/include/axiom_xml_reader.h b/axiom/include/axiom_xml_reader.h new file mode 100644 index 0000000..c9450a8 --- /dev/null +++ b/axiom/include/axiom_xml_reader.h @@ -0,0 +1,706 @@ + +/* + * 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 AXIOM_XML_READER_H +#define AXIOM_XML_READER_H + +/** + *@file axiom_xml_reader.h + *@brief this is the parser abstraction layer for axis2 + */ + +#include <axutil_env.h> +#include <axutil_utils.h> +#include <axiom_defines.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_xml_reader_ops axiom_xml_reader_ops_t; + typedef struct axiom_xml_reader axiom_xml_reader_t; + + /** + * @defgroup axiom_parser parser + * @ingroup axiom + * @{ + * @} + */ + + /** + * @defgroup axiom_xml_reader XML reader + * @ingroup axiom_parser + * @{ + */ + + typedef enum axiom_xml_reader_event_types + { + AXIOM_XML_READER_START_DOCUMENT = 0, /* <?xml version="1.0" encoding="utf-8"?> */ + AXIOM_XML_READER_START_ELEMENT, /* <element> */ + AXIOM_XML_READER_END_ELEMENT, /* </element> */ + AXIOM_XML_READER_SPACE, /* <x> </x>*//*event is for value, not for x*/ + AXIOM_XML_READER_EMPTY_ELEMENT, /* <element/> */ + AXIOM_XML_READER_CHARACTER, /* <x>text</x>*//*event is for text, not for x*/ + AXIOM_XML_READER_ENTITY_REFERENCE, + AXIOM_XML_READER_COMMENT, /* <!--comment--> */ + AXIOM_XML_READER_PROCESSING_INSTRUCTION, + AXIOM_XML_READER_CDATA, + AXIOM_XML_READER_DOCUMENT_TYPE + } axiom_xml_reader_event_types; + + /** + * \brief AXIOM_XML_READER ops + * Encapsulator struct for ops of axiom_xml_reader + */ + + struct axiom_xml_reader_ops + { + + /** + * causes the reader to read the next parse event. + * returns the event just read + * @param parser axiom_xml_reader struct + * @param env axutil_environment, MUST NOT be NULL + * @returns one of the events defined in + * axiom_xml_reader_event_types + */ + + int( + AXIS2_CALL + * next)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * free pull_parser + * @param parser axiom_xml_reader struct + * @param env axutil_environment MUST NOT be NULL + * @returns axis2_status_code + */ + + void( + AXIS2_CALL + * free)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Get the Number of attributes in the current element + * @param parser axiom_xml_reader + * @param env axutil_environment, MUST NOT be NULL. + * @returns Number of attributes , AXIS2_FAILURE on error + */ + + int( + AXIS2_CALL + * get_attribute_count)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** This is used to get an attribute's localname using an index relative to + * current element.The iterations are not zero based. + * To access the first attribute use 1 for parameter i + * @param parser parser struct + * @param env environment struct + * @param i attribute index + * @returns the attribute localname + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_attribute_name_by_number)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** This is used to get an attribute's prefix using an index relative to + * current element. The iterations are not zero based. + * To access the first attribute use 1 for parameter i + * @param parser parser struct + * @param env environment, MUST NOT be NULL + * @param i attribute index. + * @returns the attribute prefix, returns NULL on error, + * caller must free the value using axiom_xml_reader_xml_free macro + */ + + axis2_char_t *( + AXIS2_CALL + * get_attribute_prefix_by_number)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** Gets an attribute's value using an index relative to + * current element. The iterations are not zero based. + * To access the first attribute use 1 for parameter i + * @param parser parser struct + * @param env environment, MUST NOT be NULL. + * @param i attribute index + * @returns the attribute value, returns NULL on error, + * caller must free the value using axiom_xml_reader_xml_free macro + */ + + axis2_char_t *( + AXIS2_CALL + * get_attribute_value_by_number)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** Gets an attribute's namespace uri using an index relative to + * current element. The iterations are not zero based. + * To access the first attribute use 1 for parameter i + * @param parser parser struct + * @param env environment struct + * @param i attribute index + * @returns the attribute value, returns NULL on error + * caller must free the value using axiom_xml_reader_xml_free macro + */ + + axis2_char_t *( + AXIS2_CALL + * get_attribute_namespace_by_number)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** Returns the text value of current element + * @param parser pointer to parser + * @param env environment, MUST not be NULL + * @returns Text Value, NULL on error + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_value)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Returns the namespace count of current element + * @param parser parser struct + * @param env environment + * @returns namespace count of current element, + */ + int( + AXIS2_CALL + * get_namespace_count)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Accesses the namespace uri of the namespaces declared in current element + * using an index + * @param parser parser struct + * @param env environment + * @param i index + * @returns namespace uri of corresponding namespace + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_namespace_uri_by_number)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * Accesses the namespace prefix of the namespaces declared in current element + * using an index + * @param parser parser struct + * @param env environment + * @param i index + * @returns namespace prefix of corresponding namespace + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_namespace_prefix_by_number)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * Used to obtain the current element prefix + * @param parser parser struct + * @param env environment struct + * @returns prefix , NULL on error + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_prefix)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Used to obtain the current element localname + * @param parser parser struct + * @param env environment struct + * @returns localname , NULL on error + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_name)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Used to get the processingInstruction target + * @param parser parser struct + * @param env environment, MUST NOT be NULL. + * @returns target value of processingInstruction + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_pi_target)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Gets the processingInstruction data + * @param parser parser struct + * @param env environment, MUST NOT be NULL. + * @returns data of processingInstruction + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_pi_data)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Used to get the DTD + * @param parser pointer to pull parser struct + * @param env environment, MUST NOT be NULL. + * @return text of doctype declaration. NULL is returns of no data + * exists. + */ + axis2_char_t *( + AXIS2_CALL + * get_dtd)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Free function , this function wraps the underlying parser's + * xml free function. For freeing values obatined by calling + * pull parser api methods, This function must be used. + * @param parser pointer to axiom_xml_reader + * @param env environment, MUST NOT be NULL. + * @param data data values to be destroyed + * @return status of the op, AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + void( + AXIS2_CALL + * xml_free)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + void *data); + + /** + * Gets the char set encoding of the parser + * @param parser xml parser + * @param env environment + * @returns char set encoding string or NULL in failure + */ + + axis2_char_t *( + AXIS2_CALL + * get_char_set_encoding)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** Returns the namespace uri associated with current node */ + axis2_char_t *( + AXIS2_CALL + * get_namespace_uri)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + axis2_char_t *( + AXIS2_CALL + * get_namespace_uri_by_prefix)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + axis2_char_t * prefix); + + void *( + AXIS2_CALL + * get_context)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + axis2_char_t *( + AXIS2_CALL + * get_current_buffer)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + }; + + /** + * @brief axiom_xml_reader struct + * Axis2 OM pull_parser + */ + struct axiom_xml_reader + { + const axiom_xml_reader_ops_t *ops; + }; + + /** + * Creates an instance of axiom_xml_reader to parse + * a file using an xml document in a file system + * @param env environment struct, must not be null + * @param filename url of an xml document + * @returns a pointer to xml_pull_parser_t struct + * NULL on error with error code set in the environment's error + */ + AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL + axiom_xml_reader_create_for_file( + const axutil_env_t * env, + char *filename, + const axis2_char_t * encoding); + + /** + * This create an instance of axiom_xml_reader to + * parse a xml document in a buffer. It takes a callback + * function that takes a buffer and the size of the buffer + * The user must implement a function that takes in buffer + * and size and fill the buffer with specified size + * with xml stream, parser will call this function to fill the + * buffer on the fly while parsing. + * @param env environment MUST NOT be NULL. + * @param read_input_callback() callback function that fills + * a char buffer. + * @param close_input_callback() callback function that closes + * the input stream. + * @param ctx, context can be any data that needs to be passed + * to the callback method. + * @param encoding encoding scheme of the xml stream + */ + AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL + axiom_xml_reader_create_for_io( + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK, + AXIS2_CLOSE_INPUT_CALLBACK, + void *ctx, + const axis2_char_t * encoding); + + /** + * Create an axiom_xml_reader_t using a buffer, which is the xml input + * @param env environment, MUST not be NULL + * @param container any data that needs to passed to the corresponding + * parser's create_for_memory method. The reader does not take ownership + * of this data. + * @param size size of the buffer + * @param encoding encoding of the xml + * @return pointer to axiom_xml_reader_t struct on success , NULL otherwise + */ + AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL + axiom_xml_reader_create_for_memory( + const axutil_env_t * env, + void *container, + int size, + const axis2_char_t * encoding, + int type); + + /** + * init function initializes the parser. When using libxml2 parser, this function + * is needed to initialize libxml2. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_reader_init(void + ); + + /** + * parser cleanup function. This function is used to clean up the globals of libxml2 + * parser. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_reader_cleanup(void + ); + + /** + * while parsing through this method is calling for each and every + * time it parse a charactor.This is the atomic method which parse charactors. + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_xml_reader_next( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_xml_reader_free( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * free method for xml reader + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_xml_reader_get_attribute_count( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return number of attributes in an element + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_attribute_name_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return the attribute name by number + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_attribute_prefix_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return the attribute prefix by number + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_attribute_value_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return attribute value by number + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_attribute_namespace_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return attribute namespace by number + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_value( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return value of the element + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_xml_reader_get_namespace_count( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return the number of namespaces in an element + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_namespace_uri_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return uri or the namespace by number + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_namespace_prefix_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return prefix of the namespace by number + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_prefix( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return namespace prefix + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_name( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return name of the element + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_pi_target( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_pi_data( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_dtd( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_xml_reader_xml_free( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + void *data); + + /** + * free method for xml + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_char_set_encoding( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return charactor encoding + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_namespace_uri( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_namespace_uri_by_prefix( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + axis2_char_t * prefix); + + AXIS2_EXTERN void *AXIS2_CALL + axiom_xml_reader_get_context( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_current_buffer( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_XML_READER_H */ + + + + + + + + + + + + + + diff --git a/axiom/include/axiom_xml_writer.h b/axiom/include/axiom_xml_writer.h new file mode 100644 index 0000000..cddfc73 --- /dev/null +++ b/axiom/include/axiom_xml_writer.h @@ -0,0 +1,1014 @@ + +/* + * 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 AXIOM_XML_WRITER_H +#define AXIOM_XML_WRITER_H + +/** + *@file axiom_xml_writer.h + *@brief this is the parser abstraction layer for axis2 + */ + +#include <axutil_env.h> +#include <axiom_defines.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_xml_writer_ops axiom_xml_writer_ops_t; + typedef struct axiom_xml_writer axiom_xml_writer_t; + + /** + * @defgroup axiom_xml_writer XML writer + * @ingroup axiom_parser + * @{ + */ + + /** + * \brief axiom_xml_writer ops + * Encapsulator struct for ops of axiom_xml_writer + */ + + struct axiom_xml_writer_ops + { + + /** + * Free xml writer + * @param writer pointer to xml_writer struct to be freed + * @param env environment, MUST NOT be NULL. + * @returns status of the op. + * AXIS2_SUCCESS on success and AXIS2_FAILURE on error + */ + + void( + AXIS2_CALL + * free)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * Write a start tag to output stream with localname. + * Internally the writer keeps track of the opened tags + * @param writer pointer to xml writer struct + * @param env environment. MUST NOT be NULL. + * @param localname localname of the tag, May not be NULL. + * @return the status of the op, AXIS2_SUCCESS on success + AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_start_element)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname); + + /** + * write an end tag to the output relying on the internal + * state of writer to determine the prefix and localname of + * the element + * @param writer xml_writer struct + * @param env environment, MUST NOT be NULL. + * @return status of the op. AXIS2_SUCCESS on success. + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * end_start_element)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * Write an element tag with localname and namespace uri + * @param writer pointer to xml writer struct + * @param env environment struct + * @param localname localname of the tag, May not be null. + * @param namespace_uri the namespace URI of the the pefix + * to use.may not be null. + * @returns status of the op, AXIS2_SUCCESS on success. + * AXIS2_FAILURE on error + */ + axis2_status_t( + AXIS2_CALL + * write_start_element_with_namespace)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri); + + /** + * write a start tag to output + * @param writer pointer to xml_writer struct + * @param environment, MUST NOT be NULL. + * @param localname localname of the tag, May not be null. + * @param namespace_uri namespace to bind the prefix to + * @param prefix the prefix to the tag.May not be NULL. + * @return status of the op + AXIS2_SUCCESS on success. AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_start_element_with_namespace_prefix)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + + /** + * write an element tag with localname + * @param writer xml_writer + * @param env environment + * @param localname localname + * @return status of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_empty_element)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname); + + /** + * write empty_element with localname and namespace uri. + * @param writer xml writer + * @param env environment + * @param localname localname + * @param namespace uri + * @return status of the op, AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + + axis2_status_t( + AXIS2_CALL + * write_empty_element_with_namespace)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri); + + /** + * write empty element with namespace uri and prefix + * @param writer xml_writer + * @param env environment + * @param localname localname + * @param namespace_uri namespace uri + * @param prefix prefix + * @return status of the op, AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_empty_element_with_namespace_prefix)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + + /** + * write end tag with correct localname prefix resolved internally + * @param writer xml writer + * @param env environment + * @return status of the op, AXIS2_SUCCESS on success, + * AXIS2_FAILURE on failure + */ + axis2_status_t( + AXIS2_CALL + * write_end_element)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * write end document + * @param writer xml writer + * @param env environment + * @return status of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_end_document)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * write attribute with localname and value + * @param writer writer + * @param env environment + * @param localname localname + * @param value text value of attribute + * @return status of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_attribute)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value); + + /** + * @param writer + * @param env environment + * @param localname + * @param value text value of attribute + * @param namespace uri namespace uri + * @return status code of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_attribute_with_namespace)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri); + + /** + * @param writer xml_writer + * @param env environment + * @param localname localname + * @param value text value of attribute + * @param namespace uri namespaceuri + * @param prefix prefix + */ + axis2_status_t( + AXIS2_CALL + * write_attribute_with_namespace_prefix)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + + /** + * @param writer xml_writer + * @param env environment + * @param prefix prefix + * @param namespace uri namespaceuri + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + + axis2_status_t( + AXIS2_CALL + * write_namespace)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * namespace_uri); + + /** + * @param writer xml_writer + * @param env environment + * @param namespace uri namespaceuri + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + + axis2_status_t( + AXIS2_CALL + * write_default_namespace)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * namespace_uri); + + /** + * @param writer xml_writer + * @param env environment + * @param value value + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + + axis2_status_t( + AXIS2_CALL + * write_comment)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * value); + + /** + * @param writer xml_writer + * @param env environment + * @param target pi target + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + + axis2_status_t( + AXIS2_CALL + * write_processing_instruction)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target); + + /** + * @param writer xml_writer + * @param env environment + * @param target pi target + * @param data pi data + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + + axis2_status_t( + AXIS2_CALL + * write_processing_instruction_data)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target, + axis2_char_t * data); + + /** + * @param writer xml_writer + * @param env environment + * @param data cdata + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_cdata)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * data); + + /** + * @param writer xml_writer + * @param env environment + * @param dtd dtd + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_dtd)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * dtd); + + /** + * @param writer xml_writer + * @param env environment + * @param name name + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_entity_ref)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * name); + + /** + * @param writer xml_writer + * @param env environment + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_start_document)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer xml_writer + * @param env environment + * @param version version + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_start_document_with_version)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * version); + + /** + * @param writer xml_writer + * @param env environment + * @param version version + * @param encoding encoding + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_start_document_with_version_encoding)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * version, + axis2_char_t * encoding); + + /** + * @param writer xml_writer + * @param env environment + * @param text text + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_characters)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text); + + /** + * @param writer xml_writer + * @param env environment + * @param uri uri + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_char_t *( + AXIS2_CALL + * get_prefix)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri); + + /** + * @param writer xml_writer + * @param env environment + * @param prefix prefix + * @param uri uri + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * set_prefix)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * uri); + + /** + * @param writer xml_writer + * @param env environment + * @param uri uri + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * set_default_prefix)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri); + + /** + * @param writer xml_writer + * @param env environment + * @param text text + * @param in_attr + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_encoded)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text, + int in_attr); + + void *( + AXIS2_CALL + * get_xml)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + unsigned int( + AXIS2_CALL + * get_xml_size)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + int( + AXIS2_CALL + * get_type)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + axis2_status_t( + AXIS2_CALL + * write_raw)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * content); + axis2_status_t( + AXIS2_CALL + * flush)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + }; + + /** + * @brief axis2_pull_parser struct + * Axis2 OM pull_parser + */ + + struct axiom_xml_writer + { + const axiom_xml_writer_ops_t *ops; + }; + + /** + * create function for axiom_xml_writer + * @param env environment + * @param filename filename + * @param encoding encoding + * @param is_prefix_default + * @param compression + * return xml writer wrapper structure + */ + AXIS2_EXTERN axiom_xml_writer_t *AXIS2_CALL + axiom_xml_writer_create( + const axutil_env_t * env, + axis2_char_t * filename, + axis2_char_t * encoding, + int is_prefix_default, + int compression); + + /** + * create fuction for xml writer for memory buffer + * @param env environment struct, must not be null + * @param env environment + * @param encoding encoding + * @param is_prefix_default + * @param compression + * @return xml writer wrapper structure. + */ + AXIS2_EXTERN axiom_xml_writer_t *AXIS2_CALL + axiom_xml_writer_create_for_memory( + const axutil_env_t * env, + axis2_char_t * encoding, + int is_prefix_default, + int compression, + int type); + + /** + * free method for axiom xml writer + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_xml_writer_free( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname local name of the start element + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_start_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname); + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_end_start_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_start_element_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname localname of the start element + * @param namespace_uri namespace uri of that element + * @param prefix prefix of that namespace + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_start_element_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname local name of the element + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_empty_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname local name of the element + * @param namespace_uri uri of the namespace + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_empty_element_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname local name of the element + * @param namespace_uri uri of the namespace + * @param prefix prefix of the namespace + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_empty_element_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_end_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_end_document( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname local name of the element + * @param value value of the element + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_attribute( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname local name of the element + * @param value value of the element + * @param uri of the namespace + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_attribute_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname local name of the element + * @param value value of the element + * @param uri of the namespace + * @param prefix of the namespace + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_attribute_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param prefix prefix of the namespace + * @param uri of the namespace + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * namespace_uri); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_default_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * namespace_uri); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_comment( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * value); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_processing_instruction( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_processing_instruction_data( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target, + axis2_char_t * data); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_cdata( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * data); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_dtd( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * dtd); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_entity_ref( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * name); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_start_document( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_start_document_with_version( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * version); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_start_document_with_version_encoding( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * version, + axis2_char_t * encoding); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_characters( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_writer_get_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return prefix + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_set_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * uri); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_set_default_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri); + + /** + * sets the default prefix + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_encoded( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text, + int in_attr); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN void *AXIS2_CALL + axiom_xml_writer_get_xml( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN unsigned int AXIS2_CALL + axiom_xml_writer_get_xml_size( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return size of the xml + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_xml_writer_get_type( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return type + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_raw( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * content); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_flush( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_XML_WRITER_H */ diff --git a/axiom/include/axiom_xpath.h b/axiom/include/axiom_xpath.h new file mode 100644 index 0000000..d2b0ee2 --- /dev/null +++ b/axiom/include/axiom_xpath.h @@ -0,0 +1,407 @@ + +/* + * 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_XPATH_H +#define AXIOM_XPATH_H + +#include <axiom.h> +#include <axutil_env.h> +#include <axutil_stack.h> +#include <axiom_soap.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_xpath_api api + * @ingroup axiom_xpath + * @{ + */ + + + /** + * Enable tracing + */ + +#define AXIOM_XPATH_DEBUG + + /** + * An error occured while evaluating the xpath expression + */ +#define AXIOM_XPATH_EVALUATION_ERROR 0 + +#define AXIOM_XPATH_ERROR_STREAMING_NOT_SUPPORTED 10 + + /* Typedefs */ + + /** + * XPath expression + * It includes the expression as a string and parsed data. + */ + typedef struct axiom_xpath_expression axiom_xpath_expression_t; + + /** + * The XPath context + * Keeps a reference to the context node or attribute, + * XPath expression, environment and result set. + */ + typedef struct axiom_xpath_context axiom_xpath_context_t; + + /** + * XPath result set + * Contains the result set and other information such as + * whether the expression was evaluated successfully. + */ + typedef struct axiom_xpath_result axiom_xpath_result_t; + + /** + * XPath result + * Stores type and value of the result. + */ + typedef struct axiom_xpath_result_node axiom_xpath_result_node_t; + + /** + * XPath result types + */ + typedef enum axiom_xpath_result_type_t + { + AXIOM_XPATH_TYPE_NODE = 0, + AXIOM_XPATH_TYPE_ATTRIBUTE, + AXIOM_XPATH_TYPE_NAMESPACE, + AXIOM_XPATH_TYPE_TEXT, + AXIOM_XPATH_TYPE_NUMBER, + AXIOM_XPATH_TYPE_BOOLEAN + } axiom_xpath_result_type_t; + + typedef int (*axiom_xpath_function_t)(axiom_xpath_context_t *context, + int np); + + /** + * XPath expression + */ + struct axiom_xpath_expression + { + /** XPath expression as a string */ + axis2_char_t* expr_str; + + /** Length of the expression */ + int expr_len; + + /** A cursor pointing to the position currently being parsed */ + int expr_ptr; + + /** Parsed expression in an array list*/ + axutil_array_list_t *operations; + + /** A pointer to the start operation in operations */ + int start; + }; + + /** + * XPath context + */ + struct axiom_xpath_context + { + /** Environment */ + const axutil_env_t *env; + + /** List of namespaces */ + axutil_hash_t *namespaces; + + /** Set of functions */ + axutil_hash_t *functions; + + /** Root node */ + axiom_node_t *root_node; + + /** Context node */ + axiom_node_t *node; + + /** Context attribute */ + axiom_attribute_t *attribute; + + /** Context attribute */ + axiom_namespace_t *ns; + + /** Context position */ + int position; + + /** Context size + * *Does not work location paths due to optimizations */ + int size; + + /** XPath expression */ + axiom_xpath_expression_t *expr; + + /** Streaming */ + axis2_bool_t streaming; + + /** Stack of processed items */ + axutil_stack_t *stack; + + /* TODO: + functions + variables + etc */ + }; + + /** + * XPath result set + */ + struct axiom_xpath_result + { + /** A flag indicating whether errors occured while evaluting XPath + * expression */ + int flag; + + /** An array list containing the set of results */ + axutil_array_list_t * nodes; + }; + + /** + * XPath result + */ + struct axiom_xpath_result_node + { + /** Type of result */ + axiom_xpath_result_type_t type; + + /** Value */ + void * value; + }; + + /** + * Compile an XPath expression + * + * @param env Environment must not be null + * @param xpath_expr A pointer to the XPath expression + * @return The parsed XPath expression. Returns NULL if an error occured + * while parsing. + */ + AXIS2_EXTERN axiom_xpath_expression_t * AXIS2_CALL axiom_xpath_compile_expression( + const axutil_env_t *env, + const axis2_char_t* xpath_expr); + + /** + * Create an empty XPath context + * + * @param env Environment must not be null + * @param root_node A pointer to the root of the tree + * @return The initialized XPath context. + */ + AXIS2_EXTERN axiom_xpath_context_t * AXIS2_CALL axiom_xpath_context_create( + const axutil_env_t *env, + axiom_node_t * root_node); + + /** + * Evaluate an parsed XPath expression. Different expressions could + * be evaluated on the same context, and same expression could be + * evaluated on multiple trees without recompiling. + * + * @param context XPath context must not be null + * @param xpath_expr XPath expression to be evaluated + * @return The set of results. + */ + AXIS2_EXTERN axiom_xpath_result_t * AXIS2_CALL axiom_xpath_evaluate( + axiom_xpath_context_t *context, + axiom_xpath_expression_t *xpath_expr); + + + /** + * Convert an XPath result to a boolean. + * If the result is a boolean the value of it is returned. + * If the result is a number, AXIS2_TRUE is + * returned if the value is not equal to 0 and AXIS2_FALSE otherwise. + * Otherwise AXIS2_TRUE is returned if the result is not NULL and AXIS2_FALSE otherwise. + * + * @param env Environment must not be null + * @param node A pointer to the XPath result + * @return The boolean value. + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL axiom_xpath_cast_node_to_boolean( + const axutil_env_t *env, + axiom_xpath_result_node_t * node); + + /** + * Convert an XPath result to a number. + * If the result is a boolean, 1 is returned if it's true and 0 otherwise. + * If the result is a number the value of it is returned. + * Otherwise AXIS2_TRUE is returned if the result is not NULL and AXIS2_FALSE otherwise. + * + * @param env Environment must not be null + * @param node A pointer to the XPath result + * @return The numerical value. + */ + AXIS2_EXTERN double AXIS2_CALL axiom_xpath_cast_node_to_number( + const axutil_env_t *env, + axiom_xpath_result_node_t * node); + + /** + * Convert an XPath result to text. + * If the result is a boolean, "true" is returned if it's true and "false" otherwise. + * If the result is a number the text representation of it is returned. + * If the result is a text the value of it is returned. + * If the result is an axiom node, the text value of it is returned + * If the result is an axiom attribue, the text value of it is returned + * + * @param env Environment must not be null + * @param node A pointer to the XPath result + * @return The text value. + */ + AXIS2_EXTERN axis2_char_t * AXIS2_CALL axiom_xpath_cast_node_to_string( + const axutil_env_t *env, + axiom_xpath_result_node_t * node); + + /** + * Convert an XPath result to an axiom node. + * If the result is an axiom node it is returned and NULL otherwise. + * + * @param env Environment must not be null + * @param node A pointer to the XPath result + * @return The axiom node. + */ + AXIS2_EXTERN axiom_node_t * AXIS2_CALL axiom_xpath_cast_node_to_axiom_node( + const axutil_env_t *env, + axiom_xpath_result_node_t * node); + + + /** + * Free XPath context + * + * @param env Environment must not be null + * @param context XPath context must not be null + */ + AXIS2_EXTERN void AXIS2_CALL axiom_xpath_free_context( + const axutil_env_t *env, + axiom_xpath_context_t *context); + + /** + * Free XPath expression + * + * @param env Environment must not be null + * @param xpath_expr XPath expression must not be null + */ + AXIS2_EXTERN void AXIS2_CALL axiom_xpath_free_expression( + const axutil_env_t *env, + axiom_xpath_expression_t * xpath_expr); + + /** + * Free XPath result set + * + * @param env Environment must not be null + * @param result XPath result set must not be null + */ + AXIS2_EXTERN void AXIS2_CALL axiom_xpath_free_result( + const axutil_env_t *env, + axiom_xpath_result_t* result); + + /** + * Registers a XPath namespace + * + * @param context XPath Context, must not be null + * @param ns AXIOM namespace, must not be null + */ + AXIS2_EXTERN void AXIS2_CALL axiom_xpath_register_namespace( + axiom_xpath_context_t *context, + axiom_namespace_t *ns); + + /** + * Get a registered namespace by the prefix. + * If there is no namespace registered by the given prefix NULL will be returned + * + * @param context XPath Context, must not be null + * @param prefix Prefix of the namespace, must not be null + * @return The namespace corresponding to the prefix. + */ + AXIS2_EXTERN axiom_namespace_t * AXIS2_CALL axiom_xpath_get_namespace( + axiom_xpath_context_t *context, + axis2_char_t *prefix); + + /** + * Clears all registered XPath namespaces + * + * @param context XPath Context, must not be null + */ + AXIS2_EXTERN void AXIS2_CALL axiom_xpath_clear_namespaces( + axiom_xpath_context_t *context); + + /** + * Evaluates an XPath expression on streaming XML. + * Not all expressions can be evaluated on streaming XML. + * If the expression cannot be evaluated on streaming XML NULL will be returned. + * + * @param context XPath Context, must not be null + * @param xpath_expr XPath expression to be evaluated + */ + AXIS2_EXTERN axiom_xpath_result_t * AXIS2_CALL axiom_xpath_evaluate_streaming( + axiom_xpath_context_t *context, + axiom_xpath_expression_t *xpath_expr); + + /** + * Checks whether the given expression can be evaluated on streaming XML. + * If it is possible AXIS2_TRUE will be retuned; AXIS2_FALSE otherwise. + * + * @param env Axis2 environment, must not be null + * @param expr Complied XPath expression, must not be null + * @return A boolean indicating whether the expression can be evaluated on streaming XML. + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL axiom_xpath_streaming_check( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Setup the XPath core function library + * + * @param context XPath Context, must not be null + */ + AXIS2_EXTERN void AXIS2_CALL axiom_xpath_register_default_functions_set( + axiom_xpath_context_t *context); + + /** + * Registers a custom XPath function http://www.w3.org/TR/xpath#corelib + * + * @param context XPath Context, must not be null + * @param name Name of the function, must not be null + * @param func Pointer to the function, must not be null + */ + AXIS2_EXTERN void AXIS2_CALL axiom_xpath_register_function( + axiom_xpath_context_t *context, + axis2_char_t *name, + axiom_xpath_function_t func); + + /** + * Retrive a pointer to a registered funciton by the function name. + * If there is no function registered by the given name, NULL will be returned. + * + * @param context XPath Context, must not be null + * @param name Name of the function, must not be null + * @return The corresponding function. + */ + AXIS2_EXTERN axiom_xpath_function_t AXIS2_CALL axiom_xpath_get_function( + axiom_xpath_context_t *context, + axis2_char_t *name); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif |