31 static char *
get_xp_part (
char **strs, NMEM mem,
int *literal)
41 if (strchr(
"()", *cp))
43 else if (strchr(
"><=", *cp))
45 while (strchr(
"><=", *cp))
48 else if (*cp ==
'"' || *cp ==
'\'')
53 while (*cp && *cp != sep)
55 res = nmem_malloc(mem, cp - str + 1);
57 memcpy (res, str, (cp-str));
65 while (*cp && !strchr(
"><=()]\" ", *cp))
70 res = nmem_malloc(mem, cp - str + 1);
72 memcpy (res, str, (cp-str));
80 char **look,
int *literal);
83 char **look,
int *literal)
86 if (!*literal && !strcmp(*look,
"("))
90 if (!strcmp(*look,
")"))
102 if (*look && !*literal && strchr(
"><=", **look))
122 char **look,
int *literal)
130 while (*look && !*literal &&
131 (!strcmp(*look,
"and") || !strcmp(*look,
"or") ||
132 !strcmp(*look,
"not")))
154 char **pr = &predicate;
170 if (!xpath_string || *xpath_string !=
'/')
174 while (*cp && no < max)
177 while (*cp && !strchr(
"/[",*cp))
183 xpath[no].
part = nmem_malloc (mem, i+1);
185 memcpy (xpath[no].part, cp - i, i);
186 xpath[no].
part[i] = 0;
196 while(*cp && *cp !=
']') {
221 fprintf (stderr,
"%s,%s,%s",
226 fprintf (stderr,
"(");
228 fprintf (stderr,
") %s (", p->
u.
boolean.op);
230 fprintf (stderr,
")");
238 for (i=0; i<no; i++) {
239 fprintf (stderr,
"Step %d: %s ",i,xpath[i].part);
241 fprintf (stderr,
"\n");
struct xpath_predicate * predicate
struct xpath_predicate * right
union xpath_predicate::@8 u
struct xpath_predicate::@8::@9 relation
struct xpath_predicate::@8::@10 boolean
struct xpath_predicate * left
static struct xpath_predicate * get_xpath_predicate(char *predicate, NMEM mem)
void dump_xp_predicate(struct xpath_predicate *p)
void dump_xp_steps(struct xpath_location_step *xpath, int no)
static char * get_xp_part(char **strs, NMEM mem, int *literal)
int zebra_parse_xpath_str(const char *xpath_string, struct xpath_location_step *xpath, int max, NMEM mem)
static struct xpath_predicate * get_xpath_relation(char **pr, NMEM mem, char **look, int *literal)
static struct xpath_predicate * get_xpath_boolean(char **pr, NMEM mem, char **look, int *literal)
#define XPATH_PREDICATE_BOOLEAN
#define XPATH_PREDICATE_RELATION