summaryrefslogtreecommitdiffstats
path: root/axiom/src/om
diff options
context:
space:
mode:
authorGravatar shankar2010-03-23 10:51:35 +0000
committerGravatar shankar2010-03-23 10:51:35 +0000
commitfbdd94e3f0e62cb595aef2bba28f50c97b722f56 (patch)
tree5a183470f7f18b45fc608cae03aba35a6db094ba /axiom/src/om
parent34b4cde423f1180d68526c6d401d84ab7881c8c1 (diff)
downloadaxis2c-fbdd94e3f0e62cb595aef2bba28f50c97b722f56.tar.gz
axis2c-fbdd94e3f0e62cb595aef2bba28f50c97b722f56.tar.bz2
refactor
git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@926525 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'axiom/src/om')
-rw-r--r--axiom/src/om/axiom_stax_builder_internal.h25
-rw-r--r--axiom/src/om/om_document.c31
-rw-r--r--axiom/src/om/om_stax_builder.c168
3 files changed, 113 insertions, 111 deletions
diff --git a/axiom/src/om/axiom_stax_builder_internal.h b/axiom/src/om/axiom_stax_builder_internal.h
index ca78e7d..31344d5 100644
--- a/axiom/src/om/axiom_stax_builder_internal.h
+++ b/axiom/src/om/axiom_stax_builder_internal.h
@@ -92,18 +92,7 @@ extern "C"
struct axiom_stax_builder *builder,
const axutil_env_t * env);
- /**
- * Builds the next node from stream. Moves pull parser forward and reacts
- * to events.
- * @param builder pointer to stax builder struct to be used
- * @param environment Environment. MUST NOT be NULL.
- * @return a pointer to the next node, or NULL if there are no more nodes.
- * On erros sets the error and returns NULL.
- */
- axiom_node_t *AXIS2_CALL
- axiom_stax_builder_next(
- struct axiom_stax_builder *builder,
- const axutil_env_t * env);
+
#if 0
/**
@@ -128,6 +117,18 @@ extern "C"
const axutil_env_t * env,
axis2_bool_t enable_cache);
+ /**
+ * Builds the next node from stream. Moves pull parser forward and reacts
+ * to events.
+ * @param builder pointer to stax builder struct to be used
+ * @param environment Environment. MUST NOT be NULL.
+ * @return a pointer to the next node, or NULL if there are no more nodes.
+ * On erros sets the error and returns NULL.
+ */
+ axiom_node_t *AXIS2_CALL
+ axiom_stax_builder_next(
+ struct axiom_stax_builder *builder,
+ const axutil_env_t * env);
#endif
diff --git a/axiom/src/om/om_document.c b/axiom/src/om/om_document.c
index 625fd5b..aed3749 100644
--- a/axiom/src/om/om_document.c
+++ b/axiom/src/om/om_document.c
@@ -89,16 +89,20 @@ axiom_document_get_root_element(
axiom_document_t * document,
const axutil_env_t * env)
{
- if(document->root_element)
- {
- return document->root_element;
- }
-
- /* force to build the root node */
- if(!axiom_stax_builder_next(document->builder, env))
+ if(!document->root_element)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_DOCUMENT_STATE_ROOT_NULL, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to get root node");
+ /* force to build the root node */
+ int token;
+ do{
+ token = axiom_stax_builder_next_with_token(document->builder, env);
+ if(token == -1)
+ {
+ AXIS2_ERROR_SET(env->error,
+ AXIS2_ERROR_INVALID_DOCUMENT_STATE_ROOT_NULL, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to get root node");
+ return NULL;
+ }
+ }while(token != AXIOM_XML_READER_START_ELEMENT);
}
return document->root_element;
@@ -111,12 +115,11 @@ axiom_document_build_all(
{
do
{
- axiom_node_t *ret_val = NULL;
- ret_val = axiom_stax_builder_next(document->builder, env);
- if(!ret_val && !axiom_node_is_complete(document->root_element, env))
+ int token = axiom_stax_builder_next_with_token(document->builder, env);
+ if((token == -1) && (!axiom_node_is_complete(document->root_element, env)))
{
- /* if return value is null and root node is not fully completed, this means there is
- * an error occurred */
+ /* if returned token is "invalid token" and root node is not fully completed,
+ * this means there is an error occurred */
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
"Error occurred when building all nodes of document");
return NULL;
diff --git a/axiom/src/om/om_stax_builder.c b/axiom/src/om/om_stax_builder.c
index aece97e..a8cfa88 100644
--- a/axiom/src/om/om_stax_builder.c
+++ b/axiom/src/om/om_stax_builder.c
@@ -685,91 +685,6 @@ axiom_stax_builder_end_element(
return AXIS2_SUCCESS;
}
-axiom_node_t *AXIS2_CALL
-axiom_stax_builder_next(
- axiom_stax_builder_t * om_builder,
- const axutil_env_t * env)
-{
- int token = 0;
- axiom_node_t *node = NULL;
-
- do
- {
- if(om_builder->done)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_BUILDER_DONE_CANNOT_PULL, AXIS2_FAILURE);
- return NULL;
- }
-
- token = axiom_xml_reader_next(om_builder->parser, env);
- if(token == -1)
- {
- return NULL;
- }
-
- om_builder->current_event = token;
-
- switch(token)
- {
- case AXIOM_XML_READER_START_DOCUMENT:
- /*Do nothing */
- break;
-
- case AXIOM_XML_READER_START_ELEMENT:
- node = axiom_stax_builder_create_om_element(om_builder, env, AXIS2_FALSE);
- break;
-
- case AXIOM_XML_READER_EMPTY_ELEMENT:
-
-#ifdef AXIS2_LIBXML2_ENABLED
- node = axiom_stax_builder_create_om_element(om_builder, env, AXIS2_FALSE);
-#else
- node = axiom_stax_builder_create_om_element(om_builder, env, AXIS2_TRUE);
-#endif
-
- case AXIOM_XML_READER_END_ELEMENT:
- axiom_stax_builder_end_element(om_builder, env);
- break;
-
- case AXIOM_XML_READER_SPACE:
- node = axiom_stax_builder_create_om_text(om_builder, env);
- break;
-
- case AXIOM_XML_READER_CHARACTER:
- node = axiom_stax_builder_create_om_text(om_builder, env);
- break;
-
- case AXIOM_XML_READER_ENTITY_REFERENCE:
- break;
-
- case AXIOM_XML_READER_COMMENT:
-
- node = axiom_stax_builder_create_om_comment(om_builder, env);
- axiom_stax_builder_end_element(om_builder, env);
- break;
-
- case AXIOM_XML_READER_PROCESSING_INSTRUCTION:
-
- node = axiom_stax_builder_create_om_processing_instruction(om_builder, env);
- axiom_stax_builder_end_element(om_builder, env);
- break;
-
- case AXIOM_XML_READER_CDATA:
- break;
-
- case AXIOM_XML_READER_DOCUMENT_TYPE:
- break;
-
- default:
- break;
- }
- }
- while(!node && !axiom_node_is_complete(om_builder->root_node, env));
- return node;
-}
-
-
-
/**
* 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
@@ -1055,4 +970,87 @@ axiom_stax_builder_set_cache(
{
om_builder->cache = enable_cache;
}
+
+axiom_node_t *AXIS2_CALL
+axiom_stax_builder_next(
+ axiom_stax_builder_t * om_builder,
+ const axutil_env_t * env)
+{
+ int token = 0;
+ axiom_node_t *node = NULL;
+
+ do
+ {
+ if(om_builder->done)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_BUILDER_DONE_CANNOT_PULL, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ token = axiom_xml_reader_next(om_builder->parser, env);
+ if(token == -1)
+ {
+ return NULL;
+ }
+
+ om_builder->current_event = token;
+
+ switch(token)
+ {
+ case AXIOM_XML_READER_START_DOCUMENT:
+ /*Do nothing */
+ break;
+
+ case AXIOM_XML_READER_START_ELEMENT:
+ node = axiom_stax_builder_create_om_element(om_builder, env, AXIS2_FALSE);
+ break;
+
+ case AXIOM_XML_READER_EMPTY_ELEMENT:
+
+#ifdef AXIS2_LIBXML2_ENABLED
+ node = axiom_stax_builder_create_om_element(om_builder, env, AXIS2_FALSE);
+#else
+ node = axiom_stax_builder_create_om_element(om_builder, env, AXIS2_TRUE);
+#endif
+
+ case AXIOM_XML_READER_END_ELEMENT:
+ axiom_stax_builder_end_element(om_builder, env);
+ break;
+
+ case AXIOM_XML_READER_SPACE:
+ node = axiom_stax_builder_create_om_text(om_builder, env);
+ break;
+
+ case AXIOM_XML_READER_CHARACTER:
+ node = axiom_stax_builder_create_om_text(om_builder, env);
+ break;
+
+ case AXIOM_XML_READER_ENTITY_REFERENCE:
+ break;
+
+ case AXIOM_XML_READER_COMMENT:
+
+ node = axiom_stax_builder_create_om_comment(om_builder, env);
+ axiom_stax_builder_end_element(om_builder, env);
+ break;
+
+ case AXIOM_XML_READER_PROCESSING_INSTRUCTION:
+
+ node = axiom_stax_builder_create_om_processing_instruction(om_builder, env);
+ axiom_stax_builder_end_element(om_builder, env);
+ break;
+
+ case AXIOM_XML_READER_CDATA:
+ break;
+
+ case AXIOM_XML_READER_DOCUMENT_TYPE:
+ break;
+
+ default:
+ break;
+ }
+ }
+ while(!node && !axiom_node_is_complete(om_builder->root_node, env));
+ return node;
+}
#endif