+ struct record_metadata *rec_md = record_metadata_create(nmem);
+ struct record_metadata_attr **attrp = &rec_md->attributes;
+
+ for (; attr; attr = attr->next)
+ {
+ 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 */
+ *attrp = nmem_malloc(nmem, sizeof(**attrp));
+ (*attrp)->name =
+ nmem_strdup(nmem, (const char *) attr->name);
+ (*attrp)->value =
+ nmem_strdup(nmem, (const char *) attr->children->content);
+ attrp = &(*attrp)->next;
+ }
+ }
+ }
+ *attrp = 0;
+
+ if (type == Metadata_type_generic)
+ {
+ char *p = nmem_strdup(nmem, value);
+
+ p = normalize7bit_generic(p, " ,/.:([");
+
+ rec_md->data.text.disp = p;
+ rec_md->data.text.sort = 0;
+ }
+ else if (type == Metadata_type_year || type == Metadata_type_date)
+ {
+ int first, last;
+ int longdate = 0;
+
+ if (type == Metadata_type_date)
+ longdate = 1;
+ if (extract7bit_dates((char *) value, &first, &last, longdate) < 0)
+ return 0;