+ struct yaz_facet_attr attrvalues;
+ yaz_facet_attr_init(&attrvalues);
+ attrvalues.limit = 10;
+ yaz_facet_attr_get_z_attributes(facet_list->elements[index]->attributes,
+ &attrvalues);
+ yaz_log(YLOG_LOG, "Attributes: %s limit=%d start=%d sort=%d",
+ attrvalues.useattr,
+ attrvalues.limit,
+ attrvalues.start,
+ attrvalues.sortorder);
+ if (attrvalues.errstring)
+ yaz_log(YLOG_LOG, "Error parsing attributes: %s", attrvalues.errstring);
+ if (attrvalues.limit > 0 && attrvalues.useattr) {
+ new_list->elements[new_index] = facet_field_create(odr, facet_list->elements[index]->attributes, attrvalues.limit);
+ addterms(odr, new_list->elements[new_index], attrvalues.useattr);
+ new_index++;
+ }
+ else {
+ yaz_log(YLOG_DEBUG, "Facet: skipping %s due to 0 limit.", attrvalues.useattr);
+ }
+
+ }
+ new_list->num = new_index;
+ if (new_index > 0) {
+ Z_OtherInformation *oi = odr_malloc(odr, sizeof(*oi));
+ Z_OtherInformationUnit *oiu = odr_malloc(odr, sizeof(*oiu));
+ oi->num_elements = 1;
+ oi->list = odr_malloc(odr, oi->num_elements * sizeof(*oi->list));
+ oiu->category = 0;
+ oiu->which = Z_OtherInfo_externallyDefinedInfo;
+ oiu->information.externallyDefinedInfo = odr_malloc(odr, sizeof(*oiu->information.externallyDefinedInfo));
+ oiu->information.externallyDefinedInfo->direct_reference = odr_oiddup(odr, yaz_oid_userinfo_facet_1);
+ oiu->information.externallyDefinedInfo->descriptor = 0;
+ oiu->information.externallyDefinedInfo->indirect_reference = 0;
+ oiu->information.externallyDefinedInfo->which = Z_External_userFacets;
+ oiu->information.externallyDefinedInfo->u.facetList = new_list;
+ oi->list[0] = oiu;
+ return oi;
+ }
+ return 0;
+}
+
+static void echo_extra_args(ODR stream,
+ Z_SRW_extra_arg *extra_args, char **extra_response)
+{
+ if (extra_args)
+ {
+ Z_SRW_extra_arg *a;
+ WRBUF response_xml = wrbuf_alloc();
+ wrbuf_puts(response_xml, "<extra>");
+ for (a = extra_args; a; a = a->next)
+ {
+ wrbuf_puts(response_xml, "<extra name=\"");
+ wrbuf_xmlputs(response_xml, a->name);
+ wrbuf_puts(response_xml, "\"");
+ if (a->value)
+ {
+ wrbuf_puts(response_xml, " value=\"");
+ wrbuf_xmlputs(response_xml, a->value);
+ wrbuf_puts(response_xml, "\"");
+ }
+ wrbuf_puts(response_xml, "/>");
+ }
+ wrbuf_puts(response_xml, "</extra>");
+ *extra_response = odr_strdup(stream, wrbuf_cstr(response_xml));
+ wrbuf_destroy(response_xml);