<libroxml  version="3.0.2" />
contact: tristan.lelong@libroxml.net
Functions
roxml_xpath.c File Reference

xpath execution module More...

#include <stdlib.h>
#include <string.h>
#include "roxml_mem.h"
#include "roxml_core.h"
#include "roxml_xpath.h"
#include "roxml_parser.h"

Go to the source code of this file.

Functions

ROXML_STATIC ROXML_INT int roxml_is_number (char *input)
 number tester More...
 
ROXML_STATIC ROXML_INT void roxml_free_xcond (xpath_cond_t *xcond)
 xpath condition free function More...
 
ROXML_INT void roxml_free_xpath (xpath_node_t *xpath, int nb)
 xpath free function More...
 
ROXML_STATIC ROXML_INT int roxml_in_pool (node_t *root, node_t *n, int req_id)
 node pool presence tester function More...
 
ROXML_STATIC ROXML_INT void roxml_del_from_pool (node_t *root, node_t *n, int req_id)
 pool node delete function More...
 
ROXML_STATIC ROXML_INT int roxml_add_to_pool (node_t *root, node_t *n, int req_id)
 add a token top node function More...
 
ROXML_STATIC ROXML_INT void roxml_release_id (node_t *root, node_t **pool, int pool_len, int req_id)
 release id function More...
 
ROXML_STATIC ROXML_INT int roxml_request_id (node_t *root)
 id reservation function More...
 
ROXML_STATIC ROXML_INT void roxml_compute_and (node_t *root, node_t **node_set, int *count, int cur_req_id, int prev_req_id)
 node set and function More...
 
ROXML_STATIC ROXML_INT void roxml_compute_or (node_t *root, node_t **node_set, int *count, int req_id, int glob_id)
 node set or function More...
 
ROXML_STATIC ROXML_INT int roxml_parse_xpath (char *path, xpath_node_t **xpath, int context)
 xpath parsing function More...
 
ROXML_STATIC ROXML_INT int roxml_get_node_internal_position (node_t *n)
 node absolute position get More...
 
ROXML_STATIC ROXML_INT double roxml_double_oper (double a, double b, int op)
 double operation function More...
 
ROXML_STATIC ROXML_INT int roxml_double_cmp (double a, double b, int op)
 double comparison function More...
 
ROXML_STATIC ROXML_INT int roxml_string_cmp (char *sa, char *sb, int op)
 string comparison function More...
 
ROXML_STATIC ROXML_INT int roxml_validate_predicat (xpath_node_t *xn, xpath_cond_t *condition, node_t *candidat)
 predicat validation function More...
 
ROXML_STATIC ROXML_INT void roxml_add_to_set (node_t *root, node_t *candidat, node_t ***ans, int *nb, int *max, int req_id)
 
ROXML_STATIC ROXML_INT int roxml_validate_axe_func (node_t *root, node_t **candidat, xpath_node_t *xn)
 
ROXML_STATIC ROXML_INT int roxml_validate_axe_name (node_t *candidat, xpath_node_t *xn)
 
ROXML_STATIC ROXML_INT int roxml_validate_axes (node_t *root, node_t *candidat, node_t ***ans, int *nb, int *max, xpath_node_t *xn, int req_id)
 axe validation function More...
 
ROXML_STATIC ROXML_INT void roxml_check_node (xpath_node_t *xp, node_t *root, node_t *context, node_t ***ans, int *nb, int *max, int ignore, int req_id)
 real xpath validation function More...
 
ROXML_INT node_t ** roxml_exec_xpath (node_t *root, node_t *n, xpath_node_t *xpath, int index, int *count)
 real xpath execution More...
 
ROXML_API node_t ** roxml_xpath (node_t *n, char *path, int *nb_ans)
 exec path function More...
 
ROXML_STATIC ROXML_INT xpath_node_troxml_set_axes (xpath_node_t *node, char *axes, int *offset)
 axes setter function More...
 
