Zebra uses string attributes for indexing internally. Using set+numeric
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 19 May 2006 13:49:33 +0000 (13:49 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 19 May 2006 13:49:33 +0000 (13:49 +0000)
use attribute can still be used. But that is a search-only conversion which
inspects .att-set files as indicated using attset-directives in zebra.cfg.
attset references are no longer required, but when used they deserve
as "check" for that the index names used are also present in .att.

34 files changed:
NEWS
data1/d1_absyn.c
data1/d1_attset.c
include/Makefile.am
include/attrfind.h [new file with mode: 0644]
include/d1_absyn.h
include/idzebra/data1.h
include/idzebra/recctrl.h
include/idzebra/util.h
index/attribute.c
index/extract.c
index/index.h
index/zebrash.c
index/zinfo.c
index/zrpn.c
index/zsets.c
recctrl/recgrs.c
tab/gils.abs
test/api/Makefile.am
test/api/t10.c [deleted file]
test/api/t5.c
test/api/t8.c
test/api/t9.c
test/charmap/charmap1.c
test/filters/grs.marc.c
test/gils/test1.sh
test/gils/test3.sh
test/sort/sort1.c
test/sort2/t1.c
test/xpath/zebra.cfg
util/Makefile.am
util/attrfind.c [new file with mode: 0644]
util/zebramap.c
win/makefile

diff --git a/NEWS b/NEWS
index 49bb6f8..1210790 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+Zebra uses string attributes for indexing internally. Using set+numeric
+use attribute can still be used. But that is a search-only conversion which
+inspects .att-set files as indicated using attset-directives in zebra.cfg.
+attset references are no longer required, but when used they deserve
+as "check" for that the index names used are also present in .att.
+
 Implemented bug #588: allrecords search. Using @attr 1=allrecords ""
 matches all records in a database.
 
 Implemented bug #588: allrecords search. Using @attr 1=allrecords ""
 matches all records in a database.
 
index 1df3e3f..a1bc53d 100644 (file)
@@ -1,5 +1,5 @@
-/* $Id: d1_absyn.c,v 1.24 2006-05-10 08:13:17 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
    Index Data ApS
 
 This file is part of the Zebra server.
    Index Data ApS
 
 This file is part of the Zebra server.
@@ -28,6 +28,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <yaz/log.h>
 #include <yaz/oid.h>
 #include <idzebra/data1.h>
 #include <yaz/log.h>
 #include <yaz/oid.h>
 #include <idzebra/data1.h>
+#include <idzebra/recctrl.h>
 #include <zebra_xpath.h>
 #include <d1_absyn.h>
 
 #include <zebra_xpath.h>
 #include <d1_absyn.h>
 
@@ -509,17 +510,11 @@ static const char * mk_xpath_regexp (data1_handle dh, const char *expr)
     return 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)
 {
     data1_termlist **tp = *tpp;
     while(1)
 {
     data1_termlist **tp = *tpp;
     while(1)
@@ -570,27 +565,24 @@ static int parse_termlists (data1_handle dh, data1_termlist ***tpp,
            nmem_malloc(data1_nmem_get(dh), sizeof(**tp));
        (*tp)->next = 0;
         
            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 == '!')
+        if (*attname == '!')
+        {
+            if (!xpelement && element_name)
                 strcpy(attname, element_name);
                 strcpy(attname, element_name);
-       }
-       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);
             }
             }
-       }
-#endif   
+        }
+
+        (*tp)->index_name = nmem_strdup(data1_nmem_get(dh), attname);
+        assert (*(*tp)->index_name != '!');
        if (r == 2 && (source = strchr(structure, ':')))
            *source++ = '\0';   /* cut off structure .. */
        else
        if (r == 2 && (source = strchr(structure, ':')))
            *source++ = '\0';   /* cut off structure .. */
        else
@@ -704,6 +696,8 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file,
 {
     data1_sub_elements *cur_elements = NULL;
     data1_xpelement *cur_xpelement = NULL;
 {
     data1_sub_elements *cur_elements = NULL;
     data1_xpelement *cur_xpelement = NULL;
+    data1_attset *attset_list = data1_empty_attset(dh);
+    data1_attset_child **attset_childp = &attset_list->children;
 
     data1_absyn *res = 0;
     FILE *f;
 
     data1_absyn *res = 0;
     FILE *f;
@@ -712,7 +706,6 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file,
     data1_maptab **maptabp;
     data1_marctab **marcp;
     data1_termlist *all = 0;
     data1_maptab **maptabp;
     data1_marctab **marcp;
     data1_termlist *all = 0;
-    data1_attset_child **attset_childp;
     data1_tagset **tagset_childp;
     struct data1_systag **systagsp;
     int level = 0;
     data1_tagset **tagset_childp;
     struct data1_systag **systagsp;
     int level = 0;
@@ -737,9 +730,6 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file,
     systagsp = &res->systags;
     tagset_childp = &res->tagset;
 
     systagsp = &res->systags;
     tagset_childp = &res->tagset;
 
-    res->attset = data1_empty_attset (dh);
-    attset_childp =  &res->attset->children;
-
     res->varset = 0;
     res->esetnames = 0;
     esetpp = &res->esetnames;
     res->varset = 0;
     res->esetnames = 0;
     esetpp = &res->esetnames;
@@ -750,7 +740,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file,
     res->sub_elements = NULL;
     res->main_elements = NULL;
     res->xp_elements = NULL;
     res->sub_elements = NULL;
     res->main_elements = NULL;
     res->xp_elements = NULL;
-    
+
     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;
@@ -859,9 +849,8 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file,
            p = termlists;
            if (*p != '-')
            {
            p = termlists;
            if (*p != '-')
            {
-               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))
                {
                    fclose (f);
                    return 0;
                {
                    fclose (f);
                    return 0;
@@ -949,10 +938,8 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file,
            p = termlists;
            if (*p != '-')
            {
            p = termlists;
            if (*p != '-')
            {
-               assert (res->attset);
-               
                if (parse_termlists (dh, &tp, p, file, lineno,
                if (parse_termlists (dh, &tp, p, file, lineno,
-                                     xpath_expr, res, 1))
+                                     xpath_expr, res, 1, attset_list))
                {
                    fclose (f);
                    return 0;
                {
                    fclose (f);
                    return 0;
@@ -1015,7 +1002,8 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file,
                     file, lineno);
                continue;
            }
                     file, lineno);
                continue;
            }
-           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))
            {
                fclose (f);
                return 0;
            {
                fclose (f);
                return 0;
@@ -1051,31 +1039,27 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file,
        }
        else if (!strcmp(cmd, "attset"))
        {
        }
        else if (!strcmp(cmd, "attset"))
        {
-#if NATTR
-           yaz_log(YLOG_WARN, "%s:%d: attset obsolete", file, lineno);
-#else
-           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;
-#endif
+           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;
        }
        else if (!strcmp(cmd, "tagset"))
        {
        }
        else if (!strcmp(cmd, "tagset"))
        {
index bcd3484..40e1b04 100644 (file)
@@ -1,5 +1,5 @@
-/* $Id: d1_attset.c,v 1.8 2006-05-10 08:13:18 adam Exp $
-   Copyright (C) 1995-2005
+/* $Id: d1_attset.c,v 1.9 2006-05-19 13:49:33 adam Exp $
+   Copyright (C) 1995-2006
    Index Data ApS
 
 This file is part of the Zebra server.
    Index Data ApS
 
 This file is part of the Zebra server.
@@ -27,21 +27,21 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <yaz/log.h>
 #include <idzebra/data1.h>
 
 #include <yaz/log.h>
 #include <idzebra/data1.h>
 
-data1_att *data1_getattbyname(data1_handle dh, data1_attset *s, char *name)
+data1_att *data1_getattbyname(data1_handle dh, data1_attset *s, const char *name)
 {
     data1_att *r;
     data1_attset_child *c;
     
     /* scan local set */
     for (r = s->atts; r; r = r->next)
 {
     data1_att *r;
     data1_attset_child *c;
     
     /* scan local set */
     for (r = s->atts; r; r = r->next)
-       if (!data1_matchstr(r->name, name))
-           return r;
+        if (!data1_matchstr(r->name, name))
+            return r;
     for (c = s->children; c; c = c->next)
     {
     for (c = s->children; c; c = c->next)
     {
-       assert (c->child);
-       /* scan included sets */
-       if ((r = data1_getattbyname (dh, c->child, name)))
-           return r;
+        assert (c->child);
+        /* scan included sets */
+        if ((r = data1_getattbyname (dh, c->child, name)))
+            return r;
     }
     return 0;
 }
     }
     return 0;
 }
index 6bb6f49..1357c2a 100644 (file)
@@ -1,6 +1,6 @@
-# $Id: Makefile.am,v 1.22 2005-03-30 09:25:23 adam Exp $
+# $Id: Makefile.am,v 1.23 2006-05-19 13:49:33 adam Exp $
 noinst_HEADERS = bset.h charmap.h  \
 direntz.h passwddb.h dfa.h zebra_xpath.h d1_absyn.h \
 noinst_HEADERS = bset.h charmap.h  \
 direntz.h passwddb.h dfa.h zebra_xpath.h d1_absyn.h \
-rset.h dfaset.h sortidx.h zebra-lock.h
+rset.h dfaset.h sortidx.h zebra-lock.h attrfind.h
 
 SUBDIRS = idzebra
 
 SUBDIRS = idzebra
diff --git a/include/attrfind.h b/include/attrfind.h
new file mode 100644 (file)
index 0000000..cea9e4d
--- /dev/null
@@ -0,0 +1,59 @@
+/* $Id: attrfind.h,v 1.1 2006-05-19 13:49:34 adam Exp $
+   Copyright (C) 2005-2006
+   Index Data ApS
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Zebra; see the file LICENSE.zebra.  If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+*/
+
+#ifndef ATTRFIND_H
+#define ATTRFIND_H
+
+#include <yaz/yconfig.h>
+#include <yaz/z-core.h>
+#include <yaz/oid.h>
+
+YAZ_BEGIN_CDECL
+
+typedef struct {
+    int type;
+    int major;
+    int minor;
+    Z_AttributeElement **attributeList;
+    int num_attributes;
+} AttrType;
+
+void attr_init_APT(AttrType *src, Z_AttributesPlusTerm *zapt, int type);
+
+void attr_init_AttrList(AttrType *src, Z_AttributeList *list, int type);
+
+int attr_find_ex(AttrType *src, oid_value *attributeSetP,
+                 const char **string_value);
+int attr_find(AttrType *src, oid_value *attributeSetP);
+    
+
+YAZ_END_CDECL
+
+#endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 00804f1..f7aa6c9 100644 (file)
@@ -1,5 +1,5 @@
-/* $Id: d1_absyn.h,v 1.3 2006-05-10 08:13:18 adam Exp $
-   Copyright (C) 1995-2005
+/* $Id: d1_absyn.h,v 1.4 2006-05-19 13:49:34 adam Exp $
+   Copyright (C) 1995-2006
    Index Data ApS
 
 This file is part of the Zebra server.
    Index Data ApS
 
 This file is part of the Zebra server.
@@ -46,7 +46,6 @@ struct data1_absyn
     char *name;
     oid_value reference;
     data1_tagset *tagset;
     char *name;
     oid_value reference;
     data1_tagset *tagset;
-    data1_attset *attset;
     data1_varset *varset;
     data1_esetname *esetnames;
     data1_maptab *maptabs;
     data1_varset *varset;
     data1_esetname *esetnames;
     data1_maptab *maptabs;
index eda8ea4..4151727 100644 (file)
@@ -1,5 +1,5 @@
-/* $Id: data1.h,v 1.12 2006-05-10 08:13:20 adam Exp $
-   Copyright (C) 1995-2005
+/* $Id: data1.h,v 1.13 2006-05-19 13:49:34 adam Exp $
+   Copyright (C) 1995-2006
    Index Data ApS
 
 This file is part of the Zebra server.
    Index Data ApS
 
 This file is part of the Zebra server.
@@ -88,7 +88,7 @@ struct data1_attset
 typedef struct data1_handle_info *data1_handle;
 
 YAZ_EXPORT data1_att *data1_getattbyname(data1_handle dh, data1_attset *s,
 typedef struct data1_handle_info *data1_handle;
 
 YAZ_EXPORT data1_att *data1_getattbyname(data1_handle dh, data1_attset *s,
-                                        char *name);
+                                        const char *name);
 YAZ_EXPORT data1_attset *data1_read_attset(data1_handle dh, const char *file);
 
 YAZ_EXPORT data1_attset *data1_empty_attset(data1_handle dh);
 YAZ_EXPORT data1_attset *data1_read_attset(data1_handle dh, const char *file);
 
 YAZ_EXPORT data1_attset *data1_empty_attset(data1_handle dh);
@@ -245,11 +245,7 @@ struct data1_tagset
 
 typedef struct data1_termlist
 {
 
 typedef struct data1_termlist
 {
-#if NATTR
     char *index_name;
     char *index_name;
-#else
-    data1_att *att;
-#endif
     char *structure;
     char *source;
     struct data1_termlist *next;
     char *structure;
     char *source;
     struct data1_termlist *next;
index fddb08a..4ad6157 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: recctrl.h,v 1.19 2006-05-10 08:13:20 adam Exp $
+/* $Id: recctrl.h,v 1.20 2006-05-19 13:49:34 adam Exp $
    Copyright (C) 1995-2006
    Index Data ApS
 
    Copyright (C) 1995-2006
    Index Data ApS
 
@@ -34,20 +34,23 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 YAZ_BEGIN_CDECL
 
 
 YAZ_BEGIN_CDECL
 
-#if NATTR
+/* 1 */
 #define ZEBRA_XPATH_ELM_BEGIN "_XPATH_BEGIN"
 #define ZEBRA_XPATH_ELM_BEGIN "_XPATH_BEGIN"
+
+/* 2 */
 #define ZEBRA_XPATH_ELM_END   "_XPATH_END"
 #define ZEBRA_XPATH_ELM_END   "_XPATH_END"
+
+/* 1016 */
 #define ZEBRA_XPATH_CDATA     "_XPATH_CDATA"
 #define ZEBRA_XPATH_CDATA     "_XPATH_CDATA"
-#define ZEBRA_XPATH_ATTR      "_XPATH_ATTR"
-#endif
+
+/* 3 */
+#define ZEBRA_XPATH_ATTR_NAME       "_XPATH_ATTR_NAME"
+
+/* 1015 */
+#define ZEBRA_XPATH_ATTR_CDATA      "_XPATH_ATTR_CDATA"
 
 /* single word entity */
 typedef struct {
 
 /* single word entity */
 typedef struct {
-#if NATTR
-#else
-    int  attrSet;
-    int  attrUse;
-#endif
     unsigned index_type;
     const char *index_name;
     const char *term_buf;
     unsigned index_type;
     const char *index_name;
     const char *term_buf;
index b0f54f3..0744fea 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: util.h,v 1.6 2006-05-10 08:13:20 adam Exp $
+/* $Id: util.h,v 1.7 2006-05-19 13:49:34 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -84,9 +84,6 @@ YAZ_END_CDECL
 #define CAST_ZINT_TO_INT(x) (int)(x)
 #define CAST_ZINT_TO_DOUBLE(x) (double)(x)
 
 #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
-
 #endif
 /*
  * Local variables:
 #endif
 /*
  * Local variables:
index a637f99..10b1e6d 100644 (file)
@@ -1,5 +1,5 @@
-/* $Id: attribute.c,v 1.22 2006-05-10 08:13:20 adam Exp $
-   Copyright (C) 1995-2005
+/* $Id: attribute.c,v 1.23 2006-05-19 13:49:34 adam Exp $
+   Copyright (C) 1995-2006
    Index Data ApS
 
 This file is part of the Zebra server.
    Index Data ApS
 
 This file is part of the Zebra server.
@@ -23,30 +23,30 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <stdio.h>
 
 #include <yaz/log.h>
 #include <stdio.h>
 
 #include <yaz/log.h>
+#include <yaz/diagbib1.h>
 #include <idzebra/res.h>
 #include <idzebra/util.h>
 #include <idzebra/res.h>
 #include <idzebra/util.h>
+#include <attrfind.h>
 #include "index.h"
 
 #include "index.h"
 
-static data1_att *getatt(data1_attset *p, int att, const char *sattr)
+static data1_att *getatt(data1_attset *p, int att)
 {
     data1_att *a;
     data1_attset_child *c;
 
     /* scan local set */
     for (a = p->atts; a; a = a->next)
 {
     data1_att *a;
     data1_attset_child *c;
 
     /* scan local set */
     for (a = p->atts; a; a = a->next)
-       if (sattr && !yaz_matchstr(sattr, a->name))
-           return a;
-       else if (a->value == att)
+       if (a->value == att)
            return a;
     /* scan included sets */
     for (c = p->children; c; c = c->next)
            return a;
     /* scan included sets */
     for (c = p->children; c; c = c->next)
-       if ((a = getatt(c->child, att, sattr)))
+       if ((a = getatt(c->child, att)))
            return a;
     return 0;
 }
 
            return a;
     return 0;
 }
 
-int att_getentbyatt(ZebraHandle zi, attent *res, oid_value set, int att,
-               const char *sattr)
+static int att_getentbyatt(ZebraHandle zi, oid_value set, int att,
+                           const char **name)
 {
     data1_att *r;
     data1_attset *p;
 {
     data1_att *r;
     data1_attset *p;
@@ -57,18 +57,120 @@ int att_getentbyatt(ZebraHandle zi, attent *res, oid_value set, int att,
        p = data1_attset_search_id (zi->reg->dh, set);
     }
     if (!p)   /* set undefined */
        p = data1_attset_search_id (zi->reg->dh, set);
     }
     if (!p)   /* set undefined */
-    {
-       if (sattr)     
-           return -1; /* return bad string attribute */
-       else
-           return -2; /* return bad set */
-    }
-    if (!(r = getatt(p, att, sattr)))
+        return -2;
+    if (!(r = getatt(p, att)))
        return -1;
        return -1;
-    res->attset_ordinal = r->parent->reference;
-    res->local_attributes = r->locals;
+    *name = r->name;
     return 0;
 }
     return 0;
 }
+
+
+ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh,
+                                  Z_AttributeList *attr_list,
+                                  int index_type,
+                                  oid_value curAttributeSet,
+                                  int *ord)
+{
+    int use_value = -1;
+    const char *use_string = 0;
+    AttrType use;
+
+    attr_init_AttrList(&use, attr_list, 1);
+    use_value = attr_find_ex(&use, &curAttributeSet, &use_string);
+
+    if (use_value < 0)
+    {
+        if (!use_string)
+            use_string = "any";
+    }
+    else
+    {
+        /* we have a use attribute and attribute set */
+        int r;
+        
+        r = att_getentbyatt(zh, curAttributeSet, use_value, &use_string);
+        if (r == -2)
+        {
+            zebra_setError_zint(zh,  YAZ_BIB1_UNSUPP_ATTRIBUTE_SET, 0);
+            return ZEBRA_FAIL;
+        }
+        if (r == -1)
+        {
+            zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,  use_value);
+            return ZEBRA_FAIL;
+        }
+    }
+    if (!use_string)
+    {
+        zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 0);
+        return ZEBRA_FAIL;
+    }
+    *ord = zebraExplain_lookup_attr_str(zh->reg->zei, index_type, use_string);
+    if (*ord == -1)
+    {
+        if (use_value < 0)
+            zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_string);
+        else
+            zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_value);
+        return ZEBRA_FAIL;
+    }
+    return ZEBRA_OK;
+}
+
+ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh,
+                            Z_AttributesPlusTerm *zapt,
+                            int index_type,
+                            const char *xpath_use,
+                            oid_value curAttributeSet,
+                            int *ord)
+{
+    if (!xpath_use)
+        return zebra_attr_list_get_ord(zh, zapt->attributes,
+                                       index_type, curAttributeSet, ord);
+    else
+    {
+        *ord = zebraExplain_lookup_attr_str(zh->reg->zei, index_type,
+                                            xpath_use);
+        if (*ord == -1)
+        {
+            yaz_log(YLOG_LOG, "zebra_apt_get_ord FAILED xpath=%s index_type=%c",
+                    xpath_use, index_type);
+            zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 0);
+            return ZEBRA_FAIL;
+        }
+        else
+        {
+            yaz_log(YLOG_LOG, "zebra_apt_get_ord OK xpath=%s index_type=%c",
+                    xpath_use, index_type);
+        }
+        return ZEBRA_OK;
+    }
+}
+
+ZEBRA_RES zebra_sort_get_ord(ZebraHandle zh,
+                             Z_SortAttributes *sortAttributes,
+                             int *ord,
+                             int *numerical)
+{
+    AttrType structure;
+    int structure_value;
+    attr_init_AttrList(&structure, sortAttributes->list, 4);
+
+    *numerical = 0;
+    structure_value = attr_find(&structure, 0);
+    if (structure_value == 109)
+        *numerical = 1;
+    
+    if (zebra_attr_list_get_ord(zh, sortAttributes->list,
+                                's', VAL_BIB1, ord)== ZEBRA_OK)
+        return ZEBRA_OK;
+    if (zebra_attr_list_get_ord(zh, sortAttributes->list,
+                                'S', VAL_BIB1, ord)== ZEBRA_OK)
+        return ZEBRA_OK;
+    return ZEBRA_FAIL;
+}
+
+
 /*
  * Local variables:
  * c-basic-offset: 4
 /*
  * Local variables:
  * c-basic-offset: 4
index 86f868b..75bc9e0 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: extract.c,v 1.214 2006-05-18 12:03:05 adam Exp $
+/* $Id: extract.c,v 1.215 2006-05-19 13:49:34 adam Exp $
    Copyright (C) 1995-2006
    Index Data ApS
 
    Copyright (C) 1995-2006
    Index Data ApS
 
@@ -96,12 +96,7 @@ static void extract_init (struct recExtractCtrl *p, RecWord *w)
 {
     w->zebra_maps = p->zebra_maps;
     w->seqno = 1;
 {
     w->zebra_maps = p->zebra_maps;
     w->seqno = 1;
-#if NATTR
-#else
-    w->attrSet = VAL_BIB1;
-    w->attrUse = 1016;
-#endif
-    w->index_name = 0;
+    w->index_name = "any";
     w->index_type = 'w';
     w->extractCtrl = p;
     w->record_id = 0;
     w->index_type = 'w';
     w->extractCtrl = p;
     w->record_id = 0;
@@ -110,17 +105,22 @@ static void extract_init (struct recExtractCtrl *p, RecWord *w)
 
 static void searchRecordKey(ZebraHandle zh,
                            zebra_rec_keys_t reckeys,
 
 static void searchRecordKey(ZebraHandle zh,
                            zebra_rec_keys_t reckeys,
-                           int attrSetS, int attrUseS,
+                            const char *index_name,
                            const char **ws, int ws_length)
 {
     int i;
                            const char **ws, int ws_length)
 {
     int i;
-    int ch;
+    int ch = -1;
 
     for (i = 0; i<ws_length; i++)
         ws[i] = NULL;
 
 
     for (i = 0; i<ws_length; i++)
         ws[i] = NULL;
 
-    ch = zebraExplain_lookup_attr_su_any_index(zh->reg->zei,
-                                              attrSetS, attrUseS);
+    if (ch < 0)
+        ch = zebraExplain_lookup_attr_str(zh->reg->zei, '0', index_name);
+    if (ch < 0)
+        ch = zebraExplain_lookup_attr_str(zh->reg->zei, 'p', index_name);
+    if (ch < 0)
+        ch = zebraExplain_lookup_attr_str(zh->reg->zei, 'w', index_name);
+
     if (ch < 0)
        return ;
 
     if (ch < 0)
        return ;
 
@@ -236,9 +236,7 @@ static char *fileMatchStr (ZebraHandle zh,
         {
            const char *ws[32];
            char attset_str[64], attname_str[64];
         {
            const char *ws[32];
            char attset_str[64], attname_str[64];
-           data1_attset *attset;
            int i;
            int i;
-            int attSet = 1, attUse = 1;
             int first = 1;
            
            for (s++; strchr(FILE_MATCH_BLANK, *s); s++)
             int first = 1;
            
            for (s++; strchr(FILE_MATCH_BLANK, *s); s++)
@@ -251,7 +249,9 @@ static char *fileMatchStr (ZebraHandle zh,
            
            for (; strchr(FILE_MATCH_BLANK, *s); s++)
                ;
            
            for (; strchr(FILE_MATCH_BLANK, *s); s++)
                ;
-           if (*s == ',')
+           if (*s != ',')
+                strcpy(attname_str, attset_str);
+            else
            {
                for (s++; strchr(FILE_MATCH_BLANK, *s); s++)
                    ;
            {
                for (s++; strchr(FILE_MATCH_BLANK, *s); s++)
                    ;
@@ -261,18 +261,8 @@ static char *fileMatchStr (ZebraHandle zh,
                        attname_str[i++] = *s;
                attname_str[i] = '\0';
            }
                        attname_str[i++] = *s;
                attname_str[i] = '\0';
            }
-           
-           if ((attset = data1_get_attset (zh->reg->dh, attset_str)))
-           {
-               data1_att *att;
-               attSet = attset->reference;
-               att = data1_getattbyname(zh->reg->dh, attset, attname_str);
-               if (att)
-                   attUse = att->value;
-               else
-                   attUse = atoi (attname_str);
-           }
-            searchRecordKey (zh, reckeys, attSet, attUse, ws, 32);
+
+            searchRecordKey (zh, reckeys, attname_str, ws, 32);
 
             if (*s != ')')
             {
 
             if (*s != ')')
             {
@@ -1621,24 +1611,13 @@ void extract_add_index_string(RecWord *p, const char *str, int length)
     ZebraExplainInfo zei = zh->reg->zei;
     int ch;
 
     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
-    {
-#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->index_type,
-                                         p->attrSet, p->attrUse);
-#endif
-    }
+    if (!p->index_name)
+        return;
+
+    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);
+
     key.len = 4;
     key.mem[0] = ch;
     key.mem[1] = p->record_id;
     key.len = 4;
     key.mem[0] = ch;
     key.mem[1] = p->record_id;
@@ -1673,24 +1652,12 @@ static void extract_add_sort_string(RecWord *p, const char *str, int length)
     ZebraExplainInfo zei = zh->reg->zei;
     int ch;
 
     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
-    {
-#if NATTR
-       return;
-#else
-       ch = zebraExplain_lookup_attr_su(zei, p->index_type, 
-                                         VAL_IDXPATH, p->attrUse);
-       if (ch < 0)
-           ch = zebraExplain_add_attr_su(zei, p->index_type,
-                                         VAL_IDXPATH, p->attrUse);
-#endif
-    }
+    if (!p->index_name)
+        return;
+
+    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);
     key.len = 4;
     key.mem[0] = ch;
     key.mem[1] = p->record_id;
     key.len = 4;
     key.mem[0] = ch;
     key.mem[1] = p->record_id;
index 6ffa33e..d06d36d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: index.h,v 1.161 2006-05-18 12:03:05 adam Exp $
+/* $Id: index.h,v 1.162 2006-05-19 13:49:34 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -363,14 +363,13 @@ int zebra_server_lock (ZebraService zh, int lockCommit);
 void zebra_server_unlock (ZebraService zh, int commitPhase);
 int zebra_server_lock_get_state (ZebraService zh, time_t *timep);
 
 void zebra_server_unlock (ZebraService zh, int commitPhase);
 int zebra_server_lock_get_state (ZebraService zh, time_t *timep);
 
+#if 1
 typedef struct attent
 {
     int attset_ordinal;
     data1_local_attribute *local_attributes;
 } attent;
 typedef struct attent
 {
     int attset_ordinal;
     data1_local_attribute *local_attributes;
 } attent;
-
-int att_getentbyatt(ZebraHandle zh, attent *res, oid_value set, int att,
-               const char *sattr);
+#endif
 
 int zebra_record_fetch (ZebraHandle zh, SYSNO sysno, int score, 
                        zebra_snippets *hit_snippet, ODR stream,
 
 int zebra_record_fetch (ZebraHandle zh, SYSNO sysno, int score, 
                        zebra_snippets *hit_snippet, ODR stream,
@@ -468,6 +467,24 @@ ZEBRA_RES zebra_get_hit_vector(ZebraHandle zh, const char *setname, zint sysno);
 void zebra_term_untrans(ZebraHandle zh, int reg_type,
                        char *dst, const char *src);
 
 void zebra_term_untrans(ZebraHandle zh, int reg_type,
                        char *dst, const char *src);
 
+ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh,
+                            Z_AttributesPlusTerm *zapt,
+                            int index_type,
+                            const char *xpath_use,
+                            oid_value curAttributeSet,
+                            int *ord);
+
+ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh,
+                                  Z_AttributeList *attr_list,
+                                  int index_type,
+                                  oid_value curAttributeSet,
+                                  int *ord);
+
+ZEBRA_RES zebra_sort_get_ord(ZebraHandle zh,
+                             Z_SortAttributes *sortAttributes,
+                             int *ord,
+                             int *numerical);
+
 YAZ_END_CDECL
 
 #endif
 YAZ_END_CDECL
 
 #endif
index e1f6ede..978ec6f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebrash.c,v 1.37 2006-05-10 08:13:23 adam Exp $
+/* $Id: zebrash.c,v 1.38 2006-05-19 13:49:34 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -365,7 +365,7 @@ static int cmd_record_insert( char *args[], WRBUF outbuff)
                             0);
     if (0==rc)
     {
                             0);
     if (0==rc)
     {
-        wrbuf_printf(outbuff,"ok sysno=%d\n",sysno);
+        wrbuf_printf(outbuff,"ok sysno=" ZINT_FORMAT "\n",sysno);
     }
     return rc;
 }
     }
     return rc;
 }
index f19a068..3d2aee8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zinfo.c,v 1.63 2006-05-18 12:03:05 adam Exp $
+/* $Id: zinfo.c,v 1.64 2006-05-19 13:49:34 adam Exp $
    Copyright (C) 1995-2006
    Index Data ApS
 
    Copyright (C) 1995-2006
    Index Data ApS
 
@@ -1491,7 +1491,7 @@ int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, int index_type,
         *zsui; zsui = &(*zsui)->next)
         if ((*zsui)->info.index_type == index_type
             && (*zsui)->info.which == ZEB_SU_STR 
         *zsui; zsui = &(*zsui)->next)
         if ((*zsui)->info.index_type == index_type
             && (*zsui)->info.which == ZEB_SU_STR 
-            && !strcmp((*zsui)->info.u.str, str))
+            && !yaz_matchstr((*zsui)->info.u.str, str))
         {
             struct zebSUInfoB *zsui_this = *zsui;
 
         {
             struct zebSUInfoB *zsui_this = *zsui;
 
@@ -1700,6 +1700,7 @@ int zebraExplain_add_attr_su(ZebraExplainInfo zei, int index_type,
 {
     struct zebSUInfoB *zsui = zebraExplain_add_sui_info(zei, index_type);
 
 {
     struct zebSUInfoB *zsui = zebraExplain_add_sui_info(zei, index_type);
 
+    yaz_log(YLOG_WARN, "add_attr_su");
     zebraExplain_addAttributeSet (zei, set);
     zsui->info.which = ZEB_SU_SET_USE;
     zsui->info.u.su.set = set;
     zebraExplain_addAttributeSet (zei, set);
     zsui->info.which = ZEB_SU_SET_USE;
     zsui->info.u.su.set = set;
index f7ff740..f5da395 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zrpn.c,v 1.213 2006-05-17 17:46:45 adam Exp $
+/* $Id: zrpn.c,v 1.214 2006-05-19 13:49:34 adam Exp $
    Copyright (C) 1995-2006
    Index Data ApS
 
    Copyright (C) 1995-2006
    Index Data ApS
 
@@ -33,7 +33,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <yaz/diagbib1.h>
 #include "index.h"
 #include <zebra_xpath.h>
 #include <yaz/diagbib1.h>
 #include "index.h"
 #include <zebra_xpath.h>
-
+#include <attrfind.h>
 #include <charmap.h>
 #include <rset.h>
 
 #include <charmap.h>
 #include <rset.h>
 
@@ -43,14 +43,6 @@ struct rpn_char_map_info
     int reg_type;
 };
 
     int reg_type;
 };
 
-typedef struct
-{
-    int type;
-    int major;
-    int minor;
-    Z_AttributesPlusTerm *zapt;
-} AttrType;
-
 static int log_level_set = 0;
 static int log_level_rpn = 0;
 
 static int log_level_set = 0;
 static int log_level_rpn = 0;
 
@@ -81,84 +73,6 @@ static void rpn_char_map_prepare(struct zebra_register *reg, int reg_type,
     dict_grep_cmap(reg->dict, map_info, rpn_char_map_handler);
 }
 
     dict_grep_cmap(reg->dict, map_info, rpn_char_map_handler);
 }
 
-static int attr_find_ex(AttrType *src, oid_value *attributeSetP,
-                       const char **string_value)
-{
-    int num_attributes;
-
-    num_attributes = src->zapt->attributes->num_attributes;
-    while (src->major < num_attributes)
-    {
-        Z_AttributeElement *element;
-
-        element = src->zapt->attributes->attributes[src->major];
-        if (src->type == *element->attributeType)
-        {
-            switch (element->which) 
-            {
-            case Z_AttributeValue_numeric:
-                ++(src->major);
-                if (element->attributeSet && attributeSetP)
-                {
-                    oident *attrset;
-
-                    attrset = oid_getentbyoid(element->attributeSet);
-                    *attributeSetP = attrset->value;
-                }
-                return *element->value.numeric;
-                break;
-            case Z_AttributeValue_complex:
-                if (src->minor >= element->value.complex->num_list)
-                    break;
-                if (element->attributeSet && attributeSetP)
-                {
-                    oident *attrset;
-                    
-                    attrset = oid_getentbyoid(element->attributeSet);
-                    *attributeSetP = attrset->value;
-                }
-                if (element->value.complex->list[src->minor]->which ==  
-                    Z_StringOrNumeric_numeric)
-                {
-                    ++(src->minor);
-                    return
-                        *element->value.complex->list[src->minor-1]->u.numeric;
-                }
-                else if (element->value.complex->list[src->minor]->which ==  
-                         Z_StringOrNumeric_string)
-                {
-                    if (!string_value)
-                        break;
-                    ++(src->minor);
-                    *string_value = 
-                        element->value.complex->list[src->minor-1]->u.string;
-                    return -2;
-                }
-                else
-                    break;
-            default:
-                assert(0);
-            }
-        }
-        ++(src->major);
-    }
-    return -1;
-}
-
-static int attr_find(AttrType *src, oid_value *attributeSetP)
-{
-    return attr_find_ex(src, attributeSetP, 0);
-}
-
-static void attr_init(AttrType *src, Z_AttributesPlusTerm *zapt,
-                       int type)
-{
-    src->zapt = zapt;
-    src->type = type;
-    src->major = 0;
-    src->minor = 0;
-}
-
 #define TERM_COUNT        
        
 struct grep_info {        
 #define TERM_COUNT        
        
 struct grep_info {        
@@ -820,7 +734,7 @@ static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     char *term_tmp = term_dict + strlen(term_dict);
     char term_component[2*IT_MAX_WORD+20];
 
     char *term_tmp = term_dict + strlen(term_dict);
     char term_component[2*IT_MAX_WORD+20];
 
-    attr_init(&relation, zapt, 2);
+    attr_init_APT(&relation, zapt, 2);
     relation_value = attr_find(&relation, NULL);
 
     *error_code = 0;
     relation_value = attr_find(&relation, NULL);
 
     *error_code = 0;
@@ -994,7 +908,8 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                             struct grep_info *grep_info,
                             int reg_type, int complete_flag,
                             int num_bases, char **basenames,
                             struct grep_info *grep_info,
                             int reg_type, int complete_flag,
                             int num_bases, char **basenames,
-                            char *term_dst, int xpath_use,
+                            char *term_dst,
+                             const char *xpath_use,
                             struct ord_list **ol);
 
 static ZEBRA_RES term_limits_APT(ZebraHandle zh,
                             struct ord_list **ol);
 
 static ZEBRA_RES term_limits_APT(ZebraHandle zh,
@@ -1007,10 +922,10 @@ static ZEBRA_RES term_limits_APT(ZebraHandle zh,
     AttrType hits_limit_attr;
     int term_ref_id_int;
  
     AttrType hits_limit_attr;
     int term_ref_id_int;
  
-    attr_init(&hits_limit_attr, zapt, 9);
+    attr_init_APT(&hits_limit_attr, zapt, 9);
     *hits_limit_value  = attr_find(&hits_limit_attr, NULL);
 
     *hits_limit_value  = attr_find(&hits_limit_attr, NULL);
 
-    attr_init(&term_ref_id_attr, zapt, 10);
+    attr_init_APT(&term_ref_id_attr, zapt, 10);
     term_ref_id_int = attr_find_ex(&term_ref_id_attr, NULL, term_ref_id_str);
     if (term_ref_id_int >= 0)
     {
     term_ref_id_int = attr_find_ex(&term_ref_id_attr, NULL, term_ref_id_str);
     if (term_ref_id_int >= 0)
     {
@@ -1052,7 +967,8 @@ static ZEBRA_RES term_trunc(ZebraHandle zh,
                            int reg_type, int complete_flag,
                            int num_bases, char **basenames,
                            char *term_dst,
                            int reg_type, int complete_flag,
                            int num_bases, char **basenames,
                            char *term_dst,
-                           const char *rank_type, int xpath_use,
+                           const char *rank_type, 
+                            const char *xpath_use,
                            NMEM rset_nmem,
                            RSET *rset,
                            struct rset_key_control *kc)
                            NMEM rset_nmem,
                            RSET *rset,
                            struct rset_key_control *kc)
@@ -1091,16 +1007,14 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                             struct grep_info *grep_info,
                             int reg_type, int complete_flag,
                             int num_bases, char **basenames,
                             struct grep_info *grep_info,
                             int reg_type, int complete_flag,
                             int num_bases, char **basenames,
-                            char *term_dst, int xpath_use,
+                            char *term_dst,
+                             const char *xpath_use,
                             struct ord_list **ol)
 {
     char term_dict[2*IT_MAX_WORD+4000];
     int j, r, base_no;
     AttrType truncation;
     int truncation_value;
                             struct ord_list **ol)
 {
     char term_dict[2*IT_MAX_WORD+4000];
     int j, r, base_no;
     AttrType truncation;
     int truncation_value;
-    AttrType use;
-    int use_value;
-    const char *use_string = 0;
     oid_value curAttributeSet = attributeSet;
     const char *termp;
     struct rpn_char_map_info rcmi;
     oid_value curAttributeSet = attributeSet;
     const char *termp;
     struct rpn_char_map_info rcmi;
@@ -1111,26 +1025,25 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     *ol = ord_list_create(stream);
 
     rpn_char_map_prepare (zh->reg, reg_type, &rcmi);
     *ol = ord_list_create(stream);
 
     rpn_char_map_prepare (zh->reg, reg_type, &rcmi);
-    attr_init(&use, zapt, 1);
-    use_value = attr_find_ex(&use, &curAttributeSet, &use_string);
-    yaz_log(log_level_rpn, "string_term, use value %d", use_value);
-    attr_init(&truncation, zapt, 5);
+    attr_init_APT(&truncation, zapt, 5);
     truncation_value = attr_find(&truncation, NULL);
     yaz_log(log_level_rpn, "truncation value %d", truncation_value);
 
     truncation_value = attr_find(&truncation, NULL);
     yaz_log(log_level_rpn, "truncation value %d", truncation_value);
 
-    if (use_value == -1)    /* no attribute - assumy "any" */
-        use_value = 1016;
     for (base_no = 0; base_no < num_bases; base_no++)
     {
        int ord = -1;
        int attr_ok = 0;
        int regex_range = 0;
        int init_pos = 0;
     for (base_no = 0; base_no < num_bases; base_no++)
     {
        int ord = -1;
        int attr_ok = 0;
        int regex_range = 0;
        int init_pos = 0;
+#if 0
         attent attp;
         data1_local_attribute id_xpath_attr;
         data1_local_attribute *local_attr;
         attent attp;
         data1_local_attribute id_xpath_attr;
         data1_local_attribute *local_attr;
+#endif
         int max_pos, prefix_len = 0;
        int relation_error;
         int max_pos, prefix_len = 0;
        int relation_error;
+        char ord_buf[32];
+        int ord_len, i;
 
         termp = *term_sub;
 
 
         termp = *term_sub;
 
@@ -1140,111 +1053,29 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                           basenames[base_no]);
             return ZEBRA_FAIL;
         }
                           basenames[base_no]);
             return ZEBRA_FAIL;
         }
