+static int process_meta(struct filter_info *tinfo, xmlDocPtr doc, xmlNodePtr node,
+ struct recRetrieveCtrl *retctr)
+{
+
+ if (node->type == XML_ELEMENT_NODE && node->ns && node->ns->href &&
+ 0 == XML_STRCMP(node->ns->href, zebra_dom_ns))
+ {
+ if (0 == XML_STRCMP(node->name, "meta"))
+ {
+ const char *element_set_name = 0;
+
+ struct _xmlAttr *attr;
+ for (attr = node->properties; attr; attr = attr->next)
+ {
+ if (attr_content(attr, "name", &element_set_name))
+ ;
+ else
+ {
+ dom_log(YLOG_WARN, tinfo, node,
+ "bad attribute @%s, expected @name", attr->name);
+ }
+ }
+ if (element_set_name)
+ {
+ WRBUF result = wrbuf_alloc();
+ WRBUF addinfo = wrbuf_alloc();
+ const Odr_oid *input_format = yaz_oid_recsyn_xml;
+ const Odr_oid *output_format = 0;
+ int ret;
+
+ ret = retctr->special_fetch(retctr->handle,
+ element_set_name,
+ input_format, &output_format,
+ result, addinfo);
+ if (ret == 0)
+ {
+ xmlDocPtr sub_doc =
+ xmlParseMemory(wrbuf_buf(result), wrbuf_len(result));
+ if (sub_doc)
+ {
+ xmlNodePtr t = xmlDocGetRootElement(sub_doc);
+ xmlReplaceNode(node, xmlCopyNode(t, 1));
+ xmlFreeDoc(sub_doc);
+ }
+ }
+ wrbuf_destroy(result);
+ wrbuf_destroy(addinfo);
+ }
+ }
+ }
+ for (node = node->children; node; node = node->next)
+ process_meta(tinfo, doc, node, retctr);
+ return 0;
+}
+