- for (p = registered_sets; p; p = p->next)
- if (p->reference == set && (r = getatt(p, att)))
- break;;
- if (!p)
- return 0;
- res.attset_ordinal = r->parent->ordinal;
- res.local_attribute = r->local;
- return &res;
+ else
+ {
+ *ord = zebraExplain_lookup_attr_str(zh->reg->zei, cat, 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);
+ res = ZEBRA_FAIL;
+ }
+ else
+ {
+ yaz_log(YLOG_LOG, "zebra_apt_get_ord OK xpath=%s index_type=%c",
+ xpath_use, index_type);
+
+ }
+ }
+ return res;
+}
+
+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,
+ zinfo_index_category_sort,
+ 's', VAL_BIB1, ord)== ZEBRA_OK)
+ return ZEBRA_OK;
+ if (zebra_attr_list_get_ord(zh, sortAttributes->list,
+ zinfo_index_category_sort,
+ 'S', VAL_BIB1, ord)== ZEBRA_OK)
+ return ZEBRA_OK;
+ return ZEBRA_FAIL;