int _func_xpath_close_brackets(char * chunk, void * data)
{
	int cur = 0;
	roxml_xpath_ctx_t *ctx = (roxml_xpath_ctx_t*)data;
#ifdef DEBUG_PARSING
	fprintf(stderr, "calling func %s chunk %c\n",__func__,chunk[0]);
#endif /* DEBUG_PARSING */
	if(!ctx->quoted && !ctx->dquoted) {
		ctx->bracket = (ctx->bracket+1)%2;
		chunk[0] = '\0';

		if(ctx->new_cond) {
			if(ctx->new_cond->func == ROXML_FUNC_XPATH) {
				xpath_node_t *xp;
				ctx->new_cond->func2 = roxml_parse_xpath(ctx->new_cond->arg1, &xp, 1);
				ctx->new_cond->xp = xp;
			}
		} else {
			return -1;
		}
	}
	cur++;
	ctx->shorten_cond = 0;
	return 1;
}
示例#2
0
文件: roxml.c 项目: cpoyet/DdraftDolo
node_t ** ROXML_API roxml_xpath(node_t *n, char * path, int *nb_ans)
{
	int index = 0;
	int count = 0;
	xpath_node_t * xpath = NULL;
	node_t ** node_set = NULL;
	node_t * root = n;
	char * full_path_to_find;
	char * path_to_find;

	if(n == NULL)	{ 
		if(nb_ans) { *nb_ans = 0; }
		return NULL; 
	}

	root = roxml_get_root(n);

	full_path_to_find = strdup(path);
	path_to_find = full_path_to_find;

	index = roxml_parse_xpath(path_to_find, &xpath, 0);

	if(index >= 0) {
		node_set = roxml_exec_xpath(root, n, xpath, index, &count);

		roxml_free_xpath(xpath, index);
		free(full_path_to_find);

		if(count == 0)	{
			roxml_release(node_set);
			node_set = NULL;
		}
	}
	if(nb_ans)	{
		*nb_ans = count;
	}

	return node_set;
}