-
-static const char *snippet_doc(struct recRetrieveCtrl *p, int text_mode,
- int window_size)
-{
- const char *xml_doc_str;
- int ord = 0;
- WRBUF wrbuf = wrbuf_alloc();
- zebra_snippets *res =
- zebra_snippets_window(p->doc_snippet, p->hit_snippet, window_size);
- zebra_snippet_word *w = zebra_snippets_list(res);
-
- if (text_mode)
- wrbuf_printf(wrbuf, "\'");
- else
- wrbuf_printf(wrbuf, "<snippet xmlns='%s'>\n", zebra_xslt_ns);
- for (; w; w = w->next)
- {
- if (ord == 0)
- ord = w->ord;
- else if (ord != w->ord)
-
- break;
- if (text_mode)
- wrbuf_printf(wrbuf, "%s%s%s ",
- w->match ? "*" : "",
- w->term,
- w->match ? "*" : "");
- else
- {
- wrbuf_printf(wrbuf, " <term ord='%d' seqno='" ZINT_FORMAT "' %s>",
- w->ord, w->seqno,
- (w->match ? "match='1'" : ""));
- wrbuf_xmlputs(wrbuf, w->term);
- wrbuf_printf(wrbuf, "</term>\n");
- }
- }
- if (text_mode)
- wrbuf_printf(wrbuf, "\'");
- else
- wrbuf_printf(wrbuf, "</snippet>\n");
-
- xml_doc_str = odr_strdup(p->odr, wrbuf_buf(wrbuf));
-
- zebra_snippets_destroy(res);
- wrbuf_free(wrbuf, 1);
- return xml_doc_str;
-}
-