-        if (xpath_use > 0 && use_value == -2) 
-        {
-           /* xpath mode and we have a string attribute */
-            attp.local_attributes = &id_xpath_attr;
-            attp.attset_ordinal = VAL_IDXPATH;
-            id_xpath_attr.next = 0;
-
-            use_value = xpath_use;  /* xpath_use as use-attribute now */
-            id_xpath_attr.local = use_value;
-        }
-        else if (curAttributeSet == VAL_IDXPATH && use_value >= 0)
+        
+        if (zebra_apt_get_ord(zh, zapt, reg_type, xpath_use, 
+                              curAttributeSet, &ord) 
+            != ZEBRA_OK)
         {
         {
-           /* X-Path attribute, use numeric value directly */
-            attp.local_attributes = &id_xpath_attr;
-            attp.attset_ordinal = VAL_IDXPATH;
-            id_xpath_attr.next = 0;
-            id_xpath_attr.local = use_value;
+            break;
         }
         }
-       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 */
-            char ord_buf[32];
-            int i, ord_len;
-
-            if (prefix_len)
-                term_dict[prefix_len++] = '|';
-            else
-                term_dict[prefix_len++] = '(';
-            
-            ord_len = key_SU_encode (ord, ord_buf);
-            for (i = 0; i<ord_len; i++)
-            {
-                term_dict[prefix_len++] = 1;
-                term_dict[prefix_len++] = ord_buf[i];
-            }
-            attp.local_attributes = 0;  /* no more attributes */
-           *ol = ord_list_append(stream, *ol, ord);
-       }
-        else 
+        *ol = ord_list_append(stream, *ol, ord);
+        
+        if (prefix_len)
+            term_dict[prefix_len++] = '|';
+        else
+            term_dict[prefix_len++] = '(';
+        
+        ord_len = key_SU_encode (ord, ord_buf);
+        for (i = 0; i<ord_len; i++)
         {
         {
-           /* lookup in the .att files . Allow string as well */
-            if ((r = att_getentbyatt (zh, &attp, curAttributeSet, use_value,
-                                     use_string)))
-            {
-                yaz_log(YLOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d",
-                       curAttributeSet, use_value, r);
-                if (r == -1)
-                {
-                    /* set was found, but value wasn't defined */
-                    if (use_string)
-                       zebra_setError(zh, 
-                                      YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,
-                                      use_string);
-                    else
-                       zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 
-                                           use_value);
-                }
-                else
-                {
-                    int oid[OID_SIZE];
-                    struct oident oident;
-                    
-                    oident.proto = PROTO_Z3950;
-                    oident.oclass = CLASS_ATTSET;
-                    oident.value = curAttributeSet;
-                    oid_ent_to_oid (&oident, oid);
-                    
-                   zebra_setError(zh, 
-                                  YAZ_BIB1_UNSUPP_ATTRIBUTE_SET,
-                                  oident.desc);
-                   
-                }
-                continue;
-            }
-        }
-       for (local_attr = attp.local_attributes; local_attr;
-            local_attr = local_attr->next)
-       {
-           char ord_buf[32];
-           int i, ord_len;
-           
-           ord = zebraExplain_lookup_attr_su(zh->reg->zei,
-                                             reg_type,
-                                             attp.attset_ordinal,
-                                             local_attr->local);
-           if (ord < 0)
-               continue;
-           *ol = ord_list_append(stream, *ol, ord);
-           if (prefix_len)
-               term_dict[prefix_len++] = '|';
-           else
-               term_dict[prefix_len++] = '(';
-           
-           ord_len = key_SU_encode (ord, ord_buf);
-           for (i = 0; i<ord_len; i++)
-           {
-               term_dict[prefix_len++] = 1;
+            term_dict[prefix_len++] = 1;
                term_dict[prefix_len++] = ord_buf[i];
                term_dict[prefix_len++] = ord_buf[i];
-           }
-           if (ord_len > init_pos)
-               init_pos = ord_len;
-       }
+        }
+        if (ord_len > init_pos)
+            init_pos = ord_len;
+        
        bases_ok++;
         if (prefix_len)
            attr_ok = 1;
        bases_ok++;
         if (prefix_len)
            attr_ok = 1;
