+static int get_mergekey_from_doc(xmlDoc *doc, xmlNode *root, const char *name,
+ struct conf_service *service, WRBUF norm_wr)
+{
+ xmlNode *n;
+ int no_found = 0;
+ for (n = root->children; n; n = n->next)
+ {
+ if (n->type != XML_ELEMENT_NODE)
+ continue;
+ if (!strcmp((const char *) n->name, "metadata"))
+ {
+ xmlChar *type = xmlGetProp(n, (xmlChar *) "type");
+ if (!strcmp(name, (const char *) type))
+ {
+ xmlChar *value = xmlNodeListGetString(doc, n->children, 1);
+ if (value)
+ {
+ const char *norm_str;
+ pp2_relevance_token_t prt =
+ pp2_relevance_tokenize(
+ service->mergekey_pct,
+ (const char *) value);
+
+ wrbuf_puts(norm_wr, name);
+ wrbuf_puts(norm_wr, "=");
+ while ((norm_str =
+ pp2_relevance_token_next(prt)))
+ {
+ if (*norm_str)
+ {
+ if (wrbuf_len(norm_wr))
+ wrbuf_puts(norm_wr, " ");
+ wrbuf_puts(norm_wr, norm_str);
+ }
+ }
+ xmlFree(value);
+ pp2_relevance_token_destroy(prt);
+ no_found++;
+ }
+ }
+ xmlFree(type);
+ }
+ }
+ return no_found;
+}
+