- // First normalize to XML
- if (sdb->yaz_marc)
- {
- char *buf;
- int len;
- if (rec->which != Z_External_octet)
- {
- yaz_log(YLOG_WARN, "Unexpected external branch, probably BER %s",
- db->url);
- return 0;
- }
- buf = (char*) rec->u.octet_aligned->buf;
- len = rec->u.octet_aligned->len;
- if (yaz_marc_read_iso2709(sdb->yaz_marc, buf, len) < 0)
- {
- yaz_log(YLOG_WARN, "Failed to decode MARC %s", db->url);
- return 0;
- }
-
- yaz_marc_write_using_libxml2(sdb->yaz_marc, 1);
- if (yaz_marc_write_xml(sdb->yaz_marc, &res,
- "http://www.loc.gov/MARC21/slim", 0, 0) < 0)
- {
- yaz_log(YLOG_WARN, "Failed to encode as XML %s",
- db->url);
- return 0;
- }
- rdoc = xmlNewDoc((xmlChar *) "1.0");
- xmlDocSetRootElement(rdoc, res);