+ case YAZ_MARC_DATAFIELD:
+ wrbuf_printf(wr, " <datafield tag=\"");
+ wrbuf_iconv_write_cdata(wr, mt->iconv_cd, n->u.datafield.tag,
+ strlen(n->u.datafield.tag));
+ wrbuf_printf(wr, "\"");
+ if (n->u.datafield.indicator)
+ {
+ int i;
+ for (i = 0; n->u.datafield.indicator[i]; i++)
+ {
+ wrbuf_printf(wr, " ind%d=\"", i+1);
+ wrbuf_iconv_write_cdata(wr, mt->iconv_cd,
+ n->u.datafield.indicator+i, 1);
+ wrbuf_iconv_puts(wr, mt->iconv_cd, "\"");
+ }
+ }
+ wrbuf_printf(wr, ">\n");
+ for (s = n->u.datafield.subfields; s; s = s->next)
+ {
+ /* if identifier length is 2 (most MARCs),
+ the code is a single character .. However we've
+ seen multibyte codes, so see how big it really is */
+ size_t using_code_len =
+ (identifier_length != 2) ? identifier_length - 1
+ :
+ cdata_one_character(mt, s->code_data);
+
+ wrbuf_iconv_puts(wr, mt->iconv_cd, " <subfield code=\"");
+ wrbuf_iconv_write_cdata(wr, mt->iconv_cd,
+ s->code_data, using_code_len);
+ wrbuf_iconv_puts(wr, mt->iconv_cd, "\">");
+ wrbuf_iconv_write_cdata(wr, mt->iconv_cd,
+ s->code_data + using_code_len,
+ strlen(s->code_data + using_code_len));
+ marc_iconv_reset(mt, wr);
+ wrbuf_iconv_puts(wr, mt->iconv_cd, "</subfield>");
+ wrbuf_puts(wr, "\n");
+ }
+ wrbuf_printf(wr, " </datafield>\n");
+ break;
+ case YAZ_MARC_CONTROLFIELD:
+ wrbuf_printf(wr, " <controlfield tag=\"");
+ wrbuf_iconv_write_cdata(wr, mt->iconv_cd, n->u.controlfield.tag,
+ strlen(n->u.controlfield.tag));
+ wrbuf_iconv_puts(wr, mt->iconv_cd, "\">");
+ wrbuf_iconv_puts(wr, mt->iconv_cd, n->u.controlfield.data);
+
+ marc_iconv_reset(mt, wr);
+ wrbuf_iconv_puts(wr, mt->iconv_cd, "</controlfield>");
+ wrbuf_puts(wr, "\n");