You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by du...@apache.org on 2008/11/20 22:26:09 UTC

svn commit: r719381 [1/5] - in /webservices/axis2/trunk/c/axiom: src/xpath/ test/xpath/

Author: dumindu
Date: Thu Nov 20 13:26:08 2008
New Revision: 719381

URL: http://svn.apache.org/viewvc?rev=719381&view=rev
Log:
dos2unix. removing win32 newlines.


Modified:
    webservices/axis2/trunk/c/axiom/src/xpath/xpath.c
    webservices/axis2/trunk/c/axiom/src/xpath/xpath_functions.c
    webservices/axis2/trunk/c/axiom/src/xpath/xpath_functions.h
    webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals.h
    webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_engine.c
    webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_engine.h
    webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_iterators.c
    webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_iterators.h
    webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_parser.c
    webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_parser.h
    webservices/axis2/trunk/c/axiom/src/xpath/xpath_streaming.c
    webservices/axis2/trunk/c/axiom/src/xpath/xpath_streaming.h
    webservices/axis2/trunk/c/axiom/test/xpath/results.txt
    webservices/axis2/trunk/c/axiom/test/xpath/test.xml
    webservices/axis2/trunk/c/axiom/test/xpath/test_xpath.c

Modified: webservices/axis2/trunk/c/axiom/src/xpath/xpath.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/xpath/xpath.c?rev=719381&r1=719380&r2=719381&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/xpath/xpath.c (original)
+++ webservices/axis2/trunk/c/axiom/src/xpath/xpath.c Thu Nov 20 13:26:08 2008
@@ -1,414 +1,414 @@
-
-/*
- * 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.
- */
-
-#include "xpath.h"
-#include "xpath_internals.h"
-#include "xpath_internals_parser.h"
-#include "xpath_internals_engine.h"
-#include "xpath_functions.h"
-#include "xpath_streaming.h"
-
-/* Create XPath context */
-axiom_xpath_context_t * AXIS2_CALL axiom_xpath_context_create(
-    axutil_env_t *env,
-    axiom_node_t * root_node)
-{
-    axiom_xpath_context_t* context;
-
-    context = AXIS2_MALLOC(env->allocator,
-            sizeof(axiom_xpath_context_t));
-
-    context->env = env;
-    context->root_node = root_node;
-    context->node = root_node;
-    context->expr = NULL;
-    context->attribute = NULL;
-    context->namespaces = NULL;
-    context->functions = NULL;
-
-    axiom_xpath_register_default_functions_set(context);
-
-    return context;
-}
-
-/* Compile XPath expression */
-axiom_xpath_expression_t * AXIS2_CALL axiom_xpath_compile_expression(
-    const axutil_env_t *env,
-    const axis2_char_t* xpath_expr)
-{
-    axiom_xpath_expression_t* expr;
-
-    expr = AXIS2_MALLOC(env->allocator,
-            sizeof(axiom_xpath_expression_t));
-
-    expr->expr_str = axutil_strdup(env, xpath_expr);
-
-    if (axiom_xpath_compile(env, expr) == AXIOM_XPATH_PARSE_ERROR)
-    {
-        AXIS2_FREE(env->allocator, expr->expr_str);
-        AXIS2_FREE(env->allocator, expr);
-
-        return NULL;
-    }
-    else
-        return expr;
-}
-
-/* Evaluate compiled XPath expression */
-axiom_xpath_result_t * AXIS2_CALL axiom_xpath_evaluate(
-    axiom_xpath_context_t *context,
-    axiom_xpath_expression_t *xpath_expr)
-{
-    axiom_xpath_expression_copy(context, xpath_expr);
-
-    context->streaming = AXIS2_FALSE;
-
-    return axiom_xpath_run(context);
-}
-
-axiom_xpath_result_t * AXIS2_CALL axiom_xpath_evaluate_streaming(
-    axiom_xpath_context_t *context,
-    axiom_xpath_expression_t *xpath_expr)
-{
-    axiom_xpath_result_t *res;
-
-    axiom_xpath_expression_copy(context, xpath_expr);
-
-    if (axiom_xpath_streaming_check(context->env, xpath_expr))
-    {
-        context->streaming = AXIS2_TRUE;
-        return axiom_xpath_run(context);
-    }
-    else
-    {
-        res = AXIS2_MALLOC(
-                    context->env->allocator, sizeof(axiom_xpath_result_t));
-        res->nodes = NULL;
-        res->flag = AXIOM_XPATH_ERROR_STREAMING_NOT_SUPPORTED;
-
-        return res;
-    }
-}
-
-void AXIS2_CALL axiom_xpath_register_default_functions_set(
-    axiom_xpath_context_t *context)
-{
-    axiom_xpath_register_function(
-        context, "count", axiom_xpath_function_count);
-}
-
-
-void AXIS2_CALL axiom_xpath_register_function(
-    axiom_xpath_context_t *context,
-    axis2_char_t *name,
-    axiom_xpath_function_t func)
-{
-    if (name && func)
-    {
-        if (!context->functions)
-        {
-            context->functions = axutil_hash_make(context->env);
-        }
-
-        axutil_hash_set(context->functions, name, AXIS2_HASH_KEY_STRING, func);
-    }
-}
-
-axiom_xpath_function_t AXIS2_CALL axiom_xpath_get_function(
-    axiom_xpath_context_t *context,
-    axis2_char_t *name)
-{
-    axiom_xpath_function_t func = NULL;
-
-    if(context->functions)
-    {
-        func = axutil_hash_get(context->functions, name, AXIS2_HASH_KEY_STRING);
-    }
-
-    return func;
-}
-
-void AXIS2_CALL axiom_xpath_register_namespace(
-    axiom_xpath_context_t *context,
-    axiom_namespace_t *ns)
-{
-    axis2_char_t *prefix = NULL;
-
-    if (!context->namespaces)
-    {
-        context->namespaces = axutil_hash_make(context->env);
-    }
-
-    prefix = axiom_namespace_get_prefix(ns, context->env);
-
-    if (prefix)
-    {
-        axutil_hash_set(
-            context->namespaces, prefix, AXIS2_HASH_KEY_STRING, ns);
-    }
-}
-
-axiom_namespace_t * AXIS2_CALL axiom_xpath_get_namespace(
-    axiom_xpath_context_t *context,
-    axis2_char_t *prefix)
-{
-    axiom_namespace_t *ns = NULL;
-
-    if(context->namespaces)
-    {
-        ns = axutil_hash_get(context->namespaces, prefix, AXIS2_HASH_KEY_STRING);
-    }
-
-    return ns;
-}
-
-void AXIS2_CALL axiom_xpath_clear_namespaces(axiom_xpath_context_t *context)
-{
-    axutil_hash_index_t *hi;
-    void *val;
-
-    if (context->namespaces)
-    {
-        for (hi = axutil_hash_first(context->namespaces, context->env);
-                hi;
-                hi = axutil_hash_next(context->env, hi))
-        {
-            axutil_hash_this(hi, NULL, NULL, &val);
-            axiom_namespace_free((axiom_namespace_t *)val, context->env);
-        }
-
-        axutil_hash_free(context->namespaces, context->env);
-    }
-
-    context->namespaces = NULL;
-}
-
-/* Cast to boolean */
-axis2_bool_t AXIS2_CALL axiom_xpath_cast_node_to_boolean(
-    const axutil_env_t *env,
-    axiom_xpath_result_node_t * node)
-{
-    if (node->type == AXIOM_XPATH_TYPE_BOOLEAN)
-    {
-        return *(axis2_bool_t *)node->value;
-    }
-    else if (node->type == AXIOM_XPATH_TYPE_NUMBER)
-    {
-        /* Cannot evaluate as *(double *)(node->value) == 1e-12
-           since there might be an precision error */
-        if (*(double *)(node->value) > 1e-12
-                || *(double *)(node->value) < -1e-12)
-        {
-            return AXIS2_TRUE;
-        }
-        else
-        {
-            return AXIS2_FALSE;
-        }
-    }
-    else if (node->value)
-    {
-        return AXIS2_TRUE;
-    }
-    else
-    {
-        return AXIS2_FALSE;
-    }
-}
-
-/* Cast to double */
-double AXIS2_CALL axiom_xpath_cast_node_to_number(
-    const axutil_env_t *env,
-    axiom_xpath_result_node_t * node)
-{
-    if (node->type == AXIOM_XPATH_TYPE_BOOLEAN)
-    {
-        if (*(axis2_bool_t *)(node->value) == AXIS2_TRUE)
-        {
-            return 1.0;
-        }
-        else
-        {
-            return 1.0;
-        }
-    }
-    else if (node->type == AXIOM_XPATH_TYPE_NUMBER)
-    {
-        return *(double *)node->value;
-    }
-    else if (node->value)
-    {
-        return 1.0;
-    }
-    else
-    {
-        return 1.0;
-    }
-}
-
-/* Cast to text */
-axis2_char_t * AXIS2_CALL axiom_xpath_cast_node_to_string(
-    const axutil_env_t *env,
-    axiom_xpath_result_node_t * node)
-{
-    axiom_element_t *ele;
-    axis2_char_t *res;
-
-    if (!node->value)
-    {
-        return NULL;
-    }
-
-    if (node->type == AXIOM_XPATH_TYPE_BOOLEAN)
-    {
-        if (*(axis2_bool_t *)(node->value) == AXIS2_TRUE)
-        {
-            return axutil_strdup(env, "true");
-        }
-        else
-        {
-            return axutil_strdup(env, "false");
-        }
-    }
-    else if (node->type == AXIOM_XPATH_TYPE_NUMBER)
-    {
-        /* Allocate 20 bytes */
-        res = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 20);
-
-        sprintf(res, "%lf", *(double *)(node->value));
-
-        return res;
-    }
-    else if (node->type == AXIOM_XPATH_TYPE_TEXT)
-    {
-        return (axis2_char_t *)node->value;
-    }
-    else if (node->type == AXIOM_XPATH_TYPE_NODE)
-    {
-        ele = (axiom_element_t *)axiom_node_get_data_element(
-                    (axiom_node_t *)(node->value), env);
-
-        if (ele)
-        {
-            return axiom_element_get_text(
-                        ele, env, (axiom_node_t *)(node->value));
-        }
-        else
-        {
-            return NULL;
-        }
-    }
-    else if (node->type == AXIOM_XPATH_TYPE_ATTRIBUTE)
-    {
-        return axiom_attribute_get_value(
-                    (axiom_attribute_t *)(node->value), env);
-    }
-    else if (node->type == AXIOM_XPATH_TYPE_NAMESPACE)
-    {
-        return axiom_namespace_get_prefix(
-                    (axiom_namespace_t *)(node->value), env);
-    }
-
-    return NULL;
-}
-
-/* Cast to axiom node */
-axiom_node_t * AXIS2_CALL axiom_xpath_cast_node2axiom_node(
-    const axutil_env_t *env,
-    axiom_xpath_result_node_t * node)
-{
-    if (node->type == AXIOM_XPATH_TYPE_NODE && node->value)
-    {
-        return (axiom_node_t *)node->value;
-    }
-    else
-    {
-        return NULL;
-    }
-}
-
-/* Free context */
-void AXIS2_CALL axiom_xpath_free_context(
-    const axutil_env_t *env,
-    axiom_xpath_context_t *context)
-{
-    if (context)
-    {
-        /* Free the expression if not freed */
-        if (context->expr)
-        {
-            /* axiom_xpath_free_expression(env, context->expr); */
-
-            context->expr = NULL;
-        }
-
-        AXIS2_FREE(env->allocator, context);
-    }
-}
-
-/* Free expression */
-void AXIS2_CALL axiom_xpath_free_expression(
-    const axutil_env_t *env,
-    axiom_xpath_expression_t * xpath_expr)
-{
-    if (xpath_expr)
-    {
-        if (xpath_expr->expr_str)
-        {
-            AXIS2_FREE(env->allocator, xpath_expr->expr_str);
-
-            xpath_expr->expr_str = NULL;
-        }
-
-        AXIS2_FREE(env->allocator, xpath_expr);
-    }
-}
-
-/* Free result set */
-void AXIS2_CALL axiom_xpath_free_result(
-    const axutil_env_t *env,
-    axiom_xpath_result_t* result)
-{
-    if (result)
-    {
-        if (result->nodes)
-        {
-            axutil_array_list_free(result->nodes, env);
-        }
-
-        AXIS2_FREE(env->allocator, result);
-    }
-}
-
-/* Check if the expression can be evaluated on streaming XML */
-axis2_bool_t AXIS2_CALL axiom_xpath_streaming_check(
-    const axutil_env_t *env,
-    axiom_xpath_expression_t* expr)
-{
-    axiom_xpath_streaming_t r = AXIOM_XPATH_CHECK(expr->start);
-
-    if (r == AXIOM_XPATH_STREAMING_NOT_SUPPORTED)
-    {
-        return AXIS2_FALSE;
-    }
-    else
-    {
-        return AXIS2_TRUE;
-    }
-}
-
+
+/*
+ * 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.
+ */
+
+#include "xpath.h"
+#include "xpath_internals.h"
+#include "xpath_internals_parser.h"
+#include "xpath_internals_engine.h"
+#include "xpath_functions.h"
+#include "xpath_streaming.h"
+
+/* Create XPath context */
+axiom_xpath_context_t * AXIS2_CALL axiom_xpath_context_create(
+    axutil_env_t *env,
+    axiom_node_t * root_node)
+{
+    axiom_xpath_context_t* context;
+
+    context = AXIS2_MALLOC(env->allocator,
+            sizeof(axiom_xpath_context_t));
+
+    context->env = env;
+    context->root_node = root_node;
+    context->node = root_node;
+    context->expr = NULL;
+    context->attribute = NULL;
+    context->namespaces = NULL;
+    context->functions = NULL;
+
+    axiom_xpath_register_default_functions_set(context);
+
+    return context;
+}
+
+/* Compile XPath expression */
+axiom_xpath_expression_t * AXIS2_CALL axiom_xpath_compile_expression(
+    const axutil_env_t *env,
+    const axis2_char_t* xpath_expr)
+{
+    axiom_xpath_expression_t* expr;
+
+    expr = AXIS2_MALLOC(env->allocator,
+            sizeof(axiom_xpath_expression_t));
+
+    expr->expr_str = axutil_strdup(env, xpath_expr);
+
+    if (axiom_xpath_compile(env, expr) == AXIOM_XPATH_PARSE_ERROR)
+    {
+        AXIS2_FREE(env->allocator, expr->expr_str);
+        AXIS2_FREE(env->allocator, expr);
+
+        return NULL;
+    }
+    else
+        return expr;
+}
+
+/* Evaluate compiled XPath expression */
+axiom_xpath_result_t * AXIS2_CALL axiom_xpath_evaluate(
+    axiom_xpath_context_t *context,
+    axiom_xpath_expression_t *xpath_expr)
+{
+    axiom_xpath_expression_copy(context, xpath_expr);
+
+    context->streaming = AXIS2_FALSE;
+
+    return axiom_xpath_run(context);
+}
+
+axiom_xpath_result_t * AXIS2_CALL axiom_xpath_evaluate_streaming(
+    axiom_xpath_context_t *context,
+    axiom_xpath_expression_t *xpath_expr)
+{
+    axiom_xpath_result_t *res;
+
+    axiom_xpath_expression_copy(context, xpath_expr);
+
+    if (axiom_xpath_streaming_check(context->env, xpath_expr))
+    {
+        context->streaming = AXIS2_TRUE;
+        return axiom_xpath_run(context);
+    }
+    else
+    {
+        res = AXIS2_MALLOC(
+                    context->env->allocator, sizeof(axiom_xpath_result_t));
+        res->nodes = NULL;
+        res->flag = AXIOM_XPATH_ERROR_STREAMING_NOT_SUPPORTED;
+
+        return res;
+    }
+}
+
+void AXIS2_CALL axiom_xpath_register_default_functions_set(
+    axiom_xpath_context_t *context)
+{
+    axiom_xpath_register_function(
+        context, "count", axiom_xpath_function_count);
+}
+
+
+void AXIS2_CALL axiom_xpath_register_function(
+    axiom_xpath_context_t *context,
+    axis2_char_t *name,
+    axiom_xpath_function_t func)
+{
+    if (name && func)
+    {
+        if (!context->functions)
+        {
+            context->functions = axutil_hash_make(context->env);
+        }
+
+        axutil_hash_set(context->functions, name, AXIS2_HASH_KEY_STRING, func);
+    }
+}
+
+axiom_xpath_function_t AXIS2_CALL axiom_xpath_get_function(
+    axiom_xpath_context_t *context,
+    axis2_char_t *name)
+{
+    axiom_xpath_function_t func = NULL;
+
+    if(context->functions)
+    {
+        func = axutil_hash_get(context->functions, name, AXIS2_HASH_KEY_STRING);
+    }
+
+    return func;
+}
+
+void AXIS2_CALL axiom_xpath_register_namespace(
+    axiom_xpath_context_t *context,
+    axiom_namespace_t *ns)
+{
+    axis2_char_t *prefix = NULL;
+
+    if (!context->namespaces)
+    {
+        context->namespaces = axutil_hash_make(context->env);
+    }
+
+    prefix = axiom_namespace_get_prefix(ns, context->env);
+
+    if (prefix)
+    {
+        axutil_hash_set(
+            context->namespaces, prefix, AXIS2_HASH_KEY_STRING, ns);
+    }
+}
+
+axiom_namespace_t * AXIS2_CALL axiom_xpath_get_namespace(
+    axiom_xpath_context_t *context,
+    axis2_char_t *prefix)
+{
+    axiom_namespace_t *ns = NULL;
+
+    if(context->namespaces)
+    {
+        ns = axutil_hash_get(context->namespaces, prefix, AXIS2_HASH_KEY_STRING);
+    }
+
+    return ns;
+}
+
+void AXIS2_CALL axiom_xpath_clear_namespaces(axiom_xpath_context_t *context)
+{
+    axutil_hash_index_t *hi;
+    void *val;
+
+    if (context->namespaces)
+    {
+        for (hi = axutil_hash_first(context->namespaces, context->env);
+                hi;
+                hi = axutil_hash_next(context->env, hi))
+        {
+            axutil_hash_this(hi, NULL, NULL, &val);
+            axiom_namespace_free((axiom_namespace_t *)val, context->env);
+        }
+
+        axutil_hash_free(context->namespaces, context->env);
+    }
+
+    context->namespaces = NULL;
+}
+
+/* Cast to boolean */
+axis2_bool_t AXIS2_CALL axiom_xpath_cast_node_to_boolean(
+    const axutil_env_t *env,
+    axiom_xpath_result_node_t * node)
+{
+    if (node->type == AXIOM_XPATH_TYPE_BOOLEAN)
+    {
+        return *(axis2_bool_t *)node->value;
+    }
+    else if (node->type == AXIOM_XPATH_TYPE_NUMBER)
+    {
+        /* Cannot evaluate as *(double *)(node->value) == 1e-12
+           since there might be an precision error */
+        if (*(double *)(node->value) > 1e-12
+                || *(double *)(node->value) < -1e-12)
+        {
+            return AXIS2_TRUE;
+        }
+        else
+        {
+            return AXIS2_FALSE;
+        }
+    }
+    else if (node->value)
+    {
+        return AXIS2_TRUE;
+    }
+    else
+    {
+        return AXIS2_FALSE;
+    }
+}
+
+/* Cast to double */
+double AXIS2_CALL axiom_xpath_cast_node_to_number(
+    const axutil_env_t *env,
+    axiom_xpath_result_node_t * node)
+{
+    if (node->type == AXIOM_XPATH_TYPE_BOOLEAN)
+    {
+        if (*(axis2_bool_t *)(node->value) == AXIS2_TRUE)
+        {
+            return 1.0;
+        }
+        else
+        {
+            return 1.0;
+        }
+    }
+    else if (node->type == AXIOM_XPATH_TYPE_NUMBER)
+    {
+        return *(double *)node->value;
+    }
+    else if (node->value)
+    {
+        return 1.0;
+    }
+    else
+    {
+        return 1.0;
+    }
+}
+
+/* Cast to text */
+axis2_char_t * AXIS2_CALL axiom_xpath_cast_node_to_string(
+    const axutil_env_t *env,
+    axiom_xpath_result_node_t * node)
+{
+    axiom_element_t *ele;
+    axis2_char_t *res;
+
+    if (!node->value)
+    {
+        return NULL;
+    }
+
+    if (node->type == AXIOM_XPATH_TYPE_BOOLEAN)
+    {
+        if (*(axis2_bool_t *)(node->value) == AXIS2_TRUE)
+        {
+            return axutil_strdup(env, "true");
+        }
+        else
+        {
+            return axutil_strdup(env, "false");
+        }
+    }
+    else if (node->type == AXIOM_XPATH_TYPE_NUMBER)
+    {
+        /* Allocate 20 bytes */
+        res = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 20);
+
+        sprintf(res, "%lf", *(double *)(node->value));
+
+        return res;
+    }
+    else if (node->type == AXIOM_XPATH_TYPE_TEXT)
+    {
+        return (axis2_char_t *)node->value;
+    }
+    else if (node->type == AXIOM_XPATH_TYPE_NODE)
+    {
+        ele = (axiom_element_t *)axiom_node_get_data_element(
+                    (axiom_node_t *)(node->value), env);
+
+        if (ele)
+        {
+            return axiom_element_get_text(
+                        ele, env, (axiom_node_t *)(node->value));
+        }
+        else
+        {
+            return NULL;
+        }
+    }
+    else if (node->type == AXIOM_XPATH_TYPE_ATTRIBUTE)
+    {
+        return axiom_attribute_get_value(
+                    (axiom_attribute_t *)(node->value), env);
+    }
+    else if (node->type == AXIOM_XPATH_TYPE_NAMESPACE)
+    {
+        return axiom_namespace_get_prefix(
+                    (axiom_namespace_t *)(node->value), env);
+    }
+
+    return NULL;
+}
+
+/* Cast to axiom node */
+axiom_node_t * AXIS2_CALL axiom_xpath_cast_node2axiom_node(
+    const axutil_env_t *env,
+    axiom_xpath_result_node_t * node)
+{
+    if (node->type == AXIOM_XPATH_TYPE_NODE && node->value)
+    {
+        return (axiom_node_t *)node->value;
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+/* Free context */
+void AXIS2_CALL axiom_xpath_free_context(
+    const axutil_env_t *env,
+    axiom_xpath_context_t *context)
+{
+    if (context)
+    {
+        /* Free the expression if not freed */
+        if (context->expr)
+        {
+            /* axiom_xpath_free_expression(env, context->expr); */
+
+            context->expr = NULL;
+        }
+
+        AXIS2_FREE(env->allocator, context);
+    }
+}
+
+/* Free expression */
+void AXIS2_CALL axiom_xpath_free_expression(
+    const axutil_env_t *env,
+    axiom_xpath_expression_t * xpath_expr)
+{
+    if (xpath_expr)
+    {
+        if (xpath_expr->expr_str)
+        {
+            AXIS2_FREE(env->allocator, xpath_expr->expr_str);
+
+            xpath_expr->expr_str = NULL;
+        }
+
+        AXIS2_FREE(env->allocator, xpath_expr);
+    }
+}
+
+/* Free result set */
+void AXIS2_CALL axiom_xpath_free_result(
+    const axutil_env_t *env,
+    axiom_xpath_result_t* result)
+{
+    if (result)
+    {
+        if (result->nodes)
+        {
+            axutil_array_list_free(result->nodes, env);
+        }
+
+        AXIS2_FREE(env->allocator, result);
+    }
+}
+
+/* Check if the expression can be evaluated on streaming XML */
+axis2_bool_t AXIS2_CALL axiom_xpath_streaming_check(
+    const axutil_env_t *env,
+    axiom_xpath_expression_t* expr)
+{
+    axiom_xpath_streaming_t r = AXIOM_XPATH_CHECK(expr->start);
+
+    if (r == AXIOM_XPATH_STREAMING_NOT_SUPPORTED)
+    {
+        return AXIS2_FALSE;
+    }
+    else
+    {
+        return AXIS2_TRUE;
+    }
+}
+

Modified: webservices/axis2/trunk/c/axiom/src/xpath/xpath_functions.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/xpath/xpath_functions.c?rev=719381&r1=719380&r2=719381&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/xpath/xpath_functions.c (original)
+++ webservices/axis2/trunk/c/axiom/src/xpath/xpath_functions.c Thu Nov 20 13:26:08 2008
@@ -1,45 +1,45 @@
-
-/*
- * 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.
- */
-
-#include "xpath_functions.h"
-#include "xpath.h"
-#include "xpath_internals_engine.h"
-
-int axiom_xpath_function_count(axiom_xpath_context_t *context, int np)
-{
-    axiom_xpath_result_node_t *node;
-    double * v;
-    int i;
-
-    node = AXIS2_MALLOC(
-                context->env->allocator, sizeof(axiom_xpath_result_node_t));
-    v = AXIS2_MALLOC(context->env->allocator, sizeof(double));
-
-    *v = np;
-    node->value = v;
-    node->type = AXIOM_XPATH_TYPE_NUMBER;
-
-    for (i = 0; i < np; i++)
-    {
-        axutil_stack_pop(context->stack, context->env);
-    }
-
-    axutil_stack_push(context->stack, context->env, node);
-
-    return 1;
-}
+
+/*
+ * 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.
+ */
+
+#include "xpath_functions.h"
+#include "xpath.h"
+#include "xpath_internals_engine.h"
+
+int axiom_xpath_function_count(axiom_xpath_context_t *context, int np)
+{
+    axiom_xpath_result_node_t *node;
+    double * v;
+    int i;
+
+    node = AXIS2_MALLOC(
+                context->env->allocator, sizeof(axiom_xpath_result_node_t));
+    v = AXIS2_MALLOC(context->env->allocator, sizeof(double));
+
+    *v = np;
+    node->value = v;
+    node->type = AXIOM_XPATH_TYPE_NUMBER;
+
+    for (i = 0; i < np; i++)
+    {
+        axutil_stack_pop(context->stack, context->env);
+    }
+
+    axutil_stack_push(context->stack, context->env, node);
+
+    return 1;
+}

Modified: webservices/axis2/trunk/c/axiom/src/xpath/xpath_functions.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/xpath/xpath_functions.h?rev=719381&r1=719380&r2=719381&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/xpath/xpath_functions.h (original)
+++ webservices/axis2/trunk/c/axiom/src/xpath/xpath_functions.h Thu Nov 20 13:26:08 2008
@@ -1,47 +1,47 @@
-
-/*
- * 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 XPATH_FUNCTIONS_H
-#define XPATH_FUNCTIONS_H
-
-#include "xpath.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /**
-     * @defgroup axiom_xpath_functions functions
-     * @ingroup axiom_xpath
-     * @{
-     */
-
-    /**
-     * count(node-set) function
-     * http://www.w3.org/TR/xpath#function-count
-     */
-    int axiom_xpath_function_count(axiom_xpath_context_t *context, int np);
-
-    /** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+
+/*
+ * 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 XPATH_FUNCTIONS_H
+#define XPATH_FUNCTIONS_H
+
+#include "xpath.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+    /**
+     * @defgroup axiom_xpath_functions functions
+     * @ingroup axiom_xpath
+     * @{
+     */
+
+    /**
+     * count(node-set) function
+     * http://www.w3.org/TR/xpath#function-count
+     */
+    int axiom_xpath_function_count(axiom_xpath_context_t *context, int np);
+
+    /** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Modified: webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals.h?rev=719381&r1=719380&r2=719381&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals.h (original)
+++ webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals.h Thu Nov 20 13:26:08 2008
@@ -1,197 +1,197 @@
-
-/*
- * 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 XPATH_INTERNALS_H
-#define XPATH_INTERNALS_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /**
-     * @defgroup axiom_xpath_internals internals
-     * @ingroup axiom_xpath
-     * @{
-     */
-
-
-    /** Get operation at index ind */
-#define AXIOM_XPATH_OPR_GET(ind) (axiom_xpath_operation_t *) \
- axutil_array_list_get(context->expr->operations, context->env, ind)
-
-    /**
-      * An error has occured while parsing
-      */
-#define AXIOM_XPATH_PARSE_ERROR -2
-
-    /**
-      * XPath expression was successfully compiled
-      */
-#define AXIOM_XPATH_PARSE_SUCCESS 0
-
-    /**
-      * End of expression reached
-      */
-#define AXIOM_XPATH_PARSE_END -1
-
-    /* Types */
-
-    /**
-      * XPath operation
-      * Contains the operands and parameters
-      */
-    typedef struct axiom_xpath_operation axiom_xpath_operation_t;
-
-    /**
-      * XPath node test
-      * Stores the components of a node test
-      */
-    typedef struct axiom_xpath_node_test axiom_xpath_node_test_t;
-
-    /**
-      * Functions to process a XPath operator
-      */
-    typedef int (*axiom_xpath_operator_t)(axiom_xpath_context_t *context,
-            axiom_xpath_operation_t * op);
-
-    /**
-      * Functions to iterate through different XPath axes
-      */
-    typedef int (*axiom_xpath_iterator_t)(axiom_xpath_context_t *context,
-            int op_node_test,
-            int op_next,
-            int op_predicate);
-
-    /**
-      * XPath node test types
-      */
-    typedef enum axiom_xpath_node_test_type_t
-    {
-        AXIOM_XPATH_NODE_TEST_NONE = 0,
-        AXIOM_XPATH_NODE_TEST_ALL,
-        AXIOM_XPATH_NODE_TYPE_COMMENT,
-        AXIOM_XPATH_NODE_TYPE_NODE,
-        AXIOM_XPATH_NODE_TYPE_PI,
-        AXIOM_XPATH_NODE_TYPE_TEXT,
-        AXIOM_XPATH_NODE_TEST_STANDARD
-    } axiom_xpath_node_test_type_t;
-
-    /**
-      * XPath operations
-      */
-    typedef enum axiom_xpath_operation_type_t
-    {
-        AXIOM_XPATH_OPERATION_ROOT_NODE = 0,
-        AXIOM_XPATH_OPERATION_CONTEXT_NODE,
-        AXIOM_XPATH_OPERATION_NODE_TEST,
-        AXIOM_XPATH_OPERATION_STEP,
-        AXIOM_XPATH_OPERATION_RESULT,
-        AXIOM_XPATH_OPERATION_UNION,
-        AXIOM_XPATH_OPERATION_EQUAL_EXPR,
-        AXIOM_XPATH_OPERATION_PREDICATE,
-        AXIOM_XPATH_OPERATION_LITERAL,
-        AXIOM_XPATH_OPERATION_NUMBER,
-        AXIOM_XPATH_OPERATION_PATH_EXPRESSION,
-        AXIOM_XPATH_OPERATION_FUNCTION_CALL,
-        AXIOM_XPATH_OPERATION_ARGUMENT
-    } axiom_xpath_operation_type_t;
-
-    /**
-      * XPath axes
-      */
-    typedef enum axiom_xpath_axis_t
-    {
-        AXIOM_XPATH_AXIS_NONE = -1,
-        AXIOM_XPATH_AXIS_CHILD,
-        AXIOM_XPATH_AXIS_DESCENDANT,
-        AXIOM_XPATH_AXIS_PARENT,
-        AXIOM_XPATH_AXIS_ANCESTOR,
-        AXIOM_XPATH_AXIS_FOLLOWING_SIBLING,
-        AXIOM_XPATH_AXIS_PRECEDING_SIBLING,
-        AXIOM_XPATH_AXIS_FOLLOWING,
-        AXIOM_XPATH_AXIS_PRECEDING,
-        AXIOM_XPATH_AXIS_ATTRIBUTE,
-        AXIOM_XPATH_AXIS_NAMESPACE,
-        AXIOM_XPATH_AXIS_SELF,
-        AXIOM_XPATH_AXIS_DESCENDANT_OR_SELF,
-        AXIOM_XPATH_AXIS_ANCESTOR_OR_SELF
-    } axiom_xpath_axis_t;
-
-    /**
-      * XPath node test structure
-      */
-    struct axiom_xpath_node_test
-    {
-        /** Node test type */
-        axiom_xpath_node_test_type_t type;
-
-        /**  Prefix
-          * NULL if no prefix
-          */
-        axis2_char_t *prefix;
-
-        /** Name */
-        axis2_char_t *name;
-
-        /** Literal for processing instruction (PI)  */
-        axis2_char_t *lit;
-    };
-
-    /**
-      * XPath operation structure
-      */
-    struct axiom_xpath_operation
-    {
-        /** Type of operator */
-        axiom_xpath_operation_type_t opr;
-
-        /** Parameters of the operation */
-        void *par1;
-        void *par2;
-
-        /**  Position: Used for predicate evaluation
-          */
-        int pos;
-
-        /** Operands pointing to other operations */
-        int op1;
-        int op2;
-    };
-
-    /**
-      * Copies an XPath expression to a context
-      *
-      * No data is duplicated just the reference is assigned.
-      * Some parameters in the expression are reset.
-      * - pos in every operation
-      *
-      * @param context XPath context must not be NULL
-      * @param expr Expression to be copied
-      */
-    void axiom_xpath_expression_copy(
-        axiom_xpath_context_t *context,
-        axiom_xpath_expression_t* expr);
-
-    /** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+
+/*
+ * 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 XPATH_INTERNALS_H
+#define XPATH_INTERNALS_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+    /**
+     * @defgroup axiom_xpath_internals internals
+     * @ingroup axiom_xpath
+     * @{
+     */
+
+
+    /** Get operation at index ind */
+#define AXIOM_XPATH_OPR_GET(ind) (axiom_xpath_operation_t *) \
+ axutil_array_list_get(context->expr->operations, context->env, ind)
+
+    /**
+      * An error has occured while parsing
+      */
+#define AXIOM_XPATH_PARSE_ERROR -2
+
+    /**
+      * XPath expression was successfully compiled
+      */
+#define AXIOM_XPATH_PARSE_SUCCESS 0
+
+    /**
+      * End of expression reached
+      */
+#define AXIOM_XPATH_PARSE_END -1
+
+    /* Types */
+
+    /**
+      * XPath operation
+      * Contains the operands and parameters
+      */
+    typedef struct axiom_xpath_operation axiom_xpath_operation_t;
+
+    /**
+      * XPath node test
+      * Stores the components of a node test
+      */
+    typedef struct axiom_xpath_node_test axiom_xpath_node_test_t;
+
+    /**
+      * Functions to process a XPath operator
+      */
+    typedef int (*axiom_xpath_operator_t)(axiom_xpath_context_t *context,
+            axiom_xpath_operation_t * op);
+
+    /**
+      * Functions to iterate through different XPath axes
+      */
+    typedef int (*axiom_xpath_iterator_t)(axiom_xpath_context_t *context,
+            int op_node_test,
+            int op_next,
+            int op_predicate);
+
+    /**
+      * XPath node test types
+      */
+    typedef enum axiom_xpath_node_test_type_t
+    {
+        AXIOM_XPATH_NODE_TEST_NONE = 0,
+        AXIOM_XPATH_NODE_TEST_ALL,
+        AXIOM_XPATH_NODE_TYPE_COMMENT,
+        AXIOM_XPATH_NODE_TYPE_NODE,
+        AXIOM_XPATH_NODE_TYPE_PI,
+        AXIOM_XPATH_NODE_TYPE_TEXT,
+        AXIOM_XPATH_NODE_TEST_STANDARD
+    } axiom_xpath_node_test_type_t;
+
+    /**
+      * XPath operations
+      */
+    typedef enum axiom_xpath_operation_type_t
+    {
+        AXIOM_XPATH_OPERATION_ROOT_NODE = 0,
+        AXIOM_XPATH_OPERATION_CONTEXT_NODE,
+        AXIOM_XPATH_OPERATION_NODE_TEST,
+        AXIOM_XPATH_OPERATION_STEP,
+        AXIOM_XPATH_OPERATION_RESULT,
+        AXIOM_XPATH_OPERATION_UNION,
+        AXIOM_XPATH_OPERATION_EQUAL_EXPR,
+        AXIOM_XPATH_OPERATION_PREDICATE,
+        AXIOM_XPATH_OPERATION_LITERAL,
+        AXIOM_XPATH_OPERATION_NUMBER,
+        AXIOM_XPATH_OPERATION_PATH_EXPRESSION,
+        AXIOM_XPATH_OPERATION_FUNCTION_CALL,
+        AXIOM_XPATH_OPERATION_ARGUMENT
+    } axiom_xpath_operation_type_t;
+
+    /**
+      * XPath axes
+      */
+    typedef enum axiom_xpath_axis_t
+    {
+        AXIOM_XPATH_AXIS_NONE = -1,
+        AXIOM_XPATH_AXIS_CHILD,
+        AXIOM_XPATH_AXIS_DESCENDANT,
+        AXIOM_XPATH_AXIS_PARENT,
+        AXIOM_XPATH_AXIS_ANCESTOR,
+        AXIOM_XPATH_AXIS_FOLLOWING_SIBLING,
+        AXIOM_XPATH_AXIS_PRECEDING_SIBLING,
+        AXIOM_XPATH_AXIS_FOLLOWING,
+        AXIOM_XPATH_AXIS_PRECEDING,
+        AXIOM_XPATH_AXIS_ATTRIBUTE,
+        AXIOM_XPATH_AXIS_NAMESPACE,
+        AXIOM_XPATH_AXIS_SELF,
+        AXIOM_XPATH_AXIS_DESCENDANT_OR_SELF,
+        AXIOM_XPATH_AXIS_ANCESTOR_OR_SELF
+    } axiom_xpath_axis_t;
+
+    /**
+      * XPath node test structure
+      */
+    struct axiom_xpath_node_test
+    {
+        /** Node test type */
+        axiom_xpath_node_test_type_t type;
+
+        /**  Prefix
+          * NULL if no prefix
+          */
+        axis2_char_t *prefix;
+
+        /** Name */
+        axis2_char_t *name;
+
+        /** Literal for processing instruction (PI)  */
+        axis2_char_t *lit;
+    };
+
+    /**
+      * XPath operation structure
+      */
+    struct axiom_xpath_operation
+    {
+        /** Type of operator */
+        axiom_xpath_operation_type_t opr;
+
+        /** Parameters of the operation */
+        void *par1;
+        void *par2;
+
+        /**  Position: Used for predicate evaluation
+          */
+        int pos;
+
+        /** Operands pointing to other operations */
+        int op1;
+        int op2;
+    };
+
+    /**
+      * Copies an XPath expression to a context
+      *
+      * No data is duplicated just the reference is assigned.
+      * Some parameters in the expression are reset.
+      * - pos in every operation
+      *
+      * @param context XPath context must not be NULL
+      * @param expr Expression to be copied
+      */
+    void axiom_xpath_expression_copy(
+        axiom_xpath_context_t *context,
+        axiom_xpath_expression_t* expr);
+
+    /** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif