+
+static int match_node_and_attr (data1_node *c, const char *spec)
+{
+
+ char predicate[64];
+ char elem[64];
+ char attr[64];
+ char value[64];
+ char dummy_ch;
+
+ data1_tag *tag = 0;
+ if (c->u.tag.element)
+ tag = c->u.tag.element->tag;
+
+ *predicate = '\0';
+ sscanf(spec, "%63[^[]%c%63[^]]", elem, &dummy_ch, predicate);
+ if (data1_matchstr(elem, tag ? tag->value.string : c->u.tag.tag))
+ return 0;
+
+ if (*predicate == '\0')
+ return 1;
+ else if (sscanf(predicate, "@%63[^=]=%63s", attr, value) == 2)
+ {
+ data1_xattr *xa;
+ for (xa = c->u.tag.attributes; xa; xa = xa->next)
+ if (!strcmp(xa->name, attr) &&
+ !strcmp(xa->value, value))
+ return 1;
+ return 0;
+ }
+ else if (sscanf(predicate, "@%63s", attr) == 1)
+ {
+ data1_xattr *xa;
+ for (xa = c->u.tag.attributes; xa; xa = xa->next)
+ if (!strcmp(xa->name, attr))
+ return 1;
+ }
+ else
+ {
+ yaz_log(YLOG_WARN, "Bad simpleelement component: '%s'", spec);
+ }
+ return 0;
+}