From 9eebf93dc2525854867cbc43920ea8ba4a199ab5 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 23 Jun 2005 06:45:46 +0000 Subject: [PATCH] Register type (w,p) + set-use/string attriute combined in register id and stored in dictionary. Experimental (NATTR=1) support for plain string attributes everywhere. That doesn't pass tests yet, since there is no mapping in search phase. --- data1/d1_absyn.c | 17 +++-- include/idzebra/data1.h | 6 +- include/idzebra/recctrl.h | 16 ++++- include/idzebra/util.h | 6 +- index/extract.c | 153 +++++++++++++++++++++++++++++++++-------- index/index.h | 17 +++-- index/zebraapi.c | 9 ++- index/zinfo.c | 47 ++++++++++--- index/zinfo.h | 14 ++-- index/zrpn.c | 67 +++++++++--------- recctrl/alvis.c | 3 +- recctrl/recgrs.c | 167 +++++++++++++++++++++++++++++++++++++-------- recctrl/rectext.c | 5 +- recctrl/safari.c | 6 +- recctrl/xslt.c | 15 +++- test/api/t5.c | 4 +- 16 files changed, 422 insertions(+), 130 deletions(-) diff --git a/data1/d1_absyn.c b/data1/d1_absyn.c index e380610..45724a9 100644 --- a/data1/d1_absyn.c +++ b/data1/d1_absyn.c @@ -1,4 +1,4 @@ -/* $Id: d1_absyn.c,v 1.19 2005-01-15 19:38:18 adam Exp $ +/* $Id: d1_absyn.c,v 1.20 2005-06-23 06:45:46 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -561,12 +561,17 @@ static int parse_termlists (data1_handle dh, data1_termlist ***tpp, nmem_malloc(data1_nmem_get(dh), sizeof(**tp)); (*tp)->next = 0; +#if NATTR + (*tp)->index_name = nmem_strdup(data1_nmem_get(dh), element_name); + if (*attname == '!' && xpelement) + (*tp)->index_name = 0; +#else if (!xpelement) { if (*attname == '!') strcpy(attname, element_name); } - if (!((*tp)->att = data1_getattbyname(dh, res->attset, - attname))) { + 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", @@ -576,7 +581,7 @@ static int parse_termlists (data1_handle dh, data1_termlist ***tpp, (*tp)->att = 0; } } - +#endif if (r == 2 && (source = strchr(structure, ':'))) *source++ = '\0'; /* cut off structure .. */ else @@ -1037,6 +1042,9 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file, } else if (!strcmp(cmd, "attset")) { +#if NATTR + yaz_log(YLOG_WARN, "%s:%d: attset obsolete", file, lineno); +#else char *name; data1_attset *attset; @@ -1058,6 +1066,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file, (*attset_childp)->child = attset; (*attset_childp)->next = 0; attset_childp = &(*attset_childp)->next; +#endif } else if (!strcmp(cmd, "tagset")) { diff --git a/include/idzebra/data1.h b/include/idzebra/data1.h index 37744ea..a470854 100644 --- a/include/idzebra/data1.h +++ b/include/idzebra/data1.h @@ -1,4 +1,4 @@ -/* $Id: data1.h,v 1.9 2005-04-23 16:30:58 adam Exp $ +/* $Id: data1.h,v 1.10 2005-06-23 06:45:46 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -245,7 +245,11 @@ struct data1_tagset typedef struct data1_termlist { +#if NATTR + char *index_name; +#else data1_att *att; +#endif char *structure; char *source; struct data1_termlist *next; diff --git a/include/idzebra/recctrl.h b/include/idzebra/recctrl.h index 03e21af..ab1941b 100644 --- a/include/idzebra/recctrl.h +++ b/include/idzebra/recctrl.h @@ -1,4 +1,4 @@ -/* $Id: recctrl.h,v 1.11 2005-06-07 11:36:38 adam Exp $ +/* $Id: recctrl.h,v 1.12 2005-06-23 06:45:46 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -34,12 +34,22 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA YAZ_BEGIN_CDECL +#if NATTR +#define ZEBRA_XPATH_ELM_BEGIN "_XPATH_BEGIN" +#define ZEBRA_XPATH_ELM_END "_XPATH_END" +#define ZEBRA_XPATH_CDATA "_XPATH_CDATA" +#define ZEBRA_XPATH_ATTR "_XPATH_ATTR" +#endif + /* single word entity */ typedef struct { +#if NATTR +#else int attrSet; int attrUse; - unsigned reg_type; - char *attrStr; +#endif + unsigned index_type; + char *index_name; char *term_buf; int term_len; zint seqno; diff --git a/include/idzebra/util.h b/include/idzebra/util.h index eebd2dd..6d2a74d 100644 --- a/include/idzebra/util.h +++ b/include/idzebra/util.h @@ -1,4 +1,4 @@ -/* $Id: util.h,v 1.3 2005-04-29 23:09:57 adam Exp $ +/* $Id: util.h,v 1.4 2005-06-23 06:45:46 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -84,4 +84,8 @@ YAZ_END_CDECL #define CAST_ZINT_TO_INT(x) (int)(x) #define CAST_ZINT_TO_DOUBLE(x) (double)(x) +/* NATTR=1 for string-attribute architecture, =0 for set+use . */ +#define NATTR 0 +#define REG_TYPE_PREFIX 0 + #endif diff --git a/index/extract.c b/index/extract.c index de6aa9e..59822b9 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,4 +1,4 @@ -/* $Id: extract.c,v 1.186 2005-06-14 20:28:54 adam Exp $ +/* $Id: extract.c,v 1.187 2005-06-23 06:45:46 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -86,10 +86,13 @@ static void extract_init (struct recExtractCtrl *p, RecWord *w) { w->zebra_maps = p->zebra_maps; w->seqno = 1; +#if NATTR +#else w->attrSet = VAL_BIB1; w->attrUse = 1016; - w->attrStr = 0; - w->reg_type = 'w'; +#endif + w->index_name = 0; + w->index_type = 'w'; w->extractCtrl = p; w->record_id = 0; w->section_id = 0; @@ -414,9 +417,11 @@ static int file_extract_record(ZebraHandle zh, /* we are going to read from a file, so prepare the extraction */ create_rec_keys_codec(&zh->reg->keys); - +#if NATTR + create_rec_keys_codec(&zh->reg->sortKeys); +#else zh->reg->sortKeys.buf_used = 0; - +#endif recordOffset = fi->file_moffset; extractCtrl.handle = zh; extractCtrl.offset = fi->file_moffset; @@ -549,7 +554,11 @@ static int file_extract_record(ZebraHandle zh, { /* record already exists */ struct recKeys delkeys; +#if NATTR + struct recKeys sortKeys; +#else struct sortKeys sortKeys; +#endif rec = rec_get (zh->reg->records, *sysno); assert (rec); @@ -867,9 +876,11 @@ ZEBRA_RES buffer_extract_record (ZebraHandle zh, extractCtrl.fh = &fc; create_rec_keys_codec(&zh->reg->keys); - +#if NATTR + create_rec_keys_codec(&zh->reg->sortKeys); +#else zh->reg->sortKeys.buf_used = 0; - +#endif if (zebraExplain_curDatabase (zh->reg->zei, zh->basenames[0])) { if (zebraExplain_newDatabase (zh->reg->zei, zh->basenames[0], @@ -1001,7 +1012,11 @@ ZEBRA_RES buffer_extract_record (ZebraHandle zh, { /* record already exists */ struct recKeys delkeys; +#if NATTR + struct recKeys sortKeys; +#else struct sortKeys sortKeys; +#endif if (!allow_update) { @@ -1190,9 +1205,11 @@ int explain_extract (void *handle, Record rec, data1_node *n) } create_rec_keys_codec(&zh->reg->keys); - +#if NATTR + create_rec_keys_codec(&zh->reg->sortKeys); +#else zh->reg->sortKeys.buf_used = 0; - +#endif extractCtrl.init = extract_init; extractCtrl.tokenAdd = extract_token_add; extractCtrl.schemaAdd = extract_schema_add; @@ -1213,7 +1230,11 @@ int explain_extract (void *handle, Record rec, data1_node *n) if (rec->size[recInfo_delKeys]) { struct recKeys delkeys; +#if NATTR + struct recKeys sortkeys; +#else struct sortKeys sortkeys; +#endif delkeys.buf_used = rec->size[recInfo_delKeys]; delkeys.buf = rec->info[recInfo_delKeys]; @@ -1448,11 +1469,11 @@ void extract_flushWriteKeys (ZebraHandle zh, int final) } void extract_add_it_key (ZebraHandle zh, + struct recKeys *keys, int reg_type, const char *str, int slen, struct it_key *key) { char *dst; - struct recKeys *keys = &zh->reg->keys; const char *src = (char*) key; if (keys->buf_used+1024 > keys->buf_max) @@ -1467,7 +1488,9 @@ void extract_add_it_key (ZebraHandle zh, iscz1_encode(keys->codec_handle, &dst, &src); +#if REG_TYPE_PREFIX *dst++ = reg_type; +#endif memcpy (dst, str, slen); dst += slen; *dst++ = '\0'; @@ -1557,17 +1580,23 @@ void extract_add_index_string (RecWord *p, const char *str, int length) ZebraExplainInfo zei = zh->reg->zei; int ch; - if (p->attrStr) + if (p->index_name) { - ch = zebraExplain_lookup_attr_str(zei, p->attrStr); + ch = zebraExplain_lookup_attr_str(zei, p->index_type, p->index_name); if (ch < 0) - ch = zebraExplain_add_attr_str(zei, p->attrStr); + ch = zebraExplain_add_attr_str(zei, p->index_type, p->index_name); } else { - ch = zebraExplain_lookup_attr_su(zei, p->attrSet, p->attrUse); +#if NATTR + return; +#else + ch = zebraExplain_lookup_attr_su(zei, p->index_type, + p->attrSet, p->attrUse); if (ch < 0) - ch = zebraExplain_add_attr_su(zei, p->attrSet, p->attrUse); + ch = zebraExplain_add_attr_su(zei, p->index_type, + p->attrSet, p->attrUse); +#endif } key.len = 4; key.mem[0] = ch; @@ -1582,12 +1611,44 @@ void extract_add_index_string (RecWord *p, const char *str, int length) p->attrSet, p->attrUse, p->record_id, p->section_id, p->seqno); #endif - extract_add_it_key(p->extractCtrl->handle, p->reg_type, str, + extract_add_it_key(p->extractCtrl->handle, + &zh->reg->keys, + p->index_type, str, length, &key); } -static void extract_add_sort_string (RecWord *p, const char *str, - int length) +#if NATTR +static void extract_add_sort_string (RecWord *p, const char *str, int length) +{ + struct it_key key; + + ZebraHandle zh = p->extractCtrl->handle; + ZebraExplainInfo zei = zh->reg->zei; + int ch; + + if (p->index_name) + { + ch = zebraExplain_lookup_attr_str(zei, p->index_type, p->index_name); + if (ch < 0) + ch = zebraExplain_add_attr_str(zei, p->index_type, p->index_name); + } + else + { + return; + } + key.len = 4; + key.mem[0] = ch; + key.mem[1] = p->record_id; + key.mem[2] = p->section_id; + key.mem[3] = p->seqno; + + extract_add_it_key(p->extractCtrl->handle, + &zh->reg->sortKeys, + p->index_type, str, + length, &key); +} +#else +static void extract_add_sort_string (RecWord *p, const char *str, int length) { ZebraHandle zh = p->extractCtrl->handle; struct sortKeys *sk = &zh->reg->sortKeys; @@ -1622,11 +1683,12 @@ static void extract_add_sort_string (RecWord *p, const char *str, memcpy (sk->buf + off, str, length); sk->buf_used = off + length; } +#endif void extract_add_string (RecWord *p, const char *string, int length) { assert (length > 0); - if (zebra_maps_is_sort (p->zebra_maps, p->reg_type)) + if (zebra_maps_is_sort (p->zebra_maps, p->index_type)) extract_add_sort_string (p, string, length); else extract_add_index_string (p, string, length); @@ -1641,7 +1703,7 @@ static void extract_add_incomplete_field (RecWord *p) yaz_log(YLOG_DEBUG, "Incomplete field, w='%.*s'", p->term_len, p->term_buf); if (remain > 0) - map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, 0); + map = zebra_maps_input(p->zebra_maps, p->index_type, &b, remain, 0); while (map) { @@ -1653,7 +1715,8 @@ static void extract_add_incomplete_field (RecWord *p) { remain = p->term_len - (b - p->term_buf); if (remain > 0) - map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, 0); + map = zebra_maps_input(p->zebra_maps, p->index_type, &b, + remain, 0); else map = 0; } @@ -1668,7 +1731,7 @@ static void extract_add_incomplete_field (RecWord *p) buf[i++] = *(cp++); remain = p->term_len - (b - p->term_buf); if (remain > 0) - map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, 0); + map = zebra_maps_input(p->zebra_maps, p->index_type, &b, remain, 0); else map = 0; } @@ -1690,7 +1753,7 @@ static void extract_add_complete_field (RecWord *p) p->term_len, p->term_buf); if (remain > 0) - map = zebra_maps_input (p->zebra_maps, p->reg_type, &b, remain, 1); + map = zebra_maps_input (p->zebra_maps, p->index_type, &b, remain, 1); while (remain > 0 && i < IT_MAX_WORD) { @@ -1701,7 +1764,7 @@ static void extract_add_complete_field (RecWord *p) if (remain > 0) { int first = i ? 0 : 1; /* first position */ - map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, first); + map = zebra_maps_input(p->zebra_maps, p->index_type, &b, remain, first); } else map = 0; @@ -1730,7 +1793,7 @@ static void extract_add_complete_field (RecWord *p) remain = p->term_len - (b - p->term_buf); if (remain > 0) { - map = zebra_maps_input (p->zebra_maps, p->reg_type, &b, + map = zebra_maps_input (p->zebra_maps, p->index_type, &b, remain, 0); } else @@ -1751,13 +1814,13 @@ void extract_token_add (RecWord *p) p->reg_type, p->attrSet, p->attrUse, p->seqno, p->length, p->string); #endif - if ((wrbuf = zebra_replace(p->zebra_maps, p->reg_type, 0, + if ((wrbuf = zebra_replace(p->zebra_maps, p->index_type, 0, p->term_buf, p->term_len))) { p->term_buf = wrbuf_buf(wrbuf); p->term_len = wrbuf_len(wrbuf); } - if (zebra_maps_is_complete (p->zebra_maps, p->reg_type)) + if (zebra_maps_is_complete (p->zebra_maps, p->index_type)) extract_add_complete_field (p); else extract_add_incomplete_field(p); @@ -1794,6 +1857,41 @@ void extract_schema_add (struct recExtractCtrl *p, Odr_oid *oid) zebraExplain_addSchema (zh->reg->zei, oid); } +#if NATTR +void extract_flushSortKeys (ZebraHandle zh, SYSNO sysno, + int cmd, struct recKeys *reckeys) +{ + SortIdx sortIdx = zh->reg->sortIdx; + void *decode_handle = iscz1_start(); + int off = 0; + int ch = 0; + + while (off < reckeys->buf_used) + { + const char *src = reckeys->buf + off; + struct it_key key; + char *dst = (char*) &key; + + iscz1_decode(decode_handle, &dst, &src); + assert(key.len == 4); + + ch = (int) key.mem[0]; /* ordinal for field/use/attribute */ + + sortIdx_type(sortIdx, ch); + if (cmd == 1) + sortIdx_add(sortIdx, src, strlen(src)); + else + sortIdx_add(sortIdx, "", 1); + + src += strlen(src); + src++; + + off = src - reckeys->buf; + } + assert (off == reckeys->buf_used); + iscz1_stop(decode_handle); +} +#else void extract_flushSortKeys (ZebraHandle zh, SYSNO sysno, int cmd, struct sortKeys *sk) { @@ -1818,6 +1916,7 @@ void extract_flushSortKeys (ZebraHandle zh, SYSNO sysno, off += slen; } } +#endif void encode_key_init (struct encode_info *i) { diff --git a/index/index.h b/index/index.h index a21f1f4..3f952f2 100644 --- a/index/index.h +++ b/index/index.h @@ -1,4 +1,4 @@ -/* $Id: index.h,v 1.144 2005-06-22 19:42:38 adam Exp $ +/* $Id: index.h,v 1.145 2005-06-23 06:45:46 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -199,11 +199,15 @@ struct recKeys { void *codec_handle; }; +#if NATTR + +#else struct sortKeys { int buf_used; int buf_max; char *buf; }; +#endif struct zebra_register { char *name; @@ -231,10 +235,10 @@ struct zebra_register { int active; /* 0=shutdown, 1=enabled and inactive, 2=activated */ struct recKeys keys; -#if 1 - struct sortKeys sortKeys; +#if NATTR + struct recKeys sortKeys; #else - struct sortKey *sortKeys; + struct sortKeys sortKeys; #endif char **key_buf; size_t ptr_top; @@ -475,8 +479,13 @@ ZEBRA_RES zebra_snippets_hit_vector(ZebraHandle zh, const char *setname, void extract_flushRecordKeys (ZebraHandle zh, SYSNO sysno, int cmd, struct recKeys *reckeys); +#if NATTR +void extract_flushSortKeys (ZebraHandle zh, SYSNO sysno, + int cmd, struct recKeys *skp); +#else void extract_flushSortKeys (ZebraHandle zh, SYSNO sysno, int cmd, struct sortKeys *skp); +#endif void extract_schema_add (struct recExtractCtrl *p, Odr_oid *oid); void extract_token_add (RecWord *p); int explain_extract (void *handle, Record rec, data1_node *n); diff --git a/index/zebraapi.c b/index/zebraapi.c index 1fbb956..cbf4514 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.178 2005-06-14 20:28:54 adam Exp $ +/* $Id: zebraapi.c,v 1.179 2005-06-23 06:45:46 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -316,6 +316,9 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name, reg->sortKeys.buf = 0; reg->sortKeys.buf_max = 0; +#if NATTR + reg->sortKeys.codec_handle = iscz1_start(); +#endif reg->records = 0; reg->dict = 0; @@ -480,6 +483,10 @@ static void zebra_register_close (ZebraService zs, struct zebra_register *reg) xfree(reg->keys.buf); if (reg->keys.codec_handle) iscz1_stop(reg->keys.codec_handle); +#if NATTR + if (reg->sortKeys.codec_handle) + iscz1_stop(reg->sortKeys.codec_handle); +#endif xfree(reg->key_buf); xfree(reg->name); xfree(reg); diff --git a/index/zinfo.c b/index/zinfo.c index 788aaaf..c40e76e 100644 --- a/index/zinfo.c +++ b/index/zinfo.c @@ -1,4 +1,4 @@ -/* $Id: zinfo.c,v 1.45 2005-03-05 09:19:14 adam Exp $ +/* $Id: zinfo.c,v 1.46 2005-06-23 06:45:46 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -32,6 +32,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #define ZINFO_DEBUG 0 struct zebSUInfo { + int index_type; #define ZEB_SU_SET_USE 1 #define ZEB_SU_STR 2 int which; @@ -572,6 +573,7 @@ static void zebraExplain_readAttributeDetails (ZebraExplainInfo zei, data1_node *node_use = NULL; data1_node *node_str = NULL; data1_node *node_ordinal = NULL; + data1_node *node_type = NULL; data1_node *np2; char oid_str[128]; int oid_str_len; @@ -591,11 +593,22 @@ static void zebraExplain_readAttributeDetails (ZebraExplainInfo zei, node_str = np2->child; else if (!strcmp (np2->u.tag.tag, "ordinal")) node_ordinal = np2->child; + else if (!strcmp (np2->u.tag.tag, "type")) + node_type = np2->child; } assert (node_ordinal); *zsuip = (struct zebSUInfoB *) nmem_malloc (zei->nmem, sizeof(**zsuip)); + + if (node_type && node_type->u.data.len > 0) + (*zsuip)->info.index_type = node_type->u.data.data[0]; + else + { + yaz_log(YLOG_WARN, "Missing attribute 'type' in attribute info"); + (*zsuip)->info.index_type = 'w'; + } + if (node_set && node_use) { (*zsuip)->info.which = ZEB_SU_SET_USE; @@ -624,7 +637,7 @@ static void zebraExplain_readAttributeDetails (ZebraExplainInfo zei, } else { - yaz_log(YLOG_WARN, "Missng set/use/str in attribute info"); + yaz_log(YLOG_WARN, "Missing set/use/str in attribute info"); continue; } (*zsuip)->info.ordinal = atoi_n (node_ordinal->u.data.data, @@ -1089,9 +1102,16 @@ static void zebraExplain_writeAttributeDetails (ZebraExplainInfo zei, struct oident oident; int oid[OID_SIZE]; data1_node *node_attr; + char index_type_str[2]; + node_attr = data1_mk_tag (zei->dh, zei->nmem, "attr", 0 /* attr */, node_list); + + index_type_str[0] = zsui->info.index_type; + index_type_str[1] = '\0'; + data1_mk_tag_data_text (zei->dh, node_attr, "type", + index_type_str, zei->nmem); if (zsui->info.which == ZEB_SU_SET_USE) { oident.proto = PROTO_Z3950; @@ -1339,28 +1359,31 @@ static void zebraExplain_writeTarget (ZebraExplainInfo zei, int key_flush) rec_put (zei->records, &trec); } -int zebraExplain_lookup_attr_su(ZebraExplainInfo zei, int set, int use) +int zebraExplain_lookup_attr_su(ZebraExplainInfo zei, int index_type, + int set, int use) { struct zebSUInfoB *zsui; assert (zei->curDatabaseInfo); for (zsui = zei->curDatabaseInfo->attributeDetails->SUInfo; zsui; zsui=zsui->next) - if (zsui->info.which == ZEB_SU_SET_USE && + if (zsui->info.index_type == index_type && + zsui->info.which == ZEB_SU_SET_USE && zsui->info.u.su.use == use && zsui->info.u.su.set == set) return zsui->info.ordinal; return -1; } -int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, const char *str) +int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, int index_type, + const char *str) { struct zebSUInfoB *zsui; assert (zei->curDatabaseInfo); for (zsui = zei->curDatabaseInfo->attributeDetails->SUInfo; zsui; zsui=zsui->next) - if (zsui->info.which == ZEB_SU_STR && - !strcmp(zsui->info.u.str, str)) + if (zsui->info.index_type == index_type && + zsui->info.which == ZEB_SU_STR && !strcmp(zsui->info.u.str, str)) return zsui->info.ordinal; return -1; } @@ -1436,7 +1459,8 @@ void zebraExplain_addAttributeSet (ZebraExplainInfo zei, int set) } } -int zebraExplain_add_attr_su(ZebraExplainInfo zei, int set, int use) +int zebraExplain_add_attr_su(ZebraExplainInfo zei, int index_type, + int set, int use) { struct zebSUInfoB *zsui; @@ -1447,6 +1471,7 @@ int zebraExplain_add_attr_su(ZebraExplainInfo zei, int set, int use) zei->curDatabaseInfo->attributeDetails->SUInfo = zsui; zei->curDatabaseInfo->attributeDetails->dirty = 1; zei->dirty = 1; + zsui->info.index_type = index_type; zsui->info.which = ZEB_SU_SET_USE; zsui->info.u.su.set = set; zsui->info.u.su.use = use; @@ -1454,7 +1479,8 @@ int zebraExplain_add_attr_su(ZebraExplainInfo zei, int set, int use) return zsui->info.ordinal; } -int zebraExplain_add_attr_str(ZebraExplainInfo zei, const char *str) +int zebraExplain_add_attr_str(ZebraExplainInfo zei, int index_type, + const char *index_name) { struct zebSUInfoB *zsui; @@ -1464,8 +1490,9 @@ int zebraExplain_add_attr_str(ZebraExplainInfo zei, const char *str) zei->curDatabaseInfo->attributeDetails->SUInfo = zsui; zei->curDatabaseInfo->attributeDetails->dirty = 1; zei->dirty = 1; + zsui->info.index_type = index_type; zsui->info.which = ZEB_SU_STR; - zsui->info.u.str = nmem_strdup(zei->nmem, str); + zsui->info.u.str = nmem_strdup(zei->nmem, index_name); zsui->info.ordinal = (zei->ordinalSU)++; return zsui->info.ordinal; } diff --git a/index/zinfo.h b/index/zinfo.h index 38b2a9a..a7c0bce 100644 --- a/index/zinfo.h +++ b/index/zinfo.h @@ -1,4 +1,4 @@ -/* $Id: zinfo.h,v 1.23 2005-03-08 14:02:12 adam Exp $ +/* $Id: zinfo.h,v 1.24 2005-06-23 06:45:46 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -50,10 +50,14 @@ void zebraExplain_close (ZebraExplainInfo zei); int zebraExplain_curDatabase (ZebraExplainInfo zei, const char *database); int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database, int explain_database); -int zebraExplain_lookup_attr_su(ZebraExplainInfo zei, int set, int use); -int zebraExplain_add_attr_su(ZebraExplainInfo zei, int set, int use); -int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, const char *str); -int zebraExplain_add_attr_str(ZebraExplainInfo zei, const char *str); +int zebraExplain_lookup_attr_su(ZebraExplainInfo zei, int index_type, + int set, int use); +int zebraExplain_add_attr_su(ZebraExplainInfo zei, int index_type, + int set, int use); +int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, int index_type, + const char *str); +int zebraExplain_add_attr_str(ZebraExplainInfo zei, int index_type, + const char *str); void zebraExplain_addSchema (ZebraExplainInfo zei, Odr_oid *oid); void zebraExplain_recordCountIncrement (ZebraExplainInfo zei, int adjust_num); void zebraExplain_recordBytesIncrement (ZebraExplainInfo zei, int adjust_num); diff --git a/index/zrpn.c b/index/zrpn.c index 9c72835..4b451c4 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -1,4 +1,4 @@ -/* $Id: zrpn.c,v 1.201 2005-06-22 19:42:38 adam Exp $ +/* $Id: zrpn.c,v 1.202 2005-06-23 06:45:46 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -1067,13 +1067,6 @@ static ZEBRA_RES term_trunc(ZebraHandle zh, return ZEBRA_OK; } -static char *nmem_strdup_i(NMEM nmem, int v) -{ - char val_str[64]; - sprintf(val_str, "%d", v); - return nmem_strdup(nmem, val_str); -} - static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char **term_sub, oid_value attributeSet, NMEM stream, @@ -1096,9 +1089,6 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, int space_split = complete_flag ? 0 : 1; int bases_ok = 0; /* no of databases with OK attribute */ - int errCode = 0; /* err code (if any is not OK) */ - char *errString = 0; /* addinfo */ - *ol = ord_list_create(stream); @@ -1152,6 +1142,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, } else if (use_string && (ord = zebraExplain_lookup_attr_str(zh->reg->zei, + reg_type, use_string)) >= 0) { /* we have a match for a raw string attribute */ @@ -1183,11 +1174,13 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, if (r == -1) { /* set was found, but value wasn't defined */ - errCode = YAZ_BIB1_UNSUPP_USE_ATTRIBUTE; if (use_string) - errString = nmem_strdup(stream, use_string); + zebra_setError(zh, + YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, + use_string); else - errString = nmem_strdup_i (stream, use_value); + zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, + use_value); } else { @@ -1199,8 +1192,10 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, oident.value = curAttributeSet; oid_ent_to_oid (&oident, oid); - errCode = YAZ_BIB1_UNSUPP_ATTRIBUTE_SET; - errString = nmem_strdup(stream, oident.desc); + zebra_setError(zh, + YAZ_BIB1_UNSUPP_ATTRIBUTE_SET, + oident.desc); + } continue; } @@ -1212,6 +1207,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, int i, ord_len; ord = zebraExplain_lookup_attr_su(zh->reg->zei, + reg_type, attp.attset_ordinal, local_attr->local); if (ord < 0) @@ -1234,9 +1230,11 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, attr_ok = 1; term_dict[prefix_len++] = ')'; +#if REG_TYPE_PREFIX term_dict[prefix_len++] = 1; term_dict[prefix_len++] = reg_type; yaz_log(log_level_rpn, "reg_type = %d", term_dict[prefix_len-1]); +#endif term_dict[prefix_len] = '\0'; j = prefix_len; switch (truncation_value) @@ -1373,10 +1371,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, } } if (!bases_ok) - { - zebra_setError(zh, errCode, errString); return ZEBRA_FAIL; - } *term_sub = termp; yaz_log(YLOG_DEBUG, "%d positions", grep_info->isam_p_indx); return ZEBRA_OK; @@ -1795,8 +1790,6 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, struct rpn_char_map_info rcmi; int bases_ok = 0; /* no of databases with OK attribute */ - int errCode = 0; /* err code (if any is not OK) */ - char *errString = 0; /* addinfo */ rpn_char_map_prepare (zh->reg, reg_type, &rcmi); attr_init(&use, zapt, 1); @@ -1832,20 +1825,22 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, else { if ((r = att_getentbyatt (zh, &attp, curAttributeSet, use_value, - use_string))) + use_string))) { yaz_log(YLOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d", curAttributeSet, use_value, r); if (r == -1) { - errCode = YAZ_BIB1_UNSUPP_USE_ATTRIBUTE; if (use_string) - errString = nmem_strdup(stream, use_string); + zebra_setError(zh, + YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, + use_string); else - errString = nmem_strdup_i (stream, use_value); + zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, + use_value); } else - errCode = YAZ_BIB1_UNSUPP_ATTRIBUTE_SET; + zebra_setError(zh, YAZ_BIB1_UNSUPP_ATTRIBUTE_SET, 0); continue; } } @@ -1863,6 +1858,7 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, int i, ord_len; ord = zebraExplain_lookup_attr_su(zh->reg->zei, + reg_type, attp.attset_ordinal, local_attr->local); if (ord < 0) @@ -1885,10 +1881,12 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, continue; } bases_ok++; - term_dict[prefix_len++] = ')'; + term_dict[prefix_len++] = ')'; +#if REG_TYPE_PREFIX term_dict[prefix_len++] = 1; term_dict[prefix_len++] = reg_type; yaz_log(YLOG_DEBUG, "reg_type = %d", term_dict[prefix_len-1]); +#endif term_dict[prefix_len] = '\0'; if (!numeric_relation(zh, zapt, &termp, term_dict, attributeSet, grep_info, &max_pos, reg_type, @@ -1904,10 +1902,7 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, } } if (!bases_ok) - { - zebra_setError(zh, errCode, errString); return ZEBRA_FAIL; - } *term_sub = termp; yaz_log(YLOG_DEBUG, "%d positions", grep_info->isam_p_indx); return ZEBRA_OK; @@ -2129,7 +2124,8 @@ static RSET xpath_trunc(ZebraHandle zh, NMEM stream, char term_dict[2048]; char ord_buf[32]; int prefix_len = 0; - int ord = zebraExplain_lookup_attr_su(zh->reg->zei, curAttributeSet, use); + int ord = zebraExplain_lookup_attr_su(zh->reg->zei, reg_type, + curAttributeSet, use); int ord_len, i, r, max_pos; int term_type = Z_Term_characterString; const char *flags = "void"; @@ -2151,9 +2147,10 @@ static RSET xpath_trunc(ZebraHandle zh, NMEM stream, term_dict[prefix_len++] = ord_buf[i]; } term_dict[prefix_len++] = ')'; +#if REG_TYPE_PREFIX term_dict[prefix_len++] = 1; term_dict[prefix_len++] = reg_type; - +#endif strcpy(term_dict+prefix_len, term); grep_info.isam_p_indx = 0; @@ -2826,7 +2823,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, } if (use_string && - (ord = zebraExplain_lookup_attr_str(zh->reg->zei, + (ord = zebraExplain_lookup_attr_str(zh->reg->zei, reg_id, use_string)) >= 0) { /* we have a match for a raw string attribute */ @@ -2864,7 +2861,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, for (local_attr = attp.local_attributes; local_attr && ord_no < 32; local_attr = local_attr->next) { - ord = zebraExplain_lookup_attr_su(zh->reg->zei, + ord = zebraExplain_lookup_attr_su(zh->reg->zei, reg_id, attp.attset_ordinal, local_attr->local); if (ord > 0) @@ -2918,7 +2915,9 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, scan_info->list[j].term = NULL; prefix_len += key_SU_encode (ords[i], termz + prefix_len); +#if REG_TYPE_PREFIX termz[prefix_len++] = reg_id; +#endif termz[prefix_len] = 0; strcpy(scan_info->prefix, termz); diff --git a/recctrl/alvis.c b/recctrl/alvis.c index 907cb06..4fbbbda 100644 --- a/recctrl/alvis.c +++ b/recctrl/alvis.c @@ -1,4 +1,4 @@ -/* $Id: alvis.c,v 1.2 2005-04-28 08:20:40 adam Exp $ +/* $Id: alvis.c,v 1.3 2005-06-23 06:45:47 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -111,7 +111,6 @@ static int filter_extract (void *clientData, struct recExtractCtrl *p) xfree(tinfo->sep); tinfo->sep = 0; (*p->init)(p, &recWord); - recWord.reg_type = 'w'; do { int i = 0; diff --git a/recctrl/recgrs.c b/recctrl/recgrs.c index af9f096..99eb954 100644 --- a/recctrl/recgrs.c +++ b/recctrl/recgrs.c @@ -1,4 +1,4 @@ -/* $Id: recgrs.c,v 1.101 2005-04-29 23:09:30 adam Exp $ +/* $Id: recgrs.c,v 1.102 2005-06-23 06:45:47 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -465,32 +465,50 @@ static void index_xpath_attr (char *tag_path, char *name, char *value, char *structure, struct recExtractCtrl *p, RecWord *wrd) { +#if NATTR + wrd->index_name = ZEBRA_XPATH_ELM_BEGIN; +#else wrd->attrSet = VAL_IDXPATH; wrd->attrUse = 1; - wrd->reg_type = '0'; +#endif + wrd->index_type = '0'; wrd->term_buf = tag_path; wrd->term_len = strlen(tag_path); (*p->tokenAdd)(wrd); if (value) { +#if NATTR + wrd->index_name = ZEBRA_XPATH_ATTR; +#else wrd->attrUse = 1015; - wrd->reg_type = 'w'; +#endif + wrd->index_type = 'w'; wrd->term_buf = value; wrd->term_len = strlen(value); (*p->tokenAdd)(wrd); } - +#if NATTR + wrd->index_name = ZEBRA_XPATH_ELM_END; +#else wrd->attrUse = 2; - wrd->reg_type = '0'; +#endif + wrd->index_type = '0'; wrd->term_buf = tag_path; wrd->term_len = strlen(tag_path); (*p->tokenAdd)(wrd); } -static void index_xpath (struct source_parser *sp, data1_node *n, - struct recExtractCtrl *p, - int level, RecWord *wrd, int use) +static void index_xpath(struct source_parser *sp, data1_node *n, + struct recExtractCtrl *p, + int level, RecWord *wrd, +#if NATTR + char *xpath_index, + int xpath_is_start +#else + int use +#endif + ) { int i; char tag_path_full[1024]; @@ -499,8 +517,19 @@ static void index_xpath (struct source_parser *sp, data1_node *n, int termlist_only = 1; data1_termlist *tl; int xpdone = 0; +#if NATTR +#else + int xpath_is_start = 0; + if (use == 1) + xpath_is_start = 1; +#endif +#if NATTR + yaz_log(YLOG_DEBUG, "index_xpath level=%d xpath_index=%s", + level, xpath_index); +#else yaz_log(YLOG_DEBUG, "index_xpath level=%d use=%d", level, use); +#endif if ((!n->root->u.root.absyn) || (n->root->u.root.absyn->enable_xpath_indexing)) { termlist_only = 0; @@ -541,14 +570,23 @@ static void index_xpath (struct source_parser *sp, data1_node *n, { /* need to copy recword because it may be changed */ RecWord wrd_tl; - wrd->reg_type = *tl->structure; - /* this is the ! case, so structure is for the xpath index */ + wrd->index_type = *tl->structure; memcpy (&wrd_tl, wrd, sizeof(*wrd)); if (tl->source) sp_parse(sp, n, &wrd_tl, tl->source); - if (!tl->att) { +#if NATTR + if (!tl->index_name) +#else + if (!tl->att) +#endif + { + /* this is the ! case, so structure is for the xpath index */ +#if NATTR + wrd_tl.index_name = xpath_index; +#else wrd_tl.attrSet = VAL_IDXPATH; wrd_tl.attrUse = use; +#endif if (p->flagShowRecords) { int i; @@ -566,17 +604,25 @@ static void index_xpath (struct source_parser *sp, data1_node *n, xpdone = 1; } else { /* this is just the old fashioned attribute based index */ +#if NATTR + wrd_tl.index_name = tl->index_name; +#else wrd_tl.attrSet = (int) (tl->att->parent->reference); wrd_tl.attrUse = tl->att->locals->local; +#endif if (p->flagShowRecords) { int i; printf("%*sIdx: [%s]", (level + 1) * 4, "", tl->structure); +#if NATTR + printf("%s %s", tl->index_name, tl->source); +#else printf("%s:%s [%d] %s", tl->att->parent->name, tl->att->name, tl->att->value, tl->source); +#endif printf (" XData:\""); for (i = 0; iflagShowRecords && !xpdone && !termlist_only) { +#if NATTR + wrd->index_name = xpath_index; +#else wrd->attrSet = VAL_IDXPATH; wrd->attrUse = use; - wrd->reg_type = 'w'; +#endif + wrd->index_type = 'w'; (*p->tokenAdd)(wrd); } break; @@ -618,11 +668,15 @@ static void index_xpath (struct source_parser *sp, data1_node *n, } - wrd->reg_type = '0'; + wrd->index_type = '0'; wrd->term_buf = tag_path_full; wrd->term_len = flen; +#if NATTR + wrd->index_name = xpath_index; +#else wrd->attrSet = VAL_IDXPATH; wrd->attrUse = use; +#endif if (p->flagShowRecords) { printf("%*s tag=", (level + 1) * 4, ""); @@ -640,18 +694,30 @@ static void index_xpath (struct source_parser *sp, data1_node *n, tag_path_full[flen] = 0; - /* Add tag start/end xpath index, only when there is a ! in the apropriate xelm - directive, or default xpath indexing is enabled */ - if (!(do_xpindex = 1 - termlist_only)) { - if ((tl = xpath_termlist_by_tagpath(tag_path_full, n))) { - for (; tl; tl = tl->next) { if (!tl->att) {do_xpindex = 1;} } + /* Add tag start/end xpath index, only when there is a ! in + the apropriate xelm directive, or default xpath indexing + is enabled + */ + if (!(do_xpindex = 1 - termlist_only)) + { + if ((tl = xpath_termlist_by_tagpath(tag_path_full, n))) + { + for (; tl; tl = tl->next) + { +#if NATTR + if (!tl->index_name) +#else + if (!tl->att) +#endif + do_xpindex = 1; + } } } if (do_xpindex) { (*p->tokenAdd)(wrd); /* index element pag (AKA tag path) */ } - if (use == 1) /* only for the starting tag... */ + if (xpath_is_start == 1) /* only for the starting tag... */ { #define MAX_ATTR_COUNT 50 data1_termlist *tll[MAX_ATTR_COUNT]; @@ -682,17 +748,26 @@ static void index_xpath (struct source_parser *sp, data1_node *n, if ((tl = tll[i])) { for (; tl; tl = tl->next) - { + { +#if NATTR + if (!tl->index_name) + do_xpindex = 1; +#else if (!tl->att) do_xpindex = 1; +#endif } } if (do_xpindex) { /* attribute (no value) */ - wrd->reg_type = '0'; + wrd->index_type = '0'; +#if NATTR + wrd->index_name = ZEBRA_XPATH_ATTR; +#else wrd->attrUse = 3; +#endif wrd->term_buf = xp->name; wrd->term_len = strlen(xp->name); @@ -706,9 +781,13 @@ static void index_xpath (struct source_parser *sp, data1_node *n, strcpy (comb, xp->name); strcat (comb, "="); strcat (comb, xp->value); - + +#if NATTR + wrd->index_name = ZEBRA_XPATH_ATTR; +#else wrd->attrUse = 3; - wrd->reg_type = '0'; +#endif + wrd->index_type = '0'; wrd->term_buf = comb; wrd->term_len = strlen(comb); wrd->seqno--; @@ -734,7 +813,12 @@ static void index_xpath (struct source_parser *sp, data1_node *n, /* If there is a termlist given (=xelm directive) */ for (; tl; tl = tl->next) { - if (!tl->att) { +#if NATTR + if (!tl->index_name) +#else + if (!tl->att) +#endif + { /* add xpath index for the attribute */ index_xpath_attr (attr_tag_path_full, xp->name, xp->value, tl->structure, @@ -742,11 +826,16 @@ static void index_xpath (struct source_parser *sp, data1_node *n, xpdone = 1; } else { /* add attribute based index for the attribute */ - if (xp->value) { + if (xp->value) + { +#if NATTR + wrd->index_name = tl->index_name; +#else wrd->attrSet = (int) (tl->att->parent->reference); wrd->attrUse = tl->att->locals->local; - wrd->reg_type = *tl->structure; +#endif + wrd->index_type = *tl->structure; wrd->term_buf = xp->value; wrd->term_len = strlen(xp->value); (*p->tokenAdd)(wrd); @@ -804,10 +893,14 @@ static void index_termlist (struct source_parser *sp, data1_node *par, int i; printf("%*sIdx: [%s]", (level + 1) * 4, "", tlist->structure); +#if NATTR + printf("%s %s", tlist->index_name, tlist->source); +#else printf("%s:%s [%d] %s", tlist->att->parent->name, tlist->att->name, tlist->att->value, tlist->source); +#endif printf (" XData:\""); for (i = 0; iterm_len && i < 40; i++) fputc (wrd->term_buf[i], stdout); @@ -818,9 +911,13 @@ static void index_termlist (struct source_parser *sp, data1_node *par, } else { - wrd->reg_type = *tlist->structure; + wrd->index_type = *tlist->structure; +#if NATTR + wrd->index_name = tlist->index_name; +#else wrd->attrSet = (int) (tlist->att->parent->reference); wrd->attrUse = tlist->att->locals->local; +#endif (*p->tokenAdd)(wrd); } } @@ -874,8 +971,14 @@ static int dumpkeys_r(struct source_parser *sp, { index_termlist(sp, n, n, p, level, wrd); /* index start tag */ +#if NATTR + if (n->root->u.root.absyn) + index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_ELM_BEGIN, + 1 /* is start */); +#else if (n->root->u.root.absyn) index_xpath(sp, n, p, level, wrd, 1); +#endif } if (n->child) @@ -903,13 +1006,23 @@ static int dumpkeys_r(struct source_parser *sp, if (par) index_termlist(sp, par, n, p, level, wrd); +#if NATTR + index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_CDATA, + 0 /* is start */); +#else index_xpath(sp, n, p, level, wrd, 1016); +#endif } if (n->which == DATA1N_tag) { /* index end tag */ +#if NATTR + index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_ELM_END, + 0 /* is start */); +#else index_xpath(sp, n, p, level, wrd, 2); +#endif } if (p->flagShowRecords && n->which == DATA1N_root) diff --git a/recctrl/rectext.c b/recctrl/rectext.c index 352b95e..cf192c4 100644 --- a/recctrl/rectext.c +++ b/recctrl/rectext.c @@ -1,4 +1,4 @@ -/* $Id: rectext.c,v 1.28 2005-06-14 20:27:33 adam Exp $ +/* $Id: rectext.c,v 1.29 2005-06-23 06:45:47 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -41,7 +41,7 @@ static void *filter_init (Res res, RecType recType) static void filter_config(void *clientData, Res res, const char *args) { - struct filter_info *tinfo = (struct marc_info*) clientData; + struct filter_info *tinfo = (struct filter_info*) clientData; xfree(tinfo->sep); tinfo->sep = 0; if (args && *args) @@ -114,7 +114,6 @@ static int filter_extract (void *clientData, struct recExtractCtrl *p) (long) (*fi->p->tellf)(fi->p->fh)); #endif (*p->init)(p, &recWord); - recWord.reg_type = 'w'; do { int i = 0; diff --git a/recctrl/safari.c b/recctrl/safari.c index c524599..f22ef34 100644 --- a/recctrl/safari.c +++ b/recctrl/safari.c @@ -1,4 +1,4 @@ -/* $Id: safari.c,v 1.7 2005-03-31 12:42:07 adam Exp $ +/* $Id: safari.c,v 1.8 2005-06-23 06:45:47 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -123,7 +123,7 @@ static int filter_extract(void *clientData, struct recExtractCtrl *p) return RECCTRL_EXTRACT_ERROR_GENERIC; sscanf(line, "%255s", p->match_criteria); - recWord.reg_type = 'w'; + recWord.index_type = 'w'; while (fi_gets(fi, line, sizeof(line)-1)) { int nor = 0; @@ -141,7 +141,7 @@ static int filter_extract(void *clientData, struct recExtractCtrl *p) } for (cp = line + nor; *cp == ' '; cp++) ; - recWord.attrStr = field; + recWord.index_name = field; recWord.term_buf = cp; recWord.term_len = strlen(cp); (*p->tokenAdd)(&recWord); diff --git a/recctrl/xslt.c b/recctrl/xslt.c index d2cf67a..ab7a18e 100644 --- a/recctrl/xslt.c +++ b/recctrl/xslt.c @@ -1,4 +1,4 @@ -/* $Id: xslt.c,v 1.10 2005-06-15 15:30:05 adam Exp $ +/* $Id: xslt.c,v 1.11 2005-06-23 06:45:47 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -314,6 +314,7 @@ static void index_node(struct filter_info *tinfo, struct recExtractCtrl *ctrl, if (!strcmp(ptr->name, "index")) { char *name_str = 0; + const char *type_str = 0; const char *xpath_str = 0; struct _xmlAttr *attr; for (attr = ptr->properties; attr; attr = attr->next) @@ -324,11 +325,20 @@ static void index_node(struct filter_info *tinfo, struct recExtractCtrl *ctrl, if (!strcmp(attr->name, "xpath") && attr->children && attr->children->type == XML_TEXT_NODE) xpath_str = attr->children->content; + if (!strcmp(attr->name, "type") + && attr->children && attr->children->type == XML_TEXT_NODE) + type_str = attr->children->content; } if (name_str) { - recWord->attrStr = name_str; + int prev_type = recWord->index_type; /* save default type */ + + if (type_str && *type_str) + recWord->index_type = *type_str; /* type was given */ + recWord->index_name = name_str; index_cdata(tinfo, ctrl, ptr->children, recWord); + + recWord->index_type = prev_type; /* restore it again */ } } } @@ -348,7 +358,6 @@ static int extract_doc(struct filter_info *tinfo, struct recExtractCtrl *p, set_param_str(params, "schema", zebra_xslt_ns, tinfo->odr); (*p->init)(p, &recWord); - recWord.reg_type = 'w'; if (schema && schema->stylesheet_xsp) { diff --git a/test/api/t5.c b/test/api/t5.c index fb515e6..d86095d 100644 --- a/test/api/t5.c +++ b/test/api/t5.c @@ -1,4 +1,4 @@ -/* $Id: t5.c,v 1.12 2005-04-15 10:47:49 adam Exp $ +/* $Id: t5.c,v 1.13 2005-06-23 06:45:47 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -94,7 +94,7 @@ int main(int argc, char **argv) /* provoke unsupported relation */ do_query_x(__LINE__, zh, "@attr 1=1016 @attr 2=6 x", 0, 117); - do_query_x(__LINE__, zh, "@attr 1=1016 @attr 2=6 @attr 4=109 x", 0, 117); + do_query_x(__LINE__, zh, "@attr 1=1016 @attr 2=6 @attr 4=109 x", 0, 114); return close_down(zh, zs, 0); } -- 1.7.10.4