+
+ tagname = res_get_def(p->res, "tagrank", "rank");
+ if (strcmp(tagname, "0") && p->score >= 0 &&
+ (dnew = data1_insert_taggeddata(p->dh, node, node, tagname, mem)))
+ {
+ logf (LOG_DEBUG, "grs_retrieve: %s", tagname);
+ dnew->u.data.what = DATA1I_num;
+ dnew->u.data.data = dnew->lbuf;
+ sprintf(dnew->u.data.data, "%d", p->score);
+ dnew->u.data.len = strlen(dnew->u.data.data);
+ }
+
+ tagname = res_get_def(p->res, "tagsysno", "localControlNumber");
+ if (strcmp(tagname, "0") && p->localno > 0 &&
+ (dnew = data1_insert_taggeddata(p->dh, node, node, tagname, mem)))
+ {
+ logf (LOG_DEBUG, "grs_retrieve: %s", tagname);
+ dnew->u.data.what = DATA1I_text;
+ dnew->u.data.data = dnew->lbuf;
+ sprintf(dnew->u.data.data, "%d", p->localno);
+ dnew->u.data.len = strlen(dnew->u.data.data);
+ }
+
+ if (p->comp && p->comp->which == Z_RecordComp_complex &&
+ p->comp->u.complex->generic &&
+ p->comp->u.complex->generic->schema)
+ {
+ oident *oe = oid_getentbyoid (p->comp->u.complex->generic->schema);
+ if (oe)
+ requested_schema = oe->value;
+ }
+
+ /* If schema has been specified, map if possible, then check that
+ * we got the right one
+ */
+ if (requested_schema != VAL_NONE)
+ {
+ logf (LOG_DEBUG, "grs_retrieve: schema mapping");
+ for (map = node->u.root.absyn->maptabs; map; map = map->next)
+ {
+ if (map->target_absyn_ref == requested_schema)
+ {
+ onode = node;
+ if (!(node = data1_map_record(p->dh, onode, map, mem)))
+ {
+ p->diagnostic = 14;
+ nmem_destroy (mem);
+ return 0;
+ }
+ break;
+ }
+ }
+ if (node->u.root.absyn &&
+ requested_schema != node->u.root.absyn->reference)
+ {
+ p->diagnostic = 238;
+ nmem_destroy (mem);
+ return 0;
+ }
+ }
+ /*
+ * Does the requested format match a known syntax-mapping? (this reflects
+ * the overlap of schema and formatting which is inherent in the MARC
+ * family)
+ */
+ logf (LOG_DEBUG, "grs_retrieve: syntax mapping");
+ for (map = node->u.root.absyn->maptabs; map; map = map->next)