+static const char *get_record_format(ZOOM_record rec, int *len,
+ Z_NamePlusRecord *npr,
+ int marctype, const char *charset,
+ const char *format)
+{
+ const char *res = return_record(rec, len, npr, marctype, charset);
+#if YAZ_HAVE_XML2
+ if (*format == '1' && len)
+ {
+ /* try to XML format res */
+ xmlDocPtr doc;
+ xmlKeepBlanksDefault(0); /* get get xmlDocFormatMemory to work! */
+ doc = xmlParseMemory(res, *len);
+ if (doc)
+ {
+ if (rec->xml_mem)
+ xmlFree(rec->xml_mem);
+ xmlDocDumpFormatMemory(doc, &rec->xml_mem, &rec->xml_size, 1);
+ xmlFreeDoc(doc);
+ res = (char *) rec->xml_mem;
+ *len = rec->xml_size;
+ }
+ }
+#endif
+ return res;
+}
+
+