@@ -1512,7 +1343,7 @@ static ZEBRA_RES grep_info_prepare(ZebraHandle zh,
 
     if (!zapt)
         return ZEBRA_OK;
 
     if (!zapt)
         return ZEBRA_OK;
-    attr_init(&termset, zapt, 8);
+    attr_init_APT(&termset, zapt, 8);
     termset_value_numeric =
         attr_find_ex(&termset, NULL, &termset_value_string);
     if (termset_value_numeric != -1)
     termset_value_numeric =
         attr_find_ex(&termset, NULL, &termset_value_string);
     if (termset_value_numeric != -1)
@@ -1561,7 +1392,8 @@ static ZEBRA_RES term_list_trunc(ZebraHandle zh,
                                 oid_value attributeSet,
                                 NMEM stream,
                                 int reg_type, int complete_flag,
                                 oid_value attributeSet,
                                 NMEM stream,
                                 int reg_type, int complete_flag,
-                                const char *rank_type, int xpath_use,
+                                const char *rank_type,
+                                 const char *xpath_use,
                                 int num_bases, char **basenames, 
                                 NMEM rset_nmem,
                                 RSET **result_sets, int *num_result_sets,
                                 int num_bases, char **basenames, 
                                 NMEM rset_nmem,
                                 RSET **result_sets, int *num_result_sets,
@@ -1627,7 +1459,8 @@ static ZEBRA_RES rpn_search_APT_phrase(ZebraHandle zh,
                                       oid_value attributeSet,
                                       NMEM stream,
                                       int reg_type, int complete_flag,
                                       oid_value attributeSet,
                                       NMEM stream,
                                       int reg_type, int complete_flag,
-                                      const char *rank_type, int xpath_use,
+                                      const char *rank_type,
+                                       const char *xpath_use,
                                       int num_bases, char **basenames, 
                                       NMEM rset_nmem,
                                       RSET *rset,
                                       int num_bases, char **basenames, 
                                       NMEM rset_nmem,
                                       RSET *rset,
@@ -1665,7 +1498,7 @@ static ZEBRA_RES rpn_search_APT_or_list(ZebraHandle zh,
                                        NMEM stream,
                                        int reg_type, int complete_flag,
                                        const char *rank_type,
                                        NMEM stream,
                                        int reg_type, int complete_flag,
                                        const char *rank_type,
-                                       int xpath_use,
+                                        const char *xpath_use,
                                        int num_bases, char **basenames,
                                        NMEM rset_nmem,
                                        RSET *rset,
                                        int num_bases, char **basenames,
                                        NMEM rset_nmem,
                                        RSET *rset,
@@ -1701,7 +1534,7 @@ static ZEBRA_RES rpn_search_APT_and_list(ZebraHandle zh,
                                         NMEM stream,
                                         int reg_type, int complete_flag,
                                         const char *rank_type, 
                                         NMEM stream,
                                         int reg_type, int complete_flag,
                                         const char *rank_type, 
-                                        int xpath_use,
+                                         const char *xpath_use,
                                         int num_bases, char **basenames,
                                         NMEM rset_nmem,
                                         RSET *rset,
                                         int num_bases, char **basenames,
                                         NMEM rset_nmem,
                                         RSET *rset,
@@ -1748,7 +1581,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     char *term_tmp = term_dict + strlen(term_dict);
 
     *error_code = 0;
     char *term_tmp = term_dict + strlen(term_dict);
 
     *error_code = 0;
-    attr_init(&relation, zapt, 2);
+    attr_init_APT(&relation, zapt, 2);
     relation_value = attr_find(&relation, NULL);
 
     yaz_log(log_level_rpn, "numeric relation value=%d", relation_value);
     relation_value = attr_find(&relation, NULL);
 
     yaz_log(log_level_rpn, "numeric relation value=%d", relation_value);
@@ -1799,13 +1632,12 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                              struct grep_info *grep_info,
                              int reg_type, int complete_flag,
                              int num_bases, char **basenames,
                              struct grep_info *grep_info,
                              int reg_type, int complete_flag,
                              int num_bases, char **basenames,
-                             char *term_dst, int xpath_use, NMEM stream)
+                             char *term_dst, 
+                              const char *xpath_use,
+                              NMEM stream)
 {
     char term_dict[2*IT_MAX_WORD+2];
 {
     char term_dict[2*IT_MAX_WORD+2];
-    int r, base_no;
-    AttrType use;
-    int use_value;
-    const char *use_string = 0;
+    int base_no;
     oid_value curAttributeSet = attributeSet;
     const char *termp;
     struct rpn_char_map_info rcmi;
     oid_value curAttributeSet = attributeSet;
     const char *termp;
     struct rpn_char_map_info rcmi;
@@ -1813,93 +1645,40 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     int bases_ok = 0;     /* no of databases with OK attribute */
 
     rpn_char_map_prepare (zh->reg, reg_type, &rcmi);
     int bases_ok = 0;     /* no of databases with OK attribute */
 
     rpn_char_map_prepare (zh->reg, reg_type, &rcmi);
-    attr_init(&use, zapt, 1);
-    use_value = attr_find_ex(&use, &curAttributeSet, &use_string);
-
-    if (use_value == -1)
-        use_value = 1016;
 
     for (base_no = 0; base_no < num_bases; base_no++)
     {
 
     for (base_no = 0; base_no < num_bases; base_no++)
     {
-        attent attp;
-        data1_local_attribute id_xpath_attr;
-        data1_local_attribute *local_attr;
         int max_pos, prefix_len = 0;
        int relation_error = 0;
         int max_pos, prefix_len = 0;
        int relation_error = 0;
+        int ord, ord_len, i;
+        char ord_buf[32];
 
         termp = *term_sub;
 
         termp = *term_sub;
-        if (use_value == -2)  /* string attribute (assume IDXPATH/any) */
-        {
-            use_value = xpath_use;
-            attp.local_attributes = &id_xpath_attr;
-            attp.attset_ordinal = VAL_IDXPATH;
-            id_xpath_attr.next = 0;
-            id_xpath_attr.local = use_value;
-        }
-        else if (curAttributeSet == VAL_IDXPATH)
-        {
-            attp.local_attributes = &id_xpath_attr;
-            attp.attset_ordinal = VAL_IDXPATH;
-            id_xpath_attr.next = 0;
-            id_xpath_attr.local = use_value;
-        }
-        else
-        {
-            if ((r = att_getentbyatt (zh, &attp, curAttributeSet, use_value,
-                                     use_string)))
-            {
-                yaz_log(YLOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d",
-                      curAttributeSet, use_value, r);
-                if (r == -1)
-                {
-                    if (use_string)
-                       zebra_setError(zh, 
-                                      YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,
-                                      use_string);
-                    else
-                       zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 
-                                           use_value);
-                }
-                else
-                   zebra_setError(zh, YAZ_BIB1_UNSUPP_ATTRIBUTE_SET, 0);
-                continue;
-            }
-        }
+
         if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no]))
         {
            zebra_setError(zh, YAZ_BIB1_DATABASE_UNAVAILABLE,
                           basenames[base_no]);
             return ZEBRA_FAIL;
         }
         if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no]))
         {
            zebra_setError(zh, YAZ_BIB1_DATABASE_UNAVAILABLE,
                           basenames[base_no]);
             return ZEBRA_FAIL;
         }
