Differences between revisions 3 and 4
Revision 3 as of 2008-04-14 15:28:07
Size: 3061
Editor: 124
Revision 4 as of 2009-09-20 22:48:35
Size: 3061
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

Axiom XPath API

Compile XPath Expression

axiom_xpath_expression_t* axiom_xpath_compile_expression(const axutil_env_t *env, const axis2_char_t* xpath_expr)

Creates a axiom_xpath_expression by parsing xpath_expr. All parse errors will be handled by this function. All parse errors will be logged if necessary.


axiom_xpath_expression_t *exp = axiom_xpath_compile_expression(env, "/father/son");

Create XPath Context

axiom_xpath_context_t* axiom_xpath_context_create(const axutil_env_t *env, const axiom_node_t * root_node)

Creates a XPath context for the root node.

Register Namespaces

void axiom_xpath_register_namespaces(axiom_xpath_context_t *context, const axis2_char_t* prefix, const axis2_char_t* uri)

Adds namespace to list of namespaces.


axiom_xpath_register_namespace(context, "red", "http://www.xvpj.net/red");

Evaluate XPath Query

axiom_xpath_result_t* axiom_xpath_evaluate(axiom_xpath_context_t *context, const axiom_xpath_expression_t * xpath_expr)

Evaluates the xpath expression and return the results.


axiom_xpath_result_t* result = axiom_xpath_select_nodes(env, root, exp);

XPath Result

struct axiom_xpath_result
 int size; // Number of nodes in the result set
 int flag; // For error messages, etc
 axiom_xpath_result_node_t * nodes;

struct axiom_xpath_result_node
 axiom_xpath_result_type type;
 void * value;


axis2_char_t * axiom_xpath_cast_node2string(axiom_xpath_result_node_t * node)

The cast depends on the type of the node This could be a string, number, boolean, or a node. If it is a string, it would be simply returned. If it is a number or a boolean it will be converted to a string. If it is a axiom node, the node and it's content will be returned as a string.

int axiom_xpath_cast_node2boolean(axiom_xpath_result_node_t * node)

If the result is boolean it will be returned. Otherwise true will be returned if the result is not empty.

double axiom_xpath_cast_node2number(axiom_xpath_result_node_t * node)

If the result is a numebr it will be returned. If the result is boolean, 1 will be returned if true, 0 otherwise. 0 will be returned if the result type is string or axiom node.

axiom_node_t * axiom_xpath_cast_node2axiom_node(axiom_xpath_result_node_t * node)

If the result type is node it will be casted and returned; otherwise, NULL will be returned.

Freeing Memory

void axiom_xpath_free_context(axiom_xpath_context_t *context)

Frees the xpath context

void axiom_xpath_free_expression(axiom_xpath_expression_t * xpath_expr)

Frees the xpath expression

void axiom_xpath_free_result(axiom_xpath_result_t* result)

Frees the xpath result set. If result set contains axiom nodes they will not be freed as they are just pointers to the nodes in the XML tree.

axiom-xpath-api-gsoc-varuna (last edited 2009-09-20 22:48:35 by localhost)