- org_len = 0;
-
- res = data1_mk_node (spec->dh, spec->m);
- res->parent = parent;
- res->which = DATA1N_data;
- res->u.data.what = DATA1I_text;
- res->u.data.len = 0;
- res->u.data.formatted_text = formatted_text;
-#if 0
- if (elen > DATA1_LOCALDATA)
- res->u.data.data = nmem_malloc (spec->m, elen);
- else
- res->u.data.data = res->lbuf;
- memcpy (res->u.data.data, ebuf, elen);
-#else
- res->u.data.data = 0;
-#endif
- res->root = parent->root;
-
- parent->last_child = res;
- if (spec->d1_stack[spec->d1_level])
- spec->d1_stack[spec->d1_level]->next = res;
+ data1_xattr **ap;
+ res = parent;
+ if (res->which != DATA1N_tag)
+ return;
+ /* sweep through exising attributes.. */
+ for (ap = &res->u.tag.attributes; *ap; ap = &(*ap)->next)
+ if (strlen((*ap)->name) == attribute_len &&
+ !memcmp((*ap)->name, attribute_str, attribute_len))
+ break;
+ if (!*ap)
+ {
+ /* new attribute. Create it with name + value */
+ *ap = nmem_malloc(spec->m, sizeof(**ap));
+
+ (*ap)->name = nmem_malloc(spec->m, attribute_len+1);
+ memcpy((*ap)->name, attribute_str, attribute_len);
+ (*ap)->name[attribute_len] = '\0';
+
+ (*ap)->value = nmem_malloc(spec->m, elen+1);
+ memcpy((*ap)->value, ebuf, elen);
+ (*ap)->value[elen] = '\0';
+ (*ap)->next = 0;
+ }