18 #include <libxml/parser.h>
19 #include <libxml/tree.h>
35 const char *cp2 = strstr(cp,
"@attr 1=");
39 if (!strncmp(cp, field, length) &&
40 (cp[length] ==
' ' || cp[length] ==
',' || cp[length] ==
'\0'))
49 while (*cp && *cp !=
',')
61 const char **start,
const char **sort)
69 int general_start = -1;
70 int general_sortorder = -1;
71 int general_limit = -1;
73 for (i = 0; i < fl->
num; i++)
93 general_limit = av.
limit;
96 general_start = av.
start;
101 if (general_limit != -1)
104 sprintf(tmp,
"%d,", general_limit);
112 if (general_start != -1)
115 sprintf(tmp,
"%d", general_start);
118 if (general_sortorder == 1)
128 int general_limit = -1;
132 const char *cp = *
limit;
135 while (sscanf(cp,
"%d%n", &val, &nor) >= 1 && nor > 0)
141 const char *cp0 = ++cp;
142 while (*cp && *cp !=
',')
144 sprintf(tmp,
"@attr 3=%d", val);
149 sprintf(tmp,
"@attr 4=%s", *
start);
152 if (*sort && !strcmp(*sort,
"alphanumeric"))
165 if (*sort || *
start || general_limit != -1)
169 if (*sort && !strcmp(*sort,
"alphanumeric"))
173 if (general_limit != -1)
198 "http://docs.oasis-open.org/ns/search-ws/facetedResults";
199 xmlNode *p1 = xmlNewChild(n, 0, BAD_CAST
"facetedResults", 0);
200 xmlNsPtr ns_fr = xmlNewNs(p1, BAD_CAST ns, BAD_CAST
"fr");
201 for (i = 0; i < fl->
num; i++)
204 xmlNode *p2 = xmlNewChild(p1, ns_fr, BAD_CAST
"facet", 0);
211 p3 = xmlNewChild(p2, 0, BAD_CAST
"terms", 0);
216 xmlNode *p4 = xmlNewChild(p3, 0, BAD_CAST
"term", 0);
233 for (p1 = n->children; p1; p1 = p1->next)
242 for (p1 = n->children; p1; p1 = p1->next)
245 char *index_name = 0;
246 xmlNode *p_terms = 0;
247 xmlNode *p2 = p1->children;
254 for (; p2; p2 = p2->next)
268 for (p = p_terms->children; p; p = p->next)
277 for (p = p_terms->children; p; p = p->next)
283 xmlNode *p2 = p->children;
284 for (; p2; p2 = p2->next)
Z_FacetTerm * facet_term_create_cstr(ODR odr, const char *cstr, Odr_int freq)
void yaz_facet_attr_init(struct yaz_facet_attr *attr_values)
void yaz_facet_attr_get_z_attributes(const Z_AttributeList *attributes, struct yaz_facet_attr *av)
Header for the facet utilities.
char * odr_strdup(ODR o, const char *str)
void * odr_malloc(ODR o, size_t size)
Z_FacetList * yaz_pqf_parse_facet_list(ODR o, const char *qbuf)
Z_AttributeList * zget_AttributeList_use_string(ODR o, const char *name)
creates AttributeList with type=1(use) and string value
int yaz_match_xsd_element(xmlNodePtr ptr, const char *elem)
void add_xsd_integer(xmlNodePtr ptr, const char *elem, const Odr_int *val)
xmlNodePtr add_xsd_string(xmlNodePtr ptr, const char *elem, const char *val)
int yaz_match_xsd_string(xmlNodePtr ptr, const char *elem, ODR o, char **val)
xmlNodePtr add_xsd_string_n(xmlNodePtr ptr, const char *elem, const char *val, int len)
int yaz_match_xsd_integer(xmlNodePtr ptr, const char *elem, ODR o, Odr_int **val)
void yaz_sru_facet_request(ODR o, Z_FacetList **facetList, const char **limit, const char **start, const char **sort)
void yaz_sru_facet_response(ODR o, Z_FacetList **facetList, xmlNodePtr n)
static void insert_field(WRBUF w, const char *field, size_t length, const char *attr)
Z_AttributeList * attributes
void wrbuf_destroy(WRBUF b)
destroy WRBUF and its buffer
void wrbuf_insert(WRBUF b, size_t pos, const char *buf, size_t size)
inserts buffer into WRBUF at some position
WRBUF wrbuf_alloc(void)
construct WRBUF
void wrbuf_printf(WRBUF b, const char *fmt,...)
writes printf result to WRBUF
void wrbuf_cut_right(WRBUF b, size_t no_to_remove)
cut size of WRBUF
const char * wrbuf_cstr(WRBUF b)
returns WRBUF content as C-string
void wrbuf_puts(WRBUF b, const char *buf)
appends C-string to WRBUF
void wrbuf_write(WRBUF b, const char *buf, size_t size)
append constant size buffer to WRBUF
Header for WRBUF (growing buffer)