-        for (local_attr = attp.local_attributes; local_attr;
-             local_attr = local_attr->next)
-        {
-            int ord;
-            char ord_buf[32];
-            int i, ord_len;
-
-            ord = zebraExplain_lookup_attr_su(zh->reg->zei,
-                                             reg_type,
-                                             attp.attset_ordinal,
-                                             local_attr->local);
-            if (ord < 0)
-                continue;
-            if (prefix_len)
-                term_dict[prefix_len++] = '|';
-            else
-                term_dict[prefix_len++] = '(';
 
 
-            ord_len = key_SU_encode (ord, ord_buf);
-            for (i = 0; i<ord_len; i++)
-            {
-                term_dict[prefix_len++] = 1;
-                term_dict[prefix_len++] = ord_buf[i];
-            }
+        if (zebra_apt_get_ord(zh, zapt, reg_type, xpath_use,
+                              curAttributeSet, &ord) 
+            != ZEBRA_OK)
+        {
+            break;
         }
         }
-        if (!prefix_len)
+
+        if (prefix_len)
+            term_dict[prefix_len++] = '|';
+        else
+            term_dict[prefix_len++] = '(';
+        
+        ord_len = key_SU_encode (ord, ord_buf);
+        for (i = 0; i < ord_len; i++)
         {
         {
-           zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, use_value);
-            continue;
+            term_dict[prefix_len++] = 1;
+               term_dict[prefix_len++] = ord_buf[i];
         }
         bases_ok++;
         term_dict[prefix_len++] = ')';
         }
         bases_ok++;
         term_dict[prefix_len++] = ')';
@@ -1931,7 +1710,8 @@ static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh,
                                        oid_value attributeSet,
                                        NMEM stream,
                                        int reg_type, int complete_flag,
                                        oid_value attributeSet,
                                        NMEM stream,
                                        int reg_type, int complete_flag,
-                                       const char *rank_type, int xpath_use,
+                                       const char *rank_type, 
+                                        const char *xpath_use,
                                        int num_bases, char **basenames,
                                        NMEM rset_nmem,
                                        RSET *rset,
                                        int num_bases, char **basenames,
                                        NMEM rset_nmem,
                                        RSET *rset,