ROXML_INT int _func_xpath_ignore (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_new_node (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_quote (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_dquote (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_open_parenthesys (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_close_parenthesys (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_open_brackets (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_close_brackets (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_condition_or (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_condition_and (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_path_or (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_operators (roxml_parser_item_t *parser, char *chunk, void *data, int operator, int operator_bis)
 
ROXML_INT int _func_xpath_operator_equal (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_operator_sup (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_operator_inf (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_operator_diff (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_number (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_funcs (roxml_parser_item_t *parser, char *chunk, void *data, int func, char *name)
 
ROXML_INT int _func_xpath_position (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_first (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_last (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_nsuri (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_lname (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_operator_add (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_operator_subs (roxml_parser_item_t *parser, char *chunk, void *data)
 
ROXML_INT int _func_xpath_default (roxml_parser_item_t *parser, char *chunk, void *data)
 

Detailed Description

xpath execution module

(C) Copyright 2014 Tristan Lelong trist.nosp@m.an.l.nosp@m.elong.nosp@m.@lib.nosp@m.roxml.nosp@m..net

SPDX-Licence-Identifier: LGPL-2.1+ The author added a static linking exception, see License.txt.

Definition in file roxml_xpath.c.

Function Documentation

◆ roxml_add_to_pool()

roxml_add_to_pool ( node_t root,
node_t n,
int  req_id 
)

add a token top node function

this function add a token to target node. This token is used to garanty unicity in xpath results

Parameters
rootthe root node
nthe node to mark
req_idthe id to use
Returns
0 if already in the pool, else 1

Definition at line 152 of file roxml_xpath.c.

◆ roxml_check_node()

roxml_check_node ( xpath_node_t xp,
node_t root,
node_t context,
node_t ***  ans,
int *  nb,
int *  max,
int  ignore,
int  req_id 
)

real xpath validation function

this function perform the xpath test on a tree

Parameters
xpthe xpath nodes to test
rootthe root node
contextthe current context node
ansthe pointer to answers pool
nbthe number of answers in pool
maxthe current size of the pool
ignorea flag for some axes that are going thru all document  
req_idthe pool id
Returns

Definition at line 720 of file roxml_xpath.c.

◆ roxml_compute_and()

roxml_compute_and ( node_t root,
node_t **  node_set,
int *  count,
int  cur_req_id,
int  prev_req_id 
)

node set and function

this function computes the AND of two node pools. The resulting pool will have the same ID as cur_req_id.

Parameters
rootthe root of the tree
node_setthe node set containing the 2 pools
countnumber of node in the node set
cur_req_idthe id of the first group
prev_req_idthe id of the second group

Definition at line 242 of file roxml_xpath.c.

◆ roxml_compute_or()

roxml_compute_or ( node_t root,
node_t **  node_set,
int *  count,
int  req_id,
int  glob_id 
)

node set or function

this function computes the OR of two node pools. The resulting pool will have the same ID as glob_id.

Parameters
rootthe root of the tree
node_setthe node set containing the 2 pools
countnumber of node in the node set
req_idthe id of the first group
glob_idthe id of the second group
Returns

Definition at line 280 of file roxml_xpath.c.

◆ roxml_del_from_pool()

roxml_del_from_pool ( node_t root,
node_t n,
int  req_id 
)

pool node delete function

this function remove one node from a pool

Parameters
rootthe root of the tree
nthe node to remove
req_idthe pool id
Returns

Definition at line 118 of file roxml_xpath.c.

◆ roxml_double_cmp()

roxml_double_cmp ( double  a,
double  b,
int  op 
)

double comparison function

this function compare two doubles using one defined operator

Parameters
afirst operand
bsecond operand
opthe operator to use
Returns
1 if comparison is ok, esle 0

Definition at line 431 of file roxml_xpath.c.

◆ roxml_double_oper()

roxml_double_oper ( double  a,
double  b,
int  op 
)

double operation function

this function compare two doubles using one defined operator

Parameters
afirst operand
bsecond operand
opthe operator to use
Returns
1 if comparison is ok, esle 0

Definition at line 409 of file roxml_xpath.c.

◆ roxml_exec_xpath()

roxml_exec_xpath ( node_t root,
node_t n,
xpath_node_t xpath,
int  index,
int *  count 
)

real xpath execution

this function exec a decoded xpath strcuture

Parameters
rootthe root of the tree
nthe context node
xpaththe xpath structure
indexthe number of xpath condition in string
countthe pointer to a variable that is filled with the resulting node number
Returns
the resulting node set that have to be freed with roxml_release

Definition at line 898 of file roxml_xpath.c.

◆ roxml_free_xcond()

roxml_free_xcond ( xpath_cond_t xcond)

xpath condition free function

this function frees an xpath_cond_t cell

Parameters
xcondthe xcond to free
Returns

Definition at line 55 of file roxml_xpath.c.

◆ roxml_free_xpath()

roxml_free_xpath ( xpath_node_t xpath,
int  nb 
)

xpath free function

this function frees the parsed xpath structure

Parameters
xpaththe xpath to free
nbthe number of xpath structures in the table
Returns

Definition at line 64 of file roxml_xpath.c.

◆ roxml_get_node_internal_position()

roxml_get_node_internal_position ( node_t n)

node absolute position get

this function returns the absolute position of the node between siblings

Parameters
nthe node
Returns
the absolute position starting at 1

Definition at line 379 of file roxml_xpath.c.

◆ roxml_in_pool()

roxml_in_pool ( node_t root,
node_t n,
int  req_id 
)

node pool presence tester function

this function test is a node is in a pool

Parameters
rootthe root of the tree
nthe node to test
req_idthe pool id
Returns

Definition at line 86 of file roxml_xpath.c.

◆ roxml_is_number()

int roxml_is_number ( char *  input)

number tester

This function tells if a string is a number

Parameters
inputstring to test
Returns
1 if the string was a number else 0

Definition at line 25 of file roxml_xpath.c.

◆ roxml_parse_xpath()

roxml_parse_xpath ( char *  path,
xpath_node_t **  xpath,
int  context 
)

xpath parsing function

this function convert an xpath string to a table of list of xpath_node_t

Parameters
paththe xpath string
xpaththe parsed xpath
context0 for a real xpath, 1 for a xpath in predicat
Returns
the number of xpath list in the table

Definition at line 300 of file roxml_xpath.c.

◆ roxml_release_id()

roxml_release_id ( node_t root,
node_t **  pool,
int  pool_len,
int  req_id 
)

release id function

this function release a previously required id and remove all id token from the pool

Parameters
rootthe root of the tree that was used for id request
poolthe result from xpath search using this id
pool_lenthe number of node in pool
req_idthe id to release
Returns

Definition at line 194 of file roxml_xpath.c.

◆ roxml_request_id()

roxml_request_id ( node_t root)

id reservation function

this function request an available id for a new xpath search on the tree

Parameters
rootthe root of the tree where id table is stored
Returns
the id between 1 - 255 or -1 if failed

Definition at line 214 of file roxml_xpath.c.

◆ roxml_set_axes()

roxml_set_axes ( xpath_node_t node,
char *  axes,
int *  offset 
)

axes setter function

this function set the axe to a xpath node from xpath string

Parameters
nodethe xpath node to fill
axesthe string where axe is extracted from
offsetthe detected offset in axe string
Returns
the filled xpath_node

Definition at line 1015 of file roxml_xpath.c.

◆ roxml_string_cmp()

roxml_string_cmp ( char *  sa,
char *  sb,
int  op 
)

string comparison function

this function compare two strings using one defined operator

Parameters
safirst operand
sbsecond operand
opthe operator to use
Returns
1 if comparison is ok, else 0

Definition at line 457 of file roxml_xpath.c.

◆ roxml_validate_axes()

roxml_validate_axes ( node_t root,
node_t candidat,
node_t ***  ans,
int *  nb,
int *  max,
xpath_node_t xn,
int  req_id 
)

axe validation function

this function validate if an axe is matching the current node

Parameters
rootthe root node
candidatthe node to test
ansthe pointer to answers pool
nbthe number of answers in pool
maxthe current size of the pool
xnthe xpath node to test
req_idthe pool id
Returns
1 if axe is validated, else 0

Definition at line 671 of file roxml_xpath.c.

◆ roxml_validate_predicat()

roxml_validate_predicat ( xpath_node_t xn,
xpath_cond_t condition,
node_t candidat 
)

predicat validation function

this function check for predicat validity. predicat is part between brackets

Parameters
xnthe xpath node containing the predicat to test
conditionthe xpath condition to test
candidatthe node to test
Returns
1 if predicat is validated, else 0

Definition at line 492 of file roxml_xpath.c.

◆ roxml_xpath()

ROXML_API node_t** roxml_xpath ( node_t n,
char *  path,
int *  nb_ans 
)

exec path function

This function return a node set (table of nodes) corresponding to a given xpath. resulting node set should be roxml_release when not used anymore (but not individual nodes)

Parameters
nis one node of the tree
paththe xpath to use
nb_ansthe number of results
Returns
the node table or NULL

handled xpath are described in xpath handling

Definition at line 969 of file roxml_xpath.c.