From: Adam Dickmeiss Date: Thu, 28 Feb 2013 12:46:33 +0000 (+0100) Subject: New pz:metadata attribute, empty="empty-value" PAZ-858 X-Git-Tag: v1.6.26~8 X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=commitdiff_plain;h=b11fa102c0b666dc31946c7f5220775eac674d6b;p=pazpar2-moved-to-github.git New pz:metadata attribute, empty="empty-value" PAZ-858 With this attribute, Pazpar2 treates an empty pz:metadata type as having the value for "empty" - if empty! --- diff --git a/src/session.c b/src/session.c index e81c221..d8567ee 100644 --- a/src/session.c +++ b/src/session.c @@ -1410,10 +1410,11 @@ static struct record_metadata *record_metadata_init( { if (attr->children && attr->children->content) { - if (strcmp((const char *) attr->name, "type")) - { /* skip the "type" attribute.. Its value is already part of - the element in output (md-%s) and so repeating it here - is redundant */ + if (strcmp((const char *) attr->name, "type") + && strcmp((const char *) attr->name, "empty")) + { /* skip the "type" + "empty" attribute.. + The "Type" is already part of the element in output + (md-%s) and so repeating it here is redundant */ *attrp = nmem_malloc(nmem, sizeof(**attrp)); (*attrp)->name = nmem_strdup(nmem, (const char *) attr->name); @@ -1865,10 +1866,17 @@ static int ingest_to_cluster(struct client *cl, type = xmlGetProp(n, (xmlChar *) "type"); value = xmlNodeListGetString(xdoc, n->children, 1); - - if (!type || !value || !*value) + if (!type) continue; - + if (!value || !*value) + { + xmlChar *empty = xmlGetProp(n, (xmlChar *) "empty"); + if (!empty) + continue; + if (value) + xmlFree(value); + value = empty; + } md_field_id = conf_service_metadata_field_id(service, (const char *) type); if (md_field_id < 0)