1 /* $Id: d1_absyn.c,v 1.23 2006-02-07 00:17:44 adam Exp $
2 Copyright (C) 1995-2005
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
30 #include <idzebra/data1.h>
31 #include <zebra_xpath.h>
34 #define D1_MAX_NESTING 128
36 struct data1_hash_table {
39 struct data1_hash_entry **ar;
42 struct data1_hash_entry {
45 struct data1_hash_entry *next;
48 unsigned data1_hash_calc(struct data1_hash_table *ht, const char *str)
54 if (*str >= 'a' && *str <= 'z')
55 v = v*65509 + *str -'a'+10;
56 else if (*str >= 'A' && *str <= 'Z')
57 v = v*65509 + *str -'A'+10;
58 else if (*str >= '0' && *str <= '9')
59 v = v*65509 + *str -'0';
65 struct data1_hash_table *data1_hash_open(int size, NMEM nmem)
68 struct data1_hash_table *ht = nmem_malloc(nmem, sizeof(*ht));
73 ht->ar = nmem_malloc(nmem, sizeof(*ht->ar) * ht->size);
74 for (i = 0; i<ht->size; i++)
79 void data1_hash_insert(struct data1_hash_table *ht, const char *str,
80 void *clientData, int copy)
82 char *dstr = copy ? nmem_strdup(ht->nmem, str) : (char*) str;
83 if (strchr(str, '?') || strchr(str, '.'))
86 for (i = 0; i<ht->size; i++)
88 struct data1_hash_entry **he = &ht->ar[i];
89 for (; *he && strcmp(str, (*he)->str); he = &(*he)->next)
93 *he = nmem_malloc(ht->nmem, sizeof(**he));
97 (*he)->clientData = clientData;
102 struct data1_hash_entry **he = &ht->ar[data1_hash_calc(ht, str)];
103 for (; *he && strcmp(str, (*he)->str); he = &(*he)->next)
107 *he = nmem_malloc(ht->nmem, sizeof(**he));
111 (*he)->clientData = clientData;
115 void *data1_hash_lookup(struct data1_hash_table *ht, const char *str)
117 struct data1_hash_entry **he = &ht->ar[data1_hash_calc(ht, str)];
119 for (; *he && yaz_matchstr(str, (*he)->str); he = &(*he)->next)
122 return (*he)->clientData;
126 struct data1_systag {
129 struct data1_systag *next;
132 struct data1_absyn_cache_info
136 data1_absyn_cache next;
139 struct data1_attset_cache_info
142 data1_attset *attset;
143 data1_attset_cache next;
146 data1_element *data1_mk_element(data1_handle dh)
148 data1_element *e = nmem_malloc(data1_nmem_get(dh), sizeof(*e));
152 e->next = e->children = 0;
158 data1_absyn *data1_absyn_search (data1_handle dh, const char *name)
160 data1_absyn_cache p = *data1_absyn_cache_get (dh);
164 if (!yaz_matchstr (name, p->name))
171 We need to destroy DFAs, in xp_element (xelm) definitions
175 void data1_absyn_destroy (data1_handle dh)
177 data1_absyn_cache p = *data1_absyn_cache_get (dh);
181 data1_absyn *abs = p->absyn;
184 data1_xpelement *xpe = abs->xp_elements;
186 yaz_log (YLOG_DEBUG,"Destroy xp element %s",xpe->xpath_expr);
187 if (xpe->dfa) { dfa_delete (&xpe->dfa); }
196 void data1_absyn_trav (data1_handle dh, void *handle,
197 void (*fh)(data1_handle dh, void *h, data1_absyn *a))
199 data1_absyn_cache p = *data1_absyn_cache_get (dh);
203 (*fh)(dh, handle, p->absyn);
208 data1_absyn *data1_absyn_add (data1_handle dh, const char *name)
211 NMEM mem = data1_nmem_get (dh);
213 data1_absyn_cache p = (data1_absyn_cache)nmem_malloc (mem, sizeof(*p));
214 data1_absyn_cache *pp = data1_absyn_cache_get (dh);
216 sprintf(fname, "%s.abs", name);
217 p->absyn = data1_read_absyn (dh, fname, 0);
218 p->name = nmem_strdup (mem, name);
224 data1_absyn *data1_get_absyn (data1_handle dh, const char *name)
228 if (!(absyn = data1_absyn_search (dh, name)))
229 absyn = data1_absyn_add (dh, name);
233 data1_attset *data1_attset_search_name (data1_handle dh, const char *name)
235 data1_attset_cache p = *data1_attset_cache_get (dh);
239 if (!yaz_matchstr (name, p->name))
246 data1_attset *data1_attset_search_id (data1_handle dh, int id)
248 data1_attset_cache p = *data1_attset_cache_get (dh);
252 if (id == p->attset->reference)
259 data1_attset *data1_attset_add (data1_handle dh, const char *name)
261 char fname[512], aname[512];
262 NMEM mem = data1_nmem_get (dh);
263 data1_attset *attset;
265 strcpy (aname, name);
266 sprintf(fname, "%s.att", name);
267 attset = data1_read_attset (dh, fname);
271 attset = data1_read_attset (dh, name);
272 if (attset && (cp = strrchr (aname, '.')))
276 yaz_log (YLOG_WARN|YLOG_ERRNO, "Couldn't load attribute set %s", name);
279 data1_attset_cache p = (data1_attset_cache)
280 nmem_malloc (mem, sizeof(*p));
281 data1_attset_cache *pp = data1_attset_cache_get (dh);
283 attset->name = p->name = nmem_strdup (mem, aname);
291 data1_attset *data1_get_attset (data1_handle dh, const char *name)
293 data1_attset *attset;
295 if (!(attset = data1_attset_search_name (dh, name)))
296 attset = data1_attset_add (dh, name);
300 data1_esetname *data1_getesetbyname(data1_handle dh, data1_absyn *a,
305 for (r = a->esetnames; r; r = r->next)
306 if (!data1_matchstr(r->name, name))
311 /* we have multiple versions of data1_getelementbyname */
312 #define DATA1_GETELEMENTBYTAGNAME_VERSION 1
314 #if DATA1_GETELEMENTBYTAGNAME_VERSION==0
315 /* straight linear search */
316 data1_element *data1_getelementbytagname (data1_handle dh, data1_absyn *abs,
317 data1_element *parent,
322 /* It's now possible to have a data1 tree with no abstract syntax */
327 r = abs->main_elements;
329 r = parent->children;
331 for (; r; r = r->next)
335 for (n = r->tag->names; n; n = n->next)
336 if (!data1_matchstr(tagname, n->name))
343 #if DATA1_GETELEMENTBYTAGNAME_VERSION==1
344 /* using hash search */
345 data1_element *data1_getelementbytagname (data1_handle dh, data1_absyn *abs,
346 data1_element *parent,
350 struct data1_hash_table *ht;
352 /* It's now possible to have a data1 tree with no abstract syntax */
357 r = abs->main_elements;
359 r = parent->children;
367 ht = r->hash = data1_hash_open(29, data1_nmem_get(dh));
368 for (; r; r = r->next)
372 for (n = r->tag->names; n; n = n->next)
373 data1_hash_insert(ht, n->name, r, 0);
376 return data1_hash_lookup(ht, tagname);
380 data1_element *data1_getelementbyname (data1_handle dh, data1_absyn *absyn,
385 /* It's now possible to have a data1 tree with no abstract syntax */
388 for (r = absyn->main_elements; r; r = r->next)
389 if (!data1_matchstr(r->name, name))
395 void fix_element_ref (data1_handle dh, data1_absyn *absyn, data1_element *e)
397 /* It's now possible to have a data1 tree with no abstract syntax */
401 for (; e; e = e->next)
406 fix_element_ref (dh, absyn, e->children);
410 data1_sub_elements *sub_e = absyn->sub_elements;
411 while (sub_e && strcmp (e->sub_name, sub_e->name))
414 e->children = sub_e->elements;
416 yaz_log (YLOG_WARN, "Unresolved reference to sub-elements %s",
423 New function, a bit dummy now... I've seen it in zrpn.c... We should build
424 more clever regexps...
436 Now [] predicates are supported
442 static const char * mk_xpath_regexp (data1_handle dh, const char *expr)
444 const char *p = expr;
448 char *res_p, *res = 0;
461 int is_predicate = 0;
464 for (i = 0; *p && !strchr("/",*p); i++, p++)
466 res_size += (i+3); /* we'll add / between later .. */
467 stack[e] = (char *) nmem_malloc(data1_nmem_get(dh), i+1);
469 for (j = 0; j < i; j++)
471 const char *pp = p-i+j;
490 res_p = res = nmem_malloc(data1_nmem_get(dh), res_size + 10);
492 if (stack[e-1][0] == '@') /* path/@attr spec (leaf is attribute) */
495 strcpy(res_p, "[^@]*/"); /* path .. (index all cdata below it) */
496 res_p = res_p + strlen(res_p);
498 sprintf(res_p, "%s/", stack[e]);
499 res_p += strlen(stack[e]) + 1;
503 sprintf(res_p, ".*");
506 sprintf (res_p, "$");
508 yaz_log(YLOG_DEBUG, "Got regexp: %s", res);
514 added arg xpelement... when called from xelm context, it's 1, saying
515 that ! means xpath, not element name as attribute name...
519 static int parse_termlists (data1_handle dh, data1_termlist ***tpp,
520 char *cp, const char *file, int lineno,
521 const char *element_name, data1_absyn *res,
524 data1_termlist **tp = *tpp;
527 char attname[512], structure[512];
532 for (i = 0; cp[i] && i<sizeof(attname)-1; i++)
533 if (strchr(":,", cp[i]))
541 "%s:%d: Syntax error in termlistspec '%s'",
551 for (i = 0; cp[i] && i<sizeof(structure)-1; i++)
552 if (level == 0 && strchr(",", cp[i]))
556 structure[i] = cp[i];
559 else if (cp[i] == ')')
569 *tp = (data1_termlist *)
570 nmem_malloc(data1_nmem_get(dh), sizeof(**tp));
574 (*tp)->index_name = nmem_strdup(data1_nmem_get(dh), element_name);
575 if (*attname == '!' && xpelement)
576 (*tp)->index_name = 0;
580 strcpy(attname, element_name);
582 if (!((*tp)->att = data1_getattbyname(dh, res->attset, attname)))
584 if ((!xpelement) || (*attname != '!')) {
586 "%s:%d: Couldn't find att '%s' in attset",
587 file, lineno, attname);
594 if (r == 2 && (source = strchr(structure, ':')))
595 *source++ = '\0'; /* cut off structure .. */
597 source = "data"; /* ok: default is leaf data */
598 (*tp)->source = (char *)
599 nmem_strdup (data1_nmem_get (dh), source);
601 if (r < 2) /* is the structure qualified? */
602 (*tp)->structure = "w";
604 (*tp)->structure = (char *)
605 nmem_strdup (data1_nmem_get (dh), structure);
614 * Converts a 'melm' field[$subfield] pattern to a simple xpath
616 static int melm2xpath(char *melm, char *buf)
622 if ((dollar = strchr(melm, '$'))) {
627 if (field[0] == '0' && field[1] == '0')
628 fieldtype = "controlfield";
630 fieldtype = "datafield";
631 sprintf(buf, "/*/%s[@tag=\"%s\"]", fieldtype, field);
633 sprintf(buf + strlen(buf), "/subfield[@code=\"%s\"]", subfield);
634 else if (field[0] != '0' || field[1] != '0')
635 strcat(buf, "/subfield");
636 yaz_log(YLOG_DEBUG, "Created xpath: '%s'", buf);
640 const char *data1_systag_lookup(data1_absyn *absyn, const char *tag,
641 const char *default_value)
643 struct data1_systag *p = absyn->systags;
644 for (; p; p = p->next)
645 if (!strcmp(p->name, tag))
647 return default_value;
650 #define l_isspace(c) ((c) == '\t' || (c) == ' ' || (c) == '\n' || (c) == '\r')
652 int read_absyn_line(FILE *f, int *lineno, char *line, int len,
653 char *argv[], int num)
659 while ((p = fgets(line, len, f)))
662 while (*p && l_isspace(*p))
670 for (argc = 0; *p ; argc++)
672 if (*p == '#') /* trailing comment */
675 while (*p && !(l_isspace(*p) && !quoted)) {
676 if (*p =='"') quoted = 1 - quoted;
677 if (*p =='[') quoted = 1;
678 if (*p ==']') quoted = 0;
684 while (*p && l_isspace(*p))
691 data1_marctab *data1_absyn_getmarctab(data1_handle dh, data1_absyn *absyn)
696 YAZ_EXPORT data1_element *data1_absyn_getelements(data1_handle dh,
699 return absyn->main_elements;
702 data1_absyn *data1_read_absyn (data1_handle dh, const char *file,
705 data1_sub_elements *cur_elements = NULL;
706 data1_xpelement *cur_xpelement = NULL;
708 data1_absyn *res = 0;
710 data1_element **ppl[D1_MAX_NESTING];
711 data1_esetname **esetpp;
712 data1_maptab **maptabp;
713 data1_marctab **marcp;
714 data1_termlist *all = 0;
715 data1_attset_child **attset_childp;
716 data1_tagset **tagset_childp;
717 struct data1_systag **systagsp;
721 char *argv[50], line[512];
723 if (!(f = data1_path_fopen(dh, file, "r")))
725 yaz_log(YLOG_WARN|YLOG_ERRNO, "Couldn't open %s", file);
730 res = (data1_absyn *) nmem_malloc(data1_nmem_get(dh), sizeof(*res));
732 res->reference = VAL_NONE;
735 res->enable_xpath_indexing = (f ? 0 : 1);
737 systagsp = &res->systags;
738 tagset_childp = &res->tagset;
740 res->attset = data1_empty_attset (dh);
741 attset_childp = &res->attset->children;
745 esetpp = &res->esetnames;
747 maptabp = &res->maptabs;
750 res->sub_elements = NULL;
751 res->main_elements = NULL;
752 res->xp_elements = NULL;
754 while (f && (argc = read_absyn_line(f, &lineno, line, 512, argv, 50)))
757 if (!strcmp(cmd, "elm") || !strcmp(cmd, "element"))
759 data1_element *new_element;
761 char *p, *sub_p, *path, *name, *termlists;
767 yaz_log(YLOG_WARN, "%s:%d: Bad # of args to elm", file, lineno);
776 cur_elements = (data1_sub_elements *)
777 nmem_malloc(data1_nmem_get(dh), sizeof(*cur_elements));
778 cur_elements->next = res->sub_elements;
779 cur_elements->elements = NULL;
780 cur_elements->name = "main";
781 res->sub_elements = cur_elements;
784 ppl[level] = &cur_elements->elements;
791 if ((e = strchr(p, '/')))
798 yaz_log(YLOG_WARN, "%s:%d: Bad level increase", file, lineno);
803 new_element = *ppl[level-1] = data1_mk_element(dh);
805 tp = &new_element->termlists;
806 ppl[level-1] = &new_element->next;
807 ppl[level] = &new_element->children;
809 /* consider subtree (if any) ... */
810 if ((sub_p = strchr (p, ':')) && sub_p[1])
813 new_element->sub_name =
814 nmem_strdup (data1_nmem_get(dh), sub_p);
816 /* well-defined tag */
817 if (sscanf(p, "(%d,%d)", &type, &value) == 2)
821 yaz_log(YLOG_WARN, "%s:%d: No tagset loaded", file, lineno);
825 if (!(new_element->tag = data1_gettagbynum (dh, res->tagset,
828 yaz_log(YLOG_WARN, "%s:%d: Couldn't find tag %s in tagset",
838 new_element->tag = (data1_tag *)
839 nmem_malloc(data1_nmem_get (dh),
840 sizeof(*new_element->tag));
841 nt->which = DATA1T_string;
842 nt->value.string = nmem_strdup(data1_nmem_get (dh), p);
843 nt->names = (data1_name *)
844 nmem_malloc(data1_nmem_get(dh),
845 sizeof(*new_element->tag->names));
846 nt->names->name = nt->value.string;
848 nt->kind = DATA1K_string;
854 yaz_log(YLOG_WARN, "%s:%d: Bad element", file, lineno);
858 /* parse termList definitions */
862 assert (res->attset);
864 if (parse_termlists (dh, &tp, p, file, lineno, name, res, 0))
869 *tp = all; /* append any ALL entries to the list */
871 new_element->name = nmem_strdup(data1_nmem_get (dh), name);
874 New code to support xelm directive
875 for each xelm a dfa is built. xelms are stored in res->xp_elements
877 maybe we should use a simple sscanf instead of dfa?
881 Now [] predicates are supported. regexps and xpath structure is
882 a bit redundant, however it's comfortable later...
887 else if (!strcmp(cmd, "xelm") || !strcmp(cmd, "melm")) {
890 char *p, *xpath_expr, *termlists;
892 struct DFA *dfa = dfa = dfa_init();
894 char melm_xpath[128];
898 yaz_log(YLOG_WARN, "%s:%d: Bad # of args to xelm", file, lineno);
902 if (!strcmp(cmd, "melm")) {
903 if (melm2xpath(argv[1], melm_xpath) < 0)
905 xpath_expr = melm_xpath;
907 xpath_expr = argv[1];
910 regexp = mk_xpath_regexp(dh, xpath_expr);
911 i = dfa_parse (dfa, ®exp);
913 yaz_log(YLOG_WARN, "%s:%d: Bad xpath to xelm", file, lineno);
920 cur_xpelement = (data1_xpelement *)
921 nmem_malloc(data1_nmem_get(dh), sizeof(*cur_xpelement));
922 res->xp_elements = cur_xpelement;
924 cur_xpelement->next = (data1_xpelement *)
925 nmem_malloc(data1_nmem_get(dh), sizeof(*cur_xpelement));
926 cur_xpelement = cur_xpelement->next;
928 cur_xpelement->next = NULL;
929 cur_xpelement->xpath_expr = nmem_strdup(data1_nmem_get (dh),
933 cur_xpelement->dfa = dfa;
936 cur_xpelement->xpath_len =
937 zebra_parse_xpath_str(xpath_expr,
938 cur_xpelement->xpath, XPATH_STEP_COUNT,
942 dump_xp_steps(cur_xpelement->xpath,cur_xpelement->xpath_len);
945 cur_xpelement->termlists = 0;
946 tp = &cur_xpelement->termlists;
948 /* parse termList definitions */
952 assert (res->attset);
954 if (parse_termlists (dh, &tp, p, file, lineno,
960 *tp = all; /* append any ALL entries to the list */
963 else if (!strcmp(cmd, "section"))
969 yaz_log(YLOG_WARN, "%s:%d: Bad # of args to section",
975 cur_elements = (data1_sub_elements *)
976 nmem_malloc(data1_nmem_get(dh), sizeof(*cur_elements));
977 cur_elements->next = res->sub_elements;
978 cur_elements->elements = NULL;
979 cur_elements->name = nmem_strdup (data1_nmem_get(dh), name);
980 res->sub_elements = cur_elements;
983 ppl[level] = &cur_elements->elements;
985 else if (!strcmp(cmd, "xpath"))
989 yaz_log(YLOG_WARN, "%s:%d: Bad # of args to 'xpath' directive",
993 if (!strcmp(argv[1], "enable"))
994 res->enable_xpath_indexing = 1;
995 else if (!strcmp (argv[1], "disable"))
996 res->enable_xpath_indexing = 0;
999 yaz_log(YLOG_WARN, "%s:%d: Expecting disable/enable "
1000 "after 'xpath' directive", file, lineno);
1003 else if (!strcmp(cmd, "all"))
1005 data1_termlist **tp = &all;
1008 yaz_log(YLOG_WARN, "%s:%d: Too many 'all' directives - ignored",
1014 yaz_log(YLOG_WARN, "%s:%d: Bad # of args to 'all' directive",
1018 if (parse_termlists (dh, &tp, argv[1], file, lineno, 0, res, 0))
1024 else if (!strcmp(cmd, "name"))
1028 yaz_log(YLOG_WARN, "%s:%d: Bad # of args to name directive",
1032 res->name = nmem_strdup(data1_nmem_get(dh), argv[1]);
1034 else if (!strcmp(cmd, "reference"))
1040 yaz_log(YLOG_WARN, "%s:%d: Bad # of args to reference",
1045 if ((res->reference = oid_getvalbyname(name)) == VAL_NONE)
1047 yaz_log(YLOG_WARN, "%s:%d: Unknown tagset ref '%s'",
1048 file, lineno, name);
1052 else if (!strcmp(cmd, "attset"))
1055 yaz_log(YLOG_WARN, "%s:%d: attset obsolete", file, lineno);
1058 data1_attset *attset;
1062 yaz_log(YLOG_WARN, "%s:%d: Bad # of args to attset",
1067 if (!(attset = data1_get_attset (dh, name)))
1069 yaz_log(YLOG_WARN, "%s:%d: Couldn't find attset %s",
1070 file, lineno, name);
1073 *attset_childp = (data1_attset_child *)
1074 nmem_malloc (data1_nmem_get(dh), sizeof(**attset_childp));
1075 (*attset_childp)->child = attset;
1076 (*attset_childp)->next = 0;
1077 attset_childp = &(*attset_childp)->next;
1080 else if (!strcmp(cmd, "tagset"))
1086 yaz_log(YLOG_WARN, "%s:%d: Bad # of args to tagset",
1092 type = atoi(argv[2]);
1093 *tagset_childp = data1_read_tagset (dh, name, type);
1094 if (!(*tagset_childp))
1096 yaz_log(YLOG_WARN, "%s:%d: Couldn't load tagset %s",
1097 file, lineno, name);
1100 tagset_childp = &(*tagset_childp)->next;
1102 else if (!strcmp(cmd, "varset"))
1108 yaz_log(YLOG_WARN, "%s:%d: Bad # of args in varset",
1113 if (!(res->varset = data1_read_varset (dh, name)))
1115 yaz_log(YLOG_WARN, "%s:%d: Couldn't load Varset %s",
1116 file, lineno, name);
1120 else if (!strcmp(cmd, "esetname"))
1126 yaz_log(YLOG_WARN, "%s:%d: Bad # of args in esetname",
1133 *esetpp = (data1_esetname *)
1134 nmem_malloc(data1_nmem_get(dh), sizeof(**esetpp));
1135 (*esetpp)->name = nmem_strdup(data1_nmem_get(dh), name);
1136 (*esetpp)->next = 0;
1138 (*esetpp)->spec = 0;
1139 else if (!((*esetpp)->spec = data1_read_espec1 (dh, fname)))
1141 yaz_log(YLOG_WARN, "%s:%d: Espec-1 read failed for %s",
1142 file, lineno, fname);
1145 esetpp = &(*esetpp)->next;
1147 else if (!strcmp(cmd, "maptab"))
1153 yaz_log(YLOG_WARN, "%s:%d: Bad # of args for maptab",
1158 if (!(*maptabp = data1_read_maptab (dh, name)))
1160 yaz_log(YLOG_WARN, "%s:%d: Couldn't load maptab %s",
1161 file, lineno, name);
1164 maptabp = &(*maptabp)->next;
1166 else if (!strcmp(cmd, "marc"))
1172 yaz_log(YLOG_WARN, "%s:%d: Bad # or args for marc",
1177 if (!(*marcp = data1_read_marctab (dh, name)))
1179 yaz_log(YLOG_WARN, "%s:%d: Couldn't read marctab %s",
1180 file, lineno, name);
1183 marcp = &(*marcp)->next;
1185 else if (!strcmp(cmd, "encoding"))
1189 yaz_log(YLOG_WARN, "%s:%d: Bad # or args for encoding",
1193 res->encoding = nmem_strdup (data1_nmem_get(dh), argv[1]);
1195 else if (!strcmp(cmd, "systag"))
1199 yaz_log(YLOG_WARN, "%s:%d: Bad # or args for systag",
1203 *systagsp = nmem_malloc (data1_nmem_get(dh), sizeof(**systagsp));
1205 (*systagsp)->name = nmem_strdup(data1_nmem_get(dh), argv[1]);
1206 (*systagsp)->value = nmem_strdup(data1_nmem_get(dh), argv[2]);
1207 systagsp = &(*systagsp)->next;
1211 yaz_log(YLOG_WARN, "%s:%d: Unknown directive '%s'", file,
1219 for (cur_elements = res->sub_elements; cur_elements;
1220 cur_elements = cur_elements->next)
1222 if (!strcmp (cur_elements->name, "main"))
1223 res->main_elements = cur_elements->elements;
1224 fix_element_ref (dh, res, cur_elements->elements);
1227 yaz_log(YLOG_DEBUG, "%s: data1_read_absyn end", file);