@@ -2050,7 +1830,7 @@ static ZEBRA_RES rpn_sort_spec(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     oident oe;
     char termz[20];
     
     oident oe;
     char termz[20];
     
-    attr_init(&sort_relation_type, zapt, 7);
+    attr_init_APT(&sort_relation_type, zapt, 7);
     sort_relation_value = attr_find(&sort_relation_type, &attributeSet);
 
     if (!sort_sequence->specs)
     sort_relation_value = attr_find(&sort_relation_type, &attributeSet);
 
     if (!sort_sequence->specs)
@@ -2119,7 +1899,7 @@ static int parse_xpath(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     AttrType use;
     const char *use_string = 0;
     
     AttrType use;
     const char *use_string = 0;
     
-    attr_init(&use, zapt, 1);
+    attr_init_APT(&use, zapt, 1);
     attr_find_ex(&use, &curAttributeSet, &use_string);
 
     if (!use_string || *use_string != '/')
     attr_find_ex(&use, &curAttributeSet, &use_string);
 
     if (!use_string || *use_string != '/')
@@ -2131,7 +1911,8 @@ static int parse_xpath(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
                
 
 static RSET xpath_trunc(ZebraHandle zh, NMEM stream,
                
 
 static RSET xpath_trunc(ZebraHandle zh, NMEM stream,
-                        int reg_type, const char *term, int use,
+                        int reg_type, const char *term, 
+                        const char *xpath_use,
                         oid_value curAttributeSet, NMEM rset_nmem,
                        struct rset_key_control *kc)
 {
                         oid_value curAttributeSet, NMEM rset_nmem,
                        struct rset_key_control *kc)
 {
@@ -2140,8 +1921,8 @@ static RSET xpath_trunc(ZebraHandle zh, NMEM stream,
     char term_dict[2048];
     char ord_buf[32];
     int prefix_len = 0;
     char term_dict[2048];
     char ord_buf[32];
     int prefix_len = 0;
-    int ord = zebraExplain_lookup_attr_su(zh->reg->zei, reg_type,
-                                         curAttributeSet, use);
+    int ord = zebraExplain_lookup_attr_str(zh->reg->zei, reg_type,
+                                           xpath_use);
     int ord_len, i, r, max_pos;
     int term_type = Z_Term_characterString;
     const char *flags = "void";
     int ord_len, i, r, max_pos;
     int term_type = Z_Term_characterString;
     const char *flags = "void";
@@ -2300,7 +2081,7 @@ ZEBRA_RES rpn_search_xpath(ZebraHandle zh,
                 }
                 wrbuf_puts(wbuf, "");
                 rset_attr = xpath_trunc(
                 }
                 wrbuf_puts(wbuf, "");
                 rset_attr = xpath_trunc(
-                    zh, stream, '0', wrbuf_buf(wbuf), 3, 
+                    zh, stream, '0', wrbuf_buf(wbuf), ZEBRA_XPATH_ATTR_NAME, 
                     curAttributeSet, rset_nmem, kc);
                 wrbuf_free(wbuf, 1);
             } 
                     curAttributeSet, rset_nmem, kc);
                 wrbuf_free(wbuf, 1);
             } 
@@ -2313,10 +2094,16 @@ ZEBRA_RES rpn_search_xpath(ZebraHandle zh,
             if (strlen(xpath_rev))
             {
                 rset_start_tag = xpath_trunc(zh, stream, '0', 
             if (strlen(xpath_rev))
             {
                 rset_start_tag = xpath_trunc(zh, stream, '0', 
-                        xpath_rev, 1, curAttributeSet, rset_nmem, kc);
+                                             xpath_rev, 
+                                             ZEBRA_XPATH_ELM_BEGIN, 
+                                             curAttributeSet,
+                                             rset_nmem, kc);
             
                 rset_end_tag = xpath_trunc(zh, stream, '0', 
             
                 rset_end_tag = xpath_trunc(zh, stream, '0', 
-                        xpath_rev, 2, curAttributeSet, rset_nmem, kc);
+                                           xpath_rev, 
+                                           ZEBRA_XPATH_ELM_END, 
+                                           curAttributeSet,
+                                           rset_nmem, kc);
 
                 rset = rsbetween_create(rset_nmem, kc, kc->scope,
                                        rset_start_tag, rset,
 
                 rset = rsbetween_create(rset_nmem, kc, kc->scope,
                                        rset_start_tag, rset,
@@ -2345,7 +2132,7 @@ static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     int sort_flag;
     char termz[IT_MAX_WORD+1];
     int xpath_len;
     int sort_flag;
     char termz[IT_MAX_WORD+1];
     int xpath_len;
-    int xpath_use = 0;
+    const char *xpath_use = 0;
     struct xpath_location_step xpath[10];
 
     if (!log_level_set)
     struct xpath_location_step xpath[10];
 
     if (!log_level_set)
@@ -2371,9 +2158,10 @@ static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
     xpath_len = parse_xpath(zh, zapt, attributeSet, xpath, 10, stream);
     if (xpath_len >= 0)
     {
     xpath_len = parse_xpath(zh, zapt, attributeSet, xpath, 10, stream);
     if (xpath_len >= 0)
     {
-        xpath_use = 1016;  /* searching for element by default */
         if (xpath[xpath_len-1].part[0] == '@') 
         if (xpath[xpath_len-1].part[0] == '@') 
-            xpath_use = 1015;  /* last step an attribute .. */
+            xpath_use = ZEBRA_XPATH_ATTR_CDATA;  /* last step is attribute  */
+        else
+            xpath_use = ZEBRA_XPATH_CDATA;  /* searching for cdata */        
     }
 
     /* search using one of the various search type strategies
     }
 
     /* search using one of the various search type strategies
@@ -2772,7 +2560,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
     int errCode = 0;      /* err code (if any is not OK) */
     char *errString = 0;  /* addinfo */
 
     int errCode = 0;      /* err code (if any is not OK) */
     char *errString = 0;  /* addinfo */
 
-    unsigned reg_id;
+    unsigned index_type;
     char *search_type = NULL;
     char rank_type[128];
     int complete_flag;
     char *search_type = NULL;
     char rank_type[128];
     int complete_flag;
@@ -2791,7 +2579,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
         AttrType termset;
         int termset_value_numeric;
         const char *termset_value_string;
         AttrType termset;
         int termset_value_numeric;
         const char *termset_value_string;
-        attr_init(&termset, zapt, 8);
+        attr_init_APT(&termset, zapt, 8);
         termset_value_numeric =
             attr_find_ex(&termset, NULL, &termset_value_string);
         if (termset_value_numeric != -1)
         termset_value_numeric =
             attr_find_ex(&termset, NULL, &termset_value_string);
         if (termset_value_numeric != -1)
@@ -2815,10 +2603,10 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
     yaz_log(YLOG_DEBUG, "position = %d, num = %d set=%d",
            pos, num, attributeset);
         
     yaz_log(YLOG_DEBUG, "position = %d, num = %d set=%d",
            pos, num, attributeset);
         
-    attr_init(&use, zapt, 1);
+    attr_init_APT(&use, zapt, 1);
     use_value = attr_find_ex(&use, &attributeset, &use_string);
 
     use_value = attr_find_ex(&use, &attributeset, &use_string);
 
-    if (zebra_maps_attr(zh->reg->zebra_maps, zapt, &reg_id, &search_type,
+    if (zebra_maps_attr(zh->reg->zebra_maps, zapt, &index_type, &search_type,
                        rank_type, &complete_flag, &sort_flag))
     {
         *num_entries = 0;
                        rank_type, &complete_flag, &sort_flag))
     {
         *num_entries = 0;
@@ -2831,8 +2619,6 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
         use_value = 1016;
     for (base_no = 0; base_no < num_bases && ord_no < 32; base_no++)
     {
         use_value = 1016;
     for (base_no = 0; base_no < num_bases && ord_no < 32; base_no++)
     {
-       data1_local_attribute *local_attr;
-       attent attp;
        int ord;
 
        if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no]))
        int ord;
 
        if (zebraExplain_curDatabase (zh->reg->zei, basenames[base_no]))
@@ -2843,51 +2629,12 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
            return ZEBRA_FAIL;
        }
 
            return ZEBRA_FAIL;
        }
 
-       if (use_string &&
-           (ord = zebraExplain_lookup_attr_str(zh->reg->zei, reg_id,
-                                               use_string)) >= 0)
-       {
-           /* we have a match for a raw string attribute */
-           if (ord > 0)
-               ords[ord_no++] = ord;
-            attp.local_attributes = 0;  /* no more attributes */
-       }
-       else
-       {
-           int r;
-           
-           if ((r = att_getentbyatt (zh, &attp, attributeset, use_value,
-                                     use_string)))
-           {
-               yaz_log(YLOG_DEBUG, "att_getentbyatt fail. set=%d use=%d",
-                       attributeset, use_value);
-               if (r == -1)
-               {
-                   errCode = YAZ_BIB1_UNSUPP_USE_ATTRIBUTE;
-                    if (use_string)
-                       zebra_setError(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,
-                                      use_string);
-                    else
-                       zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,
-                                           use_value);
-               }   
-               else
-               {
-                   zebra_setError(zh, YAZ_BIB1_UNSUPP_ATTRIBUTE_SET, 0);
-               }
-               continue;
-           }
-       }
-       bases_ok++;
-       for (local_attr = attp.local_attributes; local_attr && ord_no < 32;
-            local_attr = local_attr->next)
-       {
-           ord = zebraExplain_lookup_attr_su(zh->reg->zei, reg_id,
-                                             attp.attset_ordinal,
-                                             local_attr->local);
-           if (ord > 0)
-               ords[ord_no++] = ord;
-       }
+        if (zebra_apt_get_ord(zh, zapt, index_type, 0, attributeset, &ord) 
+            != ZEBRA_OK)
+        {
+            break;
+        }
+        ords[ord_no++] = ord;
     }
     if (!bases_ok && errCode)
     {
     }
     if (!bases_ok && errCode)
     {
@@ -2924,7 +2671,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
         struct scan_info *scan_info = scan_info_array + i;
         struct rpn_char_map_info rcmi;
 
         struct scan_info *scan_info = scan_info_array + i;
         struct rpn_char_map_info rcmi;
 
-        rpn_char_map_prepare (zh->reg, reg_id, &rcmi);
+        rpn_char_map_prepare (zh->reg, index_type, &rcmi);
 
         scan_info->before = before;
         scan_info->after = after;
 
         scan_info->before = before;
         scan_info->after = after;
@@ -2939,7 +2686,8 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
         termz[prefix_len] = 0;
         strcpy(scan_info->prefix, termz);
 
         termz[prefix_len] = 0;
         strcpy(scan_info->prefix, termz);
 
-        if (trans_scan_term(zh, zapt, termz+prefix_len, reg_id) == ZEBRA_FAIL)
+        if (trans_scan_term(zh, zapt, termz+prefix_len, index_type) == 
+            ZEBRA_FAIL)
             return ZEBRA_FAIL;
        
         dict_scan(zh->reg->dict, termz, &before_tmp, &after_tmp,
             return ZEBRA_FAIL;
        
         dict_scan(zh->reg->dict, termz, &before_tmp, &after_tmp,
@@ -2982,12 +2730,12 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
        if (lo >= 0)
        {
            /* get result set for first term */
        if (lo >= 0)
        {
            /* get result set for first term */
-           zebra_term_untrans_iconv(zh, stream->mem, reg_id,
+           zebra_term_untrans_iconv(zh, stream->mem, index_type,
                                     &glist[lo].term, mterm);
            rset = rset_trunc(zh, &scan_info_array[j0].list[ptr[j0]].isam_p, 1,
                              glist[lo].term, strlen(glist[lo].term),
                              NULL, 0, zapt->term->which, rset_nmem, 
                                     &glist[lo].term, mterm);
            rset = rset_trunc(zh, &scan_info_array[j0].list[ptr[j0]].isam_p, 1,
                              glist[lo].term, strlen(glist[lo].term),
                              NULL, 0, zapt->term->which, rset_nmem, 
-                             kc, kc->scope, 0, reg_id, 0 /* hits_limit */,
+                             kc, kc->scope, 0, index_type, 0 /* hits_limit */,
                              0 /* term_ref_id_str */);
        }
        ptr[j0]++; /* move index for this set .. */
                              0 /* term_ref_id_str */);
        }
        ptr[j0]++; /* move index for this set .. */
@@ -3009,7 +2757,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                            glist[lo].term,
                            strlen(glist[lo].term), NULL, 0,
                            zapt->term->which,rset_nmem,
                            glist[lo].term,
                            strlen(glist[lo].term), NULL, 0,
                            zapt->term->which,rset_nmem,
-                           kc, kc->scope, 0, reg_id, 0 /* hits_limit */,
+                           kc, kc->scope, 0, index_type, 0 /* hits_limit */,
                            0 /* term_ref_id_str */ );
                    rset = rsmulti_or_create(rset_nmem, kc,
                                             kc->scope, 0 /* termid */,
                            0 /* term_ref_id_str */ );
                    rset = rsmulti_or_create(rset_nmem, kc,
                                             kc->scope, 0 /* termid */,
@@ -3076,14 +2824,14 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
        if (j0 == -1)
            break;
        
        if (j0 == -1)
            break;
        
-       zebra_term_untrans_iconv(zh, stream->mem, reg_id,
+       zebra_term_untrans_iconv(zh, stream->mem, index_type,
                                 &glist[lo].term, mterm);
        
        rset = rset_trunc
            (zh, &scan_info_array[j0].list[before-1-ptr[j0]].isam_p, 1,
             glist[lo].term, strlen(glist[lo].term),
             NULL, 0, zapt->term->which, rset_nmem,
                                 &glist[lo].term, mterm);
        
        rset = rset_trunc
            (zh, &scan_info_array[j0].list[before-1-ptr[j0]].isam_p, 1,
             glist[lo].term, strlen(glist[lo].term),
             NULL, 0, zapt->term->which, rset_nmem,
-            kc, kc->scope, 0, reg_id, 0 /* hits_limit */,
+            kc, kc->scope, 0, index_type, 0 /* hits_limit */,
             0 /* term_ref_id_str */);
        
        ptr[j0]++;
             0 /* term_ref_id_str */);
        
        ptr[j0]++;
@@ -3103,7 +2851,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                    glist[lo].term,
                    strlen(glist[lo].term), NULL, 0,
                    zapt->term->which, rset_nmem,
                    glist[lo].term,
                    strlen(glist[lo].term), NULL, 0,
                    zapt->term->which, rset_nmem,
-                   kc, kc->scope, 0, reg_id, 0 /* hits_limit */,
+                   kc, kc->scope, 0, index_type, 0 /* hits_limit */,
                    0 /* term_ref_id_str */);
                rset = rsmulti_or_create(rset_nmem, kc,
                                         kc->scope, 0 /* termid */, 2, rsets);
                    0 /* term_ref_id_str */);
                rset = rsmulti_or_create(rset_nmem, kc,
                                         kc->scope, 0 /* termid */, 2, rsets);
index 65e5272..e915543 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zsets.c,v 1.102 2006-05-18 12:03:05 adam Exp $
+/* $Id: zsets.c,v 1.103 2006-05-19 13:49:35 adam Exp $
    Copyright (C) 1995-2006
    Index Data ApS
 
    Copyright (C) 1995-2006
    Index Data ApS
 
@@ -802,7 +802,6 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem,
     if (zh->m_staticrank)
        sysno_mem_index = 1;
 
     if (zh->m_staticrank)
        sysno_mem_index = 1;
 
-
     assert(nmem); /* compiler shut up about unused param */
     sset->sort_info->num_entries = 0;
 
     assert(nmem); /* compiler shut up about unused param */
     sset->sort_info->num_entries = 0;
 
@@ -844,8 +843,17 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem,
         case Z_SortKey_sortField:
             yaz_log(log_level_sort, "key %d is of type sortField",
                    i+1);
         case Z_SortKey_sortField:
             yaz_log(log_level_sort, "key %d is of type sortField",
                    i+1);
-            zebra_setError(zh, YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE, 0);
-            return ZEBRA_FAIL;
+            sort_criteria[i].numerical = 0;
+            sort_criteria[i].ord = 
+                zebraExplain_lookup_attr_str(zh->reg->zei, 's',
+                                             sk->u.sortField);
+            if (sort_criteria[i].ord == -1)
+            {
+                zebra_setError(zh,
+                               YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE, 0);
+                return ZEBRA_FAIL;
+            }
+            break;
         case Z_SortKey_elementSpec:
             yaz_log(log_level_sort, "key %d is of type elementSpec",
                    i+1);
         case Z_SortKey_elementSpec:
             yaz_log(log_level_sort, "key %d is of type elementSpec",
                    i+1);
@@ -853,29 +861,11 @@ ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem,
             return ZEBRA_FAIL;
         case Z_SortKey_sortAttributes:
             yaz_log(log_level_sort, "key %d is of type sortAttributes", i+1);
             return ZEBRA_FAIL;
         case Z_SortKey_sortAttributes:
             yaz_log(log_level_sort, "key %d is of type sortAttributes", i+1);
-            if (1)
-            {
-                int ord;
-                int use = zebra_maps_sort(zh->reg->zebra_maps,
-                                          sk->u.sortAttributes,
-                                          &sort_criteria[i].numerical);
-                yaz_log(log_level_sort, "use value = %d", use);
-                if (use == -1)
-                {
-                    zebra_setError(
-                        zh, YAZ_BIB1_USE_ATTRIBUTE_REQUIRED_BUT_NOT_SUPPLIED, 0); 
-                    return ZEBRA_FAIL;
-                }
-                ord = zebraExplain_lookup_attr_su_any_index(zh->reg->zei, 
-                                                            VAL_IDXPATH, use);
-                if (ord == -1)
-                {
-                    zebra_setError(
-                        zh, YAZ_BIB1_CANNOT_SORT_ACCORDING_TO_SEQUENCE, 0);
-                    return ZEBRA_FAIL;
-                }
-                sort_criteria[i].ord = ord;
-            }
+            if (zebra_sort_get_ord(zh, sk->u.sortAttributes,
+                                   &sort_criteria[i].ord,
+                                   &sort_criteria[i].numerical)
+                != ZEBRA_OK)
+                return ZEBRA_FAIL;
             break;
         }
     }
             break;
         }
     }
index 55bdaa5..f45f4d7 100644 (file)
@@ -1,5 +1,5 @@
-/* $Id: recgrs.c,v 1.109 2006-05-10 08:13:28 adam Exp $
-   Copyright (C) 1995-2005
+/* $Id: recgrs.c,v 1.110 2006-05-19 13:49:35 adam Exp $
+   Copyright (C) 1995-2006
    Index Data ApS
 
 This file is part of the Zebra server.
    Index Data ApS
 
 This file is part of the Zebra server.
@@ -471,33 +471,20 @@ static void index_xpath_attr (char *tag_path, char *name, char *value,
                              char *structure, struct recExtractCtrl *p,
                              RecWord *wrd)
 {
                              char *structure, struct recExtractCtrl *p,
                              RecWord *wrd)
 {
-#if NATTR
     wrd->index_name = ZEBRA_XPATH_ELM_BEGIN;
     wrd->index_name = ZEBRA_XPATH_ELM_BEGIN;
-#else
-    wrd->attrSet = VAL_IDXPATH;
-    wrd->attrUse = 1;
-#endif
     wrd->index_type = '0';
     wrd->term_buf = tag_path;
     wrd->term_len = strlen(tag_path);
     (*p->tokenAdd)(wrd);
     
     if (value) {
     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;
-#endif
+       wrd->index_name = ZEBRA_XPATH_ATTR_CDATA;
         wrd->index_type = 'w';
         wrd->term_buf = value;
         wrd->term_len = strlen(value);
         (*p->tokenAdd)(wrd);
     }
         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;
     wrd->index_name = ZEBRA_XPATH_ELM_END;
-#else
-    wrd->attrUse = 2;
-#endif
     wrd->index_type = '0';
     wrd->term_buf = tag_path;
     wrd->term_len = strlen(tag_path);
     wrd->index_type = '0';
     wrd->term_buf = tag_path;
     wrd->term_len = strlen(tag_path);
@@ -533,12 +520,8 @@ static void mk_tag_path_full(char *tag_path_full, size_t max, data1_node *n)
 static void index_xpath(struct source_parser *sp, data1_node *n,
                        struct recExtractCtrl *p,
                        int level, RecWord *wrd,
 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
                        char *xpath_index,
                        int xpath_is_start
-#else
-                       int use
-#endif
     )
 {
     int i;
     )
 {
     int i;
@@ -546,19 +529,8 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
     int termlist_only = 1;
     data1_termlist *tl;
     int xpdone = 0;
     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);
     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;
     if ((!n->root->u.root.absyn) ||
        (n->root->u.root.absyn->enable_xpath_indexing)) {
        termlist_only = 0;
@@ -585,19 +557,10 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
                memcpy (&wrd_tl, wrd, sizeof(*wrd));
                if (tl->source)
                    sp_parse(sp, n, &wrd_tl, tl->source);
                memcpy (&wrd_tl, wrd, sizeof(*wrd));
                if (tl->source)
                    sp_parse(sp, n, &wrd_tl, tl->source);
-#if NATTR
                if (!tl->index_name)
                if (!tl->index_name)
-#else
-               if (!tl->att)
-#endif
                {
                    /* this is the ! case, so structure is for the xpath index */
                {
                    /* this is the ! case, so structure is for the xpath index */
-#if NATTR
                    wrd_tl.index_name = xpath_index;
                    wrd_tl.index_name = xpath_index;
-#else
-                   wrd_tl.attrSet = VAL_IDXPATH;
-                   wrd_tl.attrUse = use;
-#endif
                    if (p->flagShowRecords)
                    {
                        int i;
                    if (p->flagShowRecords)
                    {
                        int i;
@@ -615,25 +578,13 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
                    xpdone = 1;
                } else {
                    /* this is just the old fashioned attribute based index */
                    xpdone = 1;
                } else {
                    /* this is just the old fashioned attribute based index */
-#if NATTR
                    wrd_tl.index_name = tl->index_name;
                    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 (p->flagShowRecords)
                    {
                        int i;
                        printf("%*sIdx: [%s]", (level + 1) * 4, "",
                               tl->structure);
-#if NATTR
                        printf("%s %s", tl->index_name, tl->source);
                        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; i<wrd_tl.term_len && i < 40; i++)
                            fputc (wrd_tl.term_buf[i], stdout);
                        printf (" XData:\"");
                        for (i = 0; i<wrd_tl.term_len && i < 40; i++)
                            fputc (wrd_tl.term_buf[i], stdout);
@@ -651,12 +602,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
           or no ! in the termlist, and default indexing is enabled... */
        if (!p->flagShowRecords && !xpdone && !termlist_only)
        {
           or no ! in the termlist, and default indexing is enabled... */
        if (!p->flagShowRecords && !xpdone && !termlist_only)
        {
-#if NATTR
            wrd->index_name = xpath_index;
            wrd->index_name = xpath_index;
-#else
-           wrd->attrSet = VAL_IDXPATH;
-           wrd->attrUse = use;
-#endif
            wrd->index_type = 'w';
            (*p->tokenAdd)(wrd);
        }
            wrd->index_type = 'w';
            (*p->tokenAdd)(wrd);
        }
@@ -667,12 +613,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
         wrd->index_type = '0';
         wrd->term_buf = tag_path_full;
         wrd->term_len = strlen(tag_path_full);
         wrd->index_type = '0';
         wrd->term_buf = tag_path_full;
         wrd->term_len = strlen(tag_path_full);
-#if NATTR
        wrd->index_name = xpath_index;
        wrd->index_name = xpath_index;
-#else
-        wrd->attrSet = VAL_IDXPATH;
-        wrd->attrUse = use;
-#endif
         if (p->flagShowRecords)
         {
             printf("%*s tag=", (level + 1) * 4, "");
         if (p->flagShowRecords)
         {
             printf("%*s tag=", (level + 1) * 4, "");
@@ -698,11 +639,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
                {
                     for (; tl; tl = tl->next) 
                    {
                {
                     for (; tl; tl = tl->next) 
                    {
-#if NATTR
                        if (!tl->index_name)
                        if (!tl->index_name)
-#else
-                       if (!tl->att) 
-#endif
                            do_xpindex = 1;
                    }
                 }
                            do_xpindex = 1;
                    }
                 }
@@ -742,13 +679,8 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
                     {
                         for (; tl; tl = tl->next)
                         {
                     {
                         for (; tl; tl = tl->next)
                         {
-#if NATTR
                            if (!tl->index_name)
                                do_xpindex = 1;
                            if (!tl->index_name)
                                do_xpindex = 1;
-#else
-                            if (!tl->att)
-                                do_xpindex = 1;
-#endif
                         }
                     }
                     
                         }
                     }
                     
@@ -756,11 +688,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
                         
                         /* attribute  (no value) */
                         wrd->index_type = '0';
                         
                         /* attribute  (no value) */
                         wrd->index_type = '0';
-#if NATTR
-                       wrd->index_name = ZEBRA_XPATH_ATTR;
-#else
-                        wrd->attrUse = 3;
-#endif
+                       wrd->index_name = ZEBRA_XPATH_ATTR_NAME;
                         wrd->term_buf = xp->name;
                         wrd->term_len = strlen(xp->name);
                         
                         wrd->term_buf = xp->name;
                         wrd->term_len = strlen(xp->name);
                         
@@ -775,11 +703,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
                             strcat (comb, "=");
                             strcat (comb, xp->value);
 
                             strcat (comb, "=");
                             strcat (comb, xp->value);
 
-#if NATTR
-                            wrd->index_name = ZEBRA_XPATH_ATTR;
-#else
-                            wrd->attrUse = 3;
-#endif
+                            wrd->index_name = ZEBRA_XPATH_ATTR_NAME;
                             wrd->index_type = '0';
                             wrd->term_buf = comb;
                             wrd->term_len = strlen(comb);
                             wrd->index_type = '0';
                             wrd->term_buf = comb;
                             wrd->term_len = strlen(comb);
@@ -805,11 +729,7 @@ 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 there is a termlist given (=xelm directive) */
                         for (; tl; tl = tl->next)
                         {
-#if NATTR
                            if (!tl->index_name)
                            if (!tl->index_name)
-#else
-                            if (!tl->att) 
-#endif
                            {
                                 /* add xpath index for the attribute */
                                 index_xpath_attr (attr_tag_path_full, xp->name,
                            {
                                 /* add xpath index for the attribute */
                                 index_xpath_attr (attr_tag_path_full, xp->name,
@@ -820,13 +740,7 @@ static void index_xpath(struct source_parser *sp, data1_node *n,
                                 /* index attribute value (only path/@attr) */
                                 if (xp->value) 
                                {
                                 /* index attribute value (only path/@attr) */
                                 if (xp->value) 
                                {
-#if NATTR
                                    wrd->index_name = tl->index_name;
                                    wrd->index_name = tl->index_name;
-#else
-                                    wrd->attrSet = (int) 
-                                        (tl->att->parent->reference);
-                                    wrd->attrUse = tl->att->locals->local;
-#endif
                                     wrd->index_type = *tl->structure;
                                     wrd->term_buf = xp->value;
                                     wrd->term_len = strlen(xp->value);
                                     wrd->index_type = *tl->structure;
                                     wrd->term_buf = xp->value;
                                     wrd->term_len = strlen(xp->value);
@@ -885,14 +799,7 @@ static void index_termlist (struct source_parser *sp, data1_node *par,
                int i;
                printf("%*sIdx: [%s]", (level + 1) * 4, "",
                       tlist->structure);
                int i;
                printf("%*sIdx: [%s]", (level + 1) * 4, "",
                       tlist->structure);
-#if NATTR
                printf("%s %s", tlist->index_name, tlist->source);
                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; i<wrd->term_len && i < 40; i++)
                    fputc (wrd->term_buf[i], stdout);
                printf (" XData:\"");
                for (i = 0; i<wrd->term_len && i < 40; i++)
                    fputc (wrd->term_buf[i], stdout);
@@ -904,12 +811,7 @@ static void index_termlist (struct source_parser *sp, data1_node *par,
            else
            {
                wrd->index_type = *tlist->structure;
            else
            {
                wrd->index_type = *tlist->structure;
-#if NATTR
                wrd->index_name = tlist->index_name;
                wrd->index_name = tlist->index_name;
-#else
-               wrd->attrSet = (int) (tlist->att->parent->reference);
-               wrd->attrUse = tlist->att->locals->local;
-#endif
                (*p->tokenAdd)(wrd);
            }
        }
                (*p->tokenAdd)(wrd);
            }
        }
@@ -963,14 +865,9 @@ static int dumpkeys_r(struct source_parser *sp,
        {
             index_termlist(sp, n, n, p, level, wrd);
             /* index start tag */
        {
             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 */);
            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)
        }
 
        if (n->child)
@@ -998,23 +895,15 @@ static int dumpkeys_r(struct source_parser *sp,
            if (par)
                index_termlist(sp, par, n, p, level, wrd);
 
            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 */);
            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 (n->which == DATA1N_tag)
        {
             /* index end tag */
-#if NATTR
            index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_ELM_END, 
                        0 /* is start */);
            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)
        }
 
        if (p->flagShowRecords && n->which == DATA1N_root)
index da047a1..772e13f 100644 (file)
@@ -1,7 +1,7 @@
 # This is the abstract syntax (and most of the top-level profile info)
 # for GILS version 2.
 #
 # This is the abstract syntax (and most of the top-level profile info)
 # for GILS version 2.
 #
-# $Id: gils.abs,v 1.2 2002-12-02 16:55:14 adam Exp $
+# $Id: gils.abs,v 1.3 2006-05-19 13:49:35 adam Exp $
 
 name gils
 reference GILS-schema
 
 name gils
 reference GILS-schema
@@ -22,7 +22,7 @@ esetname F @
 
 systag sysno none
 
 
 systag sysno none
 
-#all Any
+all Any
 
 elm (1,1)                   schemaIdentifier           -
 elm (1,10)                  rank                       -
 
 elm (1,1)                   schemaIdentifier           -
 elm (1,10)                  rank                       -
index 9c56604..52a7d31 100644 (file)
@@ -1,9 +1,9 @@
-# $Id: Makefile.am,v 1.35 2006-04-27 20:40:41 marc Exp $
+# $Id: Makefile.am,v 1.36 2006-05-19 13:49:35 adam Exp $
 
 noinst_PROGRAMS = testclient
 testclient_SOURCES = testclient.c 
 
 
 noinst_PROGRAMS = testclient
 testclient_SOURCES = testclient.c 
 
-simpletests = t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15
+simpletests = t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t11 t12 t13 t14 t15
 safaritests = safari1
 check_PROGRAMS = $(simpletests) $(safaritests)
 TESTS = $(check_PROGRAMS)
 safaritests = safari1
 check_PROGRAMS = $(simpletests) $(safaritests)
 TESTS = $(check_PROGRAMS)
@@ -24,7 +24,6 @@ t6_SOURCES = t6.c
 t7_SOURCES = t7.c
 t8_SOURCES = t8.c
 t9_SOURCES = t9.c rankingrecords.h
 t7_SOURCES = t7.c
 t8_SOURCES = t8.c
 t9_SOURCES = t9.c rankingrecords.h
-t10_SOURCES = t10.c rankingrecords.h
 t11_SOURCES = t11.c
 t12_SOURCES = t12.c
 t13_SOURCES = t13.c
 t11_SOURCES = t11.c
 t12_SOURCES = t12.c
 t13_SOURCES = t13.c
diff --git a/test/api/t10.c b/test/api/t10.c
deleted file mode 100644 (file)
index 4429132..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/* $Id: t10.c,v 1.11 2006-05-10 08:13:35 adam Exp $
-   Copyright (C) 1995-2005
-   Index Data ApS
-
-This file is part of the Zebra server.
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra.  If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
-*/
-
-/** t10.c - test zv-rank */
-
-#include "testlib.h"
-#include "rankingrecords.h"
-
-struct tst {
-    char *schema;
-    char *hit1;
-    int score1;
-    char *hit2;
-    int score2;
-    char *hit3;
-    int score3;
-};
-
-struct tst tests[] = {
-    {"ntc-atn", "first title", 0, "first title", 1000, "first title",1000 },
-    {"ntc-ntn", "first title", 0, "first title", 1000, "first title",1000 },
-    {"ntc-btn", "first title", 0, "first title", 1000, "first title",1000 },
-    {"ntc-apn", "first title", 0,    "first title", 1000, "first title",1000 },
-    {"ntc-npn", "first title", 0,    "first title", 1000, "first title",1000 },
-    {"ntc-bpn", "first title", 0,    "first title", 1000, "first title",1000 },
-    {"atc-atn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"atc-ntn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"atc-btn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"atc-apn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"atc-npn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"atc-bpn", "first title", 0,    "first title", 1000, "first title", 1000 },
-
-    {"npc-atn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"npc-ntn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"npc-btn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"npc-apn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"npc-npn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"npc-bpn", "first title", 0,    "first title", 1000, "first title", 1000 },
-
-    {"apc-atn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"apc-ntn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"apc-btn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"apc-apn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"apc-npn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {"apc-bpn", "first title", 0,    "first title", 1000, "first title", 1000 },
-    {0,0,0,0,0,0,0},
-};
-
-static void tst(int argc, char **argv)
-{
-    int i;
-    ZebraService zs = tl_start_up("zebrazv.cfg", argc, argv);
-    ZebraHandle zh = zebra_open(zs, 0);
-  
-    YAZ_CHECK(tl_init_data(zh, recs));
-    zebra_close(zh);
-    for (i = 0; tests[i].schema; i++)
-    {
-        zh = zebra_open(zs, 0);
-       YAZ_CHECK(zh);
-        YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
-
-        zebra_set_resource(zh, "zvrank.weighting-scheme", tests[i].schema);
-        yaz_log(YLOG_LOG,"============%d: %s ===========", i, tests[i].schema);
-
-        YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 the",
-                                  3, tests[i].hit1, tests[i].score1));
-        YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 @or foo bar",
-                                  3, tests[i].hit2, tests[i].score2));
-        YAZ_CHECK(tl_ranking_query(zh, 
-                                  "@attr 1=1016 @attr 2=102 @or @or the foo bar",
-                                  3, tests[i].hit3, tests[i].score3));
-        zebra_close(zh);
-    }
-    YAZ_CHECK(tl_close_down(0, zs));
-}
-
-TL_MAIN
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
index 96ec8d3..df2eec6 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: t5.c,v 1.16 2006-05-10 08:13:35 adam Exp $
+/* $Id: t5.c,v 1.17 2006-05-19 13:49:35 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -62,19 +62,19 @@ static void tst(int argc, char **argv)
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @and x title", 2));
 
     /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */
     YAZ_CHECK(tl_query(zh, "@attr 1=4 @and x title", 2));
 
     /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */
-    YAZ_CHECK(tl_query(zh, "@prox 0 2 1 2 k 2 my x", 2));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 2 k 2 my x", 2));
 
     /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */
 
     /* exl=0 distance=2 order=1 relation=2 (<=), known, unit=word */
-    YAZ_CHECK(tl_query(zh, "@prox 0 2 1 2 k 2 x my", 0));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 2 k 2 x my", 0));
 
     /* exl=0 distance=2 order=0 relation=2 (<=), known, unit=word */
 
     /* exl=0 distance=2 order=0 relation=2 (<=), known, unit=word */
-    YAZ_CHECK(tl_query(zh, "@prox 0 2 0 2 k 2 x my", 2));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 0 2 k 2 x my", 2));
 
     /* exl=0 distance=2 order=0 relation=3 (=), known, unit=word */
 
     /* exl=0 distance=2 order=0 relation=3 (=), known, unit=word */
-    YAZ_CHECK(tl_query(zh, "@prox 0 2 1 3 k 2 my x", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 0 2 1 3 k 2 my x", 1));
 
     /* exl=1 distance=2 order=0 relation=3 (=), known, unit=word */
 
     /* exl=1 distance=2 order=0 relation=3 (=), known, unit=word */
-    YAZ_CHECK(tl_query(zh, "@prox 1 2 1 3 k 2 my x", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 1 2 1 3 k 2 my x", 1));
 
     /* provoke unsupported use attribute */
     YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=1 x", 0, 114));
 
     /* provoke unsupported use attribute */
     YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=1 x", 0, 114));
@@ -93,7 +93,7 @@ static void tst(int argc, char **argv)
               0, 121));
 
     /* provoke unsupported relation */
               0, 121));
 
     /* provoke unsupported relation */
-    YAZ_CHECK(tl_query_x(zh, "@attr 1=1016 @attr 2=6 x", 0, 117));
+    YAZ_CHECK(tl_query_x(zh, "@attr 1=4 @attr 2=6 x", 0, 117));
     YAZ_CHECK(tl_query_x(zh, "@attr 1=1016 @attr 2=6 @attr 4=109 x", 0, 114));
  
     YAZ_CHECK(tl_close_down(zh, zs));
     YAZ_CHECK(tl_query_x(zh, "@attr 1=1016 @attr 2=6 @attr 4=109 x", 0, 114));
  
     YAZ_CHECK(tl_close_down(zh, zs));
index 0c811a6..e1aa6ca 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: t8.c,v 1.10 2006-05-10 08:13:35 adam Exp $
+/* $Id: t8.c,v 1.11 2006-05-19 13:49:35 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -64,7 +64,6 @@ static void tst(int argc, char **argv)
 
     /* couple of simple queries just to see that we have indexed the stuff */
     YAZ_CHECK(tl_query(zh,  "@attr 1=4 title", 2));
 
     /* couple of simple queries just to see that we have indexed the stuff */
     YAZ_CHECK(tl_query(zh,  "@attr 1=4 title", 2));
-    YAZ_CHECK(tl_query(zh,  "title", 2));
     
     /* 1=2038: West-Bounding-Coordinate 2039: East: 2040: North: 2041 South*/
     /* 4=109: numeric string */
     
     /* 1=2038: West-Bounding-Coordinate 2039: East: 2040: North: 2041 South*/
     /* 4=109: numeric string */
index cfbae53..74eed98 100644 (file)
@@ -1,5 +1,5 @@
-/* $Id: t9.c,v 1.9 2006-05-10 08:13:35 adam Exp $
-   Copyright (C) 1995-2005
+/* $Id: t9.c,v 1.10 2006-05-19 13:49:35 adam Exp $
+   Copyright (C) 1995-2006
    Index Data ApS
 
 This file is part of the Zebra server.
    Index Data ApS
 
 This file is part of the Zebra server.
@@ -33,16 +33,16 @@ static void tst(int argc, char **argv)
 
     YAZ_CHECK(tl_init_data(zh, recs));
     
 
     YAZ_CHECK(tl_init_data(zh, recs));
     
-    YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 the",
-                              3, "first title", 997 ));
+    YAZ_CHECK(tl_ranking_query(zh, "@attr 1=4 @attr 2=102 the",
+                              3, "first title", 1000 ));
     
     
-    YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 foo",
+    YAZ_CHECK(tl_ranking_query(zh, "@attr 1=62 @attr 2=102 foo",
                               3, "second title", 850 ));
     
     /* get the record with the most significant hit, that is the 'bar' */
     /* as that is the rarest of my search words */
     YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 @or @or the foo bar",
                               3, "second title", 850 ));
     
     /* get the record with the most significant hit, that is the 'bar' */
     /* as that is the rarest of my search words */
     YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 @or @or the foo bar",
-                              3, "third title", 940 ));
+                              3, "third title", 813 ));
     
     YAZ_CHECK(tl_close_down(zh, zs));
 }
     
     YAZ_CHECK(tl_close_down(zh, zs));
 }
index 5783946..768b47a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: charmap1.c,v 1.10 2006-05-10 08:13:36 adam Exp $
+/* $Id: charmap1.c,v 1.11 2006-05-19 13:49:35 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -41,46 +41,46 @@ static void tst(int argc, char **argv)
     YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
     zebra_commit(zh);
 
     YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
     zebra_commit(zh);
 
-    YAZ_CHECK(tl_query(zh, "@term string Ã¦", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @term string Ã¦", 1));
 
     /* search for UNICODE 1E25 - letter h with dot below */
 
     /* search for UNICODE 1E25 - letter h with dot below */
-    YAZ_CHECK(tl_query(zh, "@term string á¸¥", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @term string á¸¥", 1));
 
     /* search for UNICODE A ring */
 
     /* search for UNICODE A ring */
-    YAZ_CHECK(tl_query(zh, "@term string lÃ¥s", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @term string lÃ¥s", 1));
 
     /* search for aa  */
 
     /* search for aa  */
-    YAZ_CHECK(tl_query(zh, "@term string laas", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @term string laas", 1));
 
     /* search for aa regular-1 */
 
     /* search for aa regular-1 */
-    YAZ_CHECK(tl_query(zh, "@attr 5=102 @term string lÃ¥s", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=102 @term string lÃ¥s", 1));
 
     /* search for aa regular-2 */
 
     /* search for aa regular-2 */
-    YAZ_CHECK(tl_query(zh, "@attr 5=103 @term string lÃ¥s", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=103 @term string lÃ¥s", 1));
 
     /* search for aa trunc=104 */
 
     /* search for aa trunc=104 */
-    YAZ_CHECK(tl_query(zh, "@attr 5=104 @term string laas", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 @term string laas", 1));
 
     /* search for aa trunc=105 */
 
     /* search for aa trunc=105 */
-    YAZ_CHECK(tl_query(zh, "@attr 5=104 @term string laas", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=104 @term string laas", 1));
 
     /* search for aaa  */
 
     /* search for aaa  */
-    YAZ_CHECK(tl_query(zh, "@term string laaas", 0));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @term string laaas", 0));
     
     /* search ABC in title:0 .  */
     
     /* search ABC in title:0 .  */
-    YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 ABC", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 ABC", 1));
     
     /* search DEF in title:0 .  */
     
     /* search DEF in title:0 .  */
-    YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 DEF", 0));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 DEF", 0));
     
     /* search [ in title:0 .  */
     
     /* search [ in title:0 .  */
-    YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 [", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 [", 1));
     
     /* search \ in title:0 .  */
     
     /* search \ in title:0 .  */
-    YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 \\\\\\\\", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 \\\\\\\\", 1));
 
     /* search { in title:0 .  */
 
     /* search { in title:0 .  */
-    YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=4 \\{", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 4=3 @attr 1=4 \\{", 1));
     
     YAZ_CHECK(tl_close_down(zh, zs));
 }
     
     YAZ_CHECK(tl_close_down(zh, zs));
 }
index bcd7f55..d115611 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: grs.marc.c,v 1.4 2006-05-10 08:13:36 adam Exp $
+/* $Id: grs.marc.c,v 1.5 2006-05-19 13:49:35 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -42,9 +42,9 @@ static void tst(int argc, char **argv)
     YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
     zebra_commit(zh);
 
     YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
     zebra_commit(zh);
 
-    YAZ_CHECK(tl_query(zh, "computer", 1));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 computer", 1));
 
 
-    YAZ_CHECK(tl_query(zh, "computee", 0));
+    YAZ_CHECK(tl_query(zh, "@attr 1=4 computee", 0));
 
     YAZ_CHECK(tl_close_down(zh, zs));
 }
 
     YAZ_CHECK(tl_close_down(zh, zs));
 }
index 4eff517..13f7fd9 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
 #!/bin/sh
-# $Id: test1.sh,v 1.14 2006-04-27 10:52:26 marc Exp $
+# $Id: test1.sh,v 1.15 2006-05-19 13:49:36 adam Exp $
 
 srcdir=${srcdir:-"."}
 
 
 srcdir=${srcdir:-"."}
 
@@ -44,7 +44,7 @@ grep "^Result count: 17$" log >/dev/null || exit 1
 
 echo "search 2..." >>$LOG
 ../api/testclient unix:socket "@or utah the" > log || exit 1
 
 echo "search 2..." >>$LOG
 ../api/testclient unix:socket "@or utah the" > log || exit 1
-grep "^Result count: 40$" log >/dev/null || exit 1
+grep "^Result count: 41$" log >/dev/null || exit 1
 
 echo "search 3..." >>$LOG
 ../api/testclient unix:socket "@attr 1=4 the" > log || exit 1
 
 echo "search 3..." >>$LOG
 ../api/testclient unix:socket "@attr 1=4 the" > log || exit 1
index fb5e07b..7350901 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
 #!/bin/sh
-# $Id: test3.sh,v 1.8 2006-04-27 10:52:26 marc Exp $
+# $Id: test3.sh,v 1.9 2006-05-19 13:49:36 adam Exp $
 
 # Testing searches with lots of @and operators
 # in order to test the fast-forward operation of rsets
 
 # Testing searches with lots of @and operators
 # in order to test the fast-forward operation of rsets
@@ -37,7 +37,7 @@ echo "search A1..." >>$LOG
 ../api/testclient -c 17 unix:socket utah > log || exit 1
 
 echo "search A2..." >>$LOG
 ../api/testclient -c 17 unix:socket utah > log || exit 1
 
 echo "search A2..." >>$LOG
-../api/testclient -c 30 unix:socket the > log || exit 1
+../api/testclient -c 31 unix:socket the > log || exit 1
 
 echo "search A3..." >>$LOG
 ../api/testclient -c 4 unix:socket deposits > log || exit 1
 
 echo "search A3..." >>$LOG
 ../api/testclient -c 4 unix:socket deposits > log || exit 1
@@ -69,19 +69,19 @@ echo "search C6..." >>$LOG
 
 
 echo "search D1..." >>$LOG
 
 
 echo "search D1..." >>$LOG
-../api/testclient -c 29 unix:socket "@and the of "  > log || exit 1
+../api/testclient -c 30 unix:socket "@and the of "  > log || exit 1
 
 echo "search D2..." >>$LOG
 
 echo "search D2..." >>$LOG
-../api/testclient -c 29 unix:socket "@and of the"  > log || exit 1
+../api/testclient -c 30 unix:socket "@and of the"  > log || exit 1
 
 echo "search D3..." >>$LOG
 
 echo "search D3..." >>$LOG
-../api/testclient -c 29 unix:socket "@and @and the of of"  > log || exit 1
+../api/testclient -c 30 unix:socket "@and @and the of of"  > log || exit 1
 
 echo "search D4..." >>$LOG
 
 echo "search D4..." >>$LOG
-../api/testclient -c 29 unix:socket "@and @and of the the"  > log || exit 1
+../api/testclient -c 30 unix:socket "@and @and of the the"  > log || exit 1
 
 echo "search D5..." >>$LOG
 
 echo "search D5..." >>$LOG
-../api/testclient -c 29 unix:socket "@and @and @and the of of the"  > log || exit 1
+../api/testclient -c 30 unix:socket "@and @and @and the of of the"  > log || exit 1
 
 echo "search D6..." >>$LOG
 ../api/testclient -c 15 unix:socket '@and @and in the data' > log || exit 1
 
 echo "search D6..." >>$LOG
 ../api/testclient -c 15 unix:socket '@and @and in the data' > log || exit 1
@@ -94,22 +94,22 @@ echo "search D8..." >>$LOG
 # This one failed at early fast-forwards
 
 echo "search E1..." >>$LOG
 # This one failed at early fast-forwards
 
 echo "search E1..." >>$LOG
-../api/testclient -c 40 unix:socket "@or the utah"  > log || exit 1
+../api/testclient -c 41 unix:socket "@or the utah"  > log || exit 1
 
 echo "search E2..." >>$LOG
 
 echo "search E2..." >>$LOG
-../api/testclient -c 40 unix:socket "@or utah the"  > log || exit 1
+../api/testclient -c 41 unix:socket "@or utah the"  > log || exit 1
 
 echo "search E3..." >>$LOG
 ../api/testclient -c 42 unix:socket "@or deposits @or the utah"  > log || exit 1
 
 echo "search E4..." >>$LOG
 
 echo "search E3..." >>$LOG
 ../api/testclient -c 42 unix:socket "@or deposits @or the utah"  > log || exit 1
 
 echo "search E4..." >>$LOG
-../api/testclient -c 2 unix:socket "@and deposits @or the utah"  > log || exit 1
+../api/testclient -c 3 unix:socket "@and deposits @or the utah"  > log || exit 1
 
 echo "search E5..." >>$LOG
 
 echo "search E5..." >>$LOG
-../api/testclient -c 2 unix:socket "@and @or the utah deposits"  > log || exit 1
+../api/testclient -c 3 unix:socket "@and @or the utah deposits"  > log || exit 1
 
 echo "search F1..." >>$LOG
 
 echo "search F1..." >>$LOG
-../api/testclient -c 23 unix:socket "@not the utah "  > log || exit 1
+../api/testclient -c 24 unix:socket "@not the utah "  > log || exit 1
 
 echo "search F2..." >>$LOG
 ../api/testclient -c 10 unix:socket "@not utah the "  > log || exit 1
 
 echo "search F2..." >>$LOG
 ../api/testclient -c 10 unix:socket "@not utah the "  > log || exit 1
index 4e648c1..34419a6 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: sort1.c,v 1.8 2006-05-10 08:13:39 adam Exp $
+/* $Id: sort1.c,v 1.9 2006-05-19 13:49:36 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -47,19 +47,19 @@ static void tst(int argc, char **argv)
     ids[1] = 2;
     ids[2] = 4;
     ids[3] = 5;
     ids[1] = 2;
     ids[2] = 4;
     ids[3] = 5;
-    YAZ_CHECK(tl_sort(zh, "@or computer @attr 7=1 @attr 1=30 0", 4, ids));
+    YAZ_CHECK(tl_sort(zh, "@or @attr 1=4 computer @attr 7=1 @attr 1=30 0", 4, ids));
 
     ids[0] = 5;
     ids[1] = 4;
     ids[2] = 2;
     ids[3] = 3;
 
     ids[0] = 5;
     ids[1] = 4;
     ids[2] = 2;
     ids[3] = 3;
-    YAZ_CHECK(tl_sort(zh, "@or computer @attr 7=1 @attr 1=1021 0", 4, ids));
+    YAZ_CHECK(tl_sort(zh, "@or @attr 1=4 computer @attr 7=1 @attr 1=1021 0", 4, ids));
 
     ids[0] = 2;
     ids[1] = 5;
     ids[2] = 4;
     ids[3] = 3;
 
     ids[0] = 2;
     ids[1] = 5;
     ids[2] = 4;
     ids[3] = 3;
-    YAZ_CHECK(tl_sort(zh, "@or computer @attr 7=1 @attr 1=1021 @attr 4=109 0", 4, ids));
+    YAZ_CHECK(tl_sort(zh, "@or @attr 1=4 computer @attr 7=1 @attr 1=1021 @attr 4=109 0", 4, ids));
 
     YAZ_CHECK(tl_close_down(zh, zs));
 }
 
     YAZ_CHECK(tl_close_down(zh, zs));
 }
index 66f81c5..d2bd23b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: t1.c,v 1.6 2006-05-10 08:13:39 adam Exp $
+/* $Id: t1.c,v 1.7 2006-05-19 13:49:36 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -47,7 +47,7 @@ static void tst(int argc, char **argv)
     ids[1] = 5;
     ids[2] = 3;
     ids[3] = 4;
     ids[1] = 5;
     ids[2] = 3;
     ids[3] = 4;
-    YAZ_CHECK(tl_sort(zh, "@or computer @attr 7=1 @attr 1=4 0", 4, ids));
+    YAZ_CHECK(tl_sort(zh, "@or @attr 1=4 computer @attr 7=1 @attr 1=4 0", 4, ids));
 
     YAZ_CHECK(tl_close_down(zh, zs));
 }
 
     YAZ_CHECK(tl_close_down(zh, zs));
 }
index 713cf95..ee9baf1 100644 (file)
@@ -1,7 +1,8 @@
-# $Id: zebra.cfg,v 1.6 2004-12-15 13:07:07 adam Exp $
+# $Id: zebra.cfg,v 1.7 2006-05-19 13:49:38 adam Exp $
 profilePath: ${srcdir:-.}:${srcdir:-.}/../../tab
 recordType: grs.sgml
 attset: bib1.att
 profilePath: ${srcdir:-.}:${srcdir:-.}/../../tab
 recordType: grs.sgml
 attset: bib1.att
+attset: explain.att
 
 isam:b
 
 
 isam:b
 
index 8ff62e1..4cba0d4 100644 (file)
@@ -1,4 +1,4 @@
-## $Id: Makefile.am,v 1.17 2006-04-27 20:40:45 marc Exp $
+## $Id: Makefile.am,v 1.18 2006-05-19 13:49:38 adam Exp $
 
 lib_LTLIBRARIES = libidzebra-util.la
 
 
 lib_LTLIBRARIES = libidzebra-util.la
 
@@ -18,7 +18,7 @@ AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC) -DDEFAULT_PROFILE_PATH=\"$(pkgdat
 LDADD = libidzebra-util.la $(YAZLALIB)
 
 libidzebra_util_la_SOURCES = zint.c res.c charmap.c zebramap.c passwddb.c \
 LDADD = libidzebra-util.la $(YAZLALIB)
 
 libidzebra_util_la_SOURCES = zint.c res.c charmap.c zebramap.c passwddb.c \
- zebra-lock.c dirent.c xpath.c atoi_zn.c snippet.c flock.c
+ zebra-lock.c dirent.c xpath.c atoi_zn.c snippet.c flock.c attrfind.c
 
 passtest_SOURCES = passtest.c
 
 
 passtest_SOURCES = passtest.c
 
diff --git a/util/attrfind.c b/util/attrfind.c
new file mode 100644 (file)
index 0000000..80f9912
--- /dev/null
@@ -0,0 +1,122 @@
+/* $Id: attrfind.c,v 1.1 2006-05-19 13:49:38 adam Exp $
+   Copyright (C) 2005-2006
+   Index Data ApS
+
+   This file is part of the Zebra server.
+
+   Zebra is free software; you can redistribute it and/or modify it under
+   the terms of the GNU General Public License as published by the Free
+   Software Foundation; either version 2, or (at your option) any later
+   version.
+
+   Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+   for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Zebra; see the file LICENSE.zebra.  If not, write to the
+   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, USA.
+*/
+
+#include <assert.h>
+
+#include <attrfind.h>
+
+void attr_init_APT(AttrType *src, Z_AttributesPlusTerm *zapt, int type)
+{
+    src->attributeList = zapt->attributes->attributes;
+    src->num_attributes = zapt->attributes->num_attributes;
+    src->type = type;
+    src->major = 0;
+    src->minor = 0;
+}
+
+void attr_init_AttrList(AttrType *src, Z_AttributeList *list, int type)
+{
+    src->attributeList = list->attributes;
+    src->num_attributes = list->num_attributes;
+    src->type = type;
+    src->major = 0;
+    src->minor = 0;
+}
+
+int attr_find_ex(AttrType *src, oid_value *attributeSetP, 
+                const char **string_value)
+{
+    int num_attributes;
+
+    num_attributes = src->num_attributes;
+    while (src->major < num_attributes)
+    {
+        Z_AttributeElement *element;
+
+        element = src->attributeList[src->major];
+        if (src->type == *element->attributeType)
+        {
+            switch (element->which) 
+            {
+            case Z_AttributeValue_numeric:
+                ++(src->major);
+                if (element->attributeSet && attributeSetP)
+                {
+                    oident *attrset;
+
+                    attrset = oid_getentbyoid(element->attributeSet);
+                    *attributeSetP = attrset->value;
+                }
+                return *element->value.numeric;
+                break;
+            case Z_AttributeValue_complex:
+                if (src->minor >= element->value.complex->num_list)
+                    break;
+                if (element->attributeSet && attributeSetP)
+                {
+                    oident *attrset;
+                    
+                    attrset = oid_getentbyoid(element->attributeSet);
+                    *attributeSetP = attrset->value;
+                }
+                if (element->value.complex->list[src->minor]->which ==  
+                    Z_StringOrNumeric_numeric)
+                {
+                    ++(src->minor);
+                    return
+                        *element->value.complex->list[src->minor-1]->u.numeric;
+                }
+                else if (element->value.complex->list[src->minor]->which ==  
+                         Z_StringOrNumeric_string)
+                {
+                    if (!string_value)
+                        break;
+                    ++(src->minor);
+                    *string_value = 
+                        element->value.complex->list[src->minor-1]->u.string;
+                    return -2;
+                }
+                else
+                    break;
+            default:
+                assert(0);
+            }
+        }
+        ++(src->major);
+    }
+    return -1;
+}
+
+int attr_find(AttrType *src, oid_value *attributeSetP)
+{
+    return attr_find_ex(src, attributeSetP, 0);
+}
+
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index d2ac8f9..6418560 100644 (file)
@@ -1,5 +1,5 @@
-/* $Id: zebramap.c,v 1.48 2006-05-17 17:46:45 adam Exp $
-   Copyright (C) 1995-2005
+/* $Id: zebramap.c,v 1.49 2006-05-19 13:49:38 adam Exp $
+   Copyright (C) 1995-2006
    Index Data ApS
 
    This file is part of the Zebra server.
    Index Data ApS
 
    This file is part of the Zebra server.
@@ -25,6 +25,7 @@
 #include <ctype.h>
 
 #include <charmap.h>
 #include <ctype.h>
 
 #include <charmap.h>
+#include <attrfind.h>
 #include <yaz/yaz-util.h>
 
 #include <idzebra/zebramap.h>
 #include <yaz/yaz-util.h>
 
 #include <idzebra/zebramap.h>
@@ -275,78 +276,6 @@ const char *zebra_maps_output(ZebraMaps zms, unsigned reg_id,
 }
 
 
 }
 
 
-/* ------------------------------------ */
-
-typedef struct {
-    int type;
-    int major;
-    int minor;
-    Z_AttributeElement **attributeList;
-    int num_attributes;
-} AttrType;
-
-static int attr_find(AttrType *src, oid_value *attributeSetP)
-{
-    while (src->major < src->num_attributes)
-    {
-        Z_AttributeElement *element;
-
-        element = src->attributeList[src->major];
-        if (src->type == *element->attributeType)
-        {
-            switch (element->which) 
-            {
-            case Z_AttributeValue_numeric:
-                ++(src->major);
-                if (element->attributeSet && attributeSetP)
-                {
-                    oident *attrset;
-
-                    attrset = oid_getentbyoid(element->attributeSet);
-                    *attributeSetP = attrset->value;
-                }
-                return *element->value.numeric;
-                break;
-            case Z_AttributeValue_complex:
-                if (src->minor >= element->value.complex->num_list ||
-                    element->value.complex->list[src->minor]->which !=  
-                    Z_StringOrNumeric_numeric)
-                    break;
-                ++(src->minor);
-                if (element->attributeSet && attributeSetP)
-                {
-                    oident *attrset;
-
-                    attrset = oid_getentbyoid(element->attributeSet);
-                    *attributeSetP = attrset->value;
-                }
-                return *element->value.complex->list[src->minor-1]->u.numeric;
-            default:
-                assert(0);
-            }
-        }
-        ++(src->major);
-    }
-    return -1;
-}
-
-static void attr_init_APT(AttrType *src, Z_AttributesPlusTerm *zapt, int type)
-{
-    src->attributeList = zapt->attributes->attributes;
-    src->num_attributes = zapt->attributes->num_attributes;
-    src->type = type;
-    src->major = 0;
-    src->minor = 0;
-}
-
-static void attr_init_AttrList(AttrType *src, Z_AttributeList *list, int type)
-{
-    src->attributeList = list->attributes;
-    src->num_attributes = list->num_attributes;
-    src->type = type;
-    src->major = 0;
-    src->minor = 0;
-}
 
 /* ------------------------------------ */
 
 
 /* ------------------------------------ */
 
index 22d0802..8b95933 100644 (file)
@@ -1,5 +1,5 @@
 # Zebra makefile for MS NMAKE
 # Zebra makefile for MS NMAKE
-# $Id: makefile,v 1.43 2006-03-29 08:38:45 adam Exp $
+# $Id: makefile,v 1.44 2006-05-19 13:49:38 adam Exp $
  
 ###########################################################
 ############### Parameters 
  
 ###########################################################
 ############### Parameters 
@@ -329,6 +329,7 @@ ZEBRALIB_OBJS= \
        $(MOD_XSLT_OBJS) \
        $(OBJDIR)\atoi_zn.obj \
        $(OBJDIR)\attribute.obj \
        $(MOD_XSLT_OBJS) \
        $(OBJDIR)\atoi_zn.obj \
        $(OBJDIR)\attribute.obj \
+       $(OBJDIR)\attrfind.obj \
        $(OBJDIR)\bfile.obj \
        $(OBJDIR)\bset.obj \
        $(OBJDIR)\cfile.obj \
        $(OBJDIR)\bfile.obj \
        $(OBJDIR)\bset.obj \
        $(OBJDIR)\cfile.obj \