-/* $Id: d1_absyn.c,v 1.19 2005-01-15 19:38:18 adam Exp $
- Copyright (C) 1995-2005
+/* $Id: d1_absyn.c,v 1.25 2006-05-19 13:49:33 adam Exp $
+ Copyright (C) 1995-2006
- if (*p == '/') { abs=0; p++; }
-
- while (*p) {
- i=0;
- while (*p && !strchr("/",*p)) {
- i++; p++;
- }
- stack[e] = (char *) nmem_malloc (data1_nmem_get (dh), i+1);
+ if (*p == '/')
+ {
+ abs =0;
+ p++;
+ }
+ while (*p)
+ {
+ int is_predicate = 0;
+ char *s;
+ int i, j;
+ for (i = 0; *p && !strchr("/",*p); i++, p++)
+ ;
+ res_size += (i+3); /* we'll add / between later .. */
+ stack[e] = (char *) nmem_malloc(data1_nmem_get(dh), i+1);
+ if (*p)
+ p++;
+ }
+ res_p = res = nmem_malloc(data1_nmem_get(dh), res_size + 10);
+
+ if (stack[e-1][0] == '@') /* path/@attr spec (leaf is attribute) */
+ strcpy(res_p, "/");
+ else
+ strcpy(res_p, "[^@]*/"); /* path .. (index all cdata below it) */
+ res_p = res_p + strlen(res_p);
+ while (--e >= 0) {
+ sprintf(res_p, "%s/", stack[e]);
+ res_p += strlen(stack[e]) + 1;
- if (!abs) { sprintf (p, ".*"); p+=2; }
- sprintf (p, "$"); p++;
- r = nmem_strdup (data1_nmem_get (dh), res);
- yaz_log(YLOG_DEBUG,"Got regexp: %s",r);
- return (r);
+ sprintf (res_p, "$");
+ res_p++;
+ yaz_log(YLOG_DEBUG, "Got regexp: %s", res);
+ return res;
-/* *ostrich*
-
- added arg xpelement... when called from xelm context, it's 1, saying
- that ! means xpath, not element name as attribute name...
-
- pop, 2002-12-13
- */
-static int parse_termlists (data1_handle dh, data1_termlist ***tpp,
- char *cp, const char *file, int lineno,
- const char *element_name, data1_absyn *res,
- int xpelement)
+static int parse_termlists(data1_handle dh, data1_termlist ***tpp,
+ char *cp, const char *file, int lineno,
+ const char *element_name, data1_absyn *res,
+ int xpelement,
+ data1_attset *attset)
- }
- if (!((*tp)->att = data1_getattbyname(dh, res->attset,
- attname))) {
- if ((!xpelement) || (*attname != '!')) {
- yaz_log(YLOG_WARN,
- "%s:%d: Couldn't find att '%s' in attset",
- file, lineno, attname);
- return -1;
- } else {
- (*tp)->att = 0;
+ else if (xpelement)
+ strcpy(attname, ZEBRA_XPATH_CDATA);
+ }
+ if (attset)
+ {
+ if (!data1_getattbyname(dh, attset, attname))
+ {
+ yaz_log(YLOG_WARN, "Index '%s' not found in attset(s)",
+ attname);
if (r == 2 && (source = strchr(structure, ':')))
*source++ = '\0'; /* cut off structure .. */
else
if (r == 2 && (source = strchr(structure, ':')))
*source++ = '\0'; /* cut off structure .. */
else
while (f && (argc = read_absyn_line(f, &lineno, line, 512, argv, 50)))
{
char *cmd = *argv;
while (f && (argc = read_absyn_line(f, &lineno, line, 512, argv, 50)))
{
char *cmd = *argv;
- assert (res->attset);
-
- if (parse_termlists (dh, &tp, p, file, lineno, name, res, 0))
+ if (parse_termlists (dh, &tp, p, file, lineno, name, res, 0,
+ attset_list))
if (parse_termlists (dh, &tp, p, file, lineno,
if (parse_termlists (dh, &tp, p, file, lineno,
- if (parse_termlists (dh, &tp, argv[1], file, lineno, 0, res, 0))
+ if (parse_termlists (dh, &tp, argv[1], file, lineno, 0, res, 0,
+ attset_list))
- char *name;
- data1_attset *attset;
-
- if (argc != 2)
- {
- yaz_log(YLOG_WARN, "%s:%d: Bad # of args to attset",
- file, lineno);
- continue;
- }
- name = argv[1];
- if (!(attset = data1_get_attset (dh, name)))
- {
- yaz_log(YLOG_WARN, "%s:%d: Couldn't find attset %s",
- file, lineno, name);
- continue;
- }
- *attset_childp = (data1_attset_child *)
- nmem_malloc (data1_nmem_get(dh), sizeof(**attset_childp));
- (*attset_childp)->child = attset;
- (*attset_childp)->next = 0;
- attset_childp = &(*attset_childp)->next;
+ char *name;
+ data1_attset *attset;
+
+ if (argc != 2)
+ {
+ yaz_log(YLOG_WARN, "%s:%d: Bad # of args to attset",
+ file, lineno);
+ continue;
+ }
+ name = argv[1];
+ if (!(attset = data1_get_attset (dh, name)))
+ {
+ yaz_log(YLOG_WARN, "%s:%d: Couldn't find attset %s",
+ file, lineno, name);
+ continue;
+ }
+ *attset_childp = (data1_attset_child *)
+ nmem_malloc (data1_nmem_get(dh), sizeof(**attset_childp));
+ (*attset_childp)->child = attset;
+ (*attset_childp)->next = 0;
+ attset_childp = &(*attset_childp)->next;