+ if (!input_format)
+ {
+ wrbuf_printf(p->wr_error, "Element <marc>: "
+ "attribute 'inputformat' required");
+ return -1;
+ }
+ else if (!strcmp(input_format, "marc"))
+ {
+ input_format_mode = YAZ_MARC_ISO2709;
+ }
+ else if (!strcmp(input_format, "xml"))
+ {
+ input_format_mode = YAZ_MARC_MARCXML;
+ /** Libxml2 generates UTF-8 encoding by default .
+ So we convert from UTF-8 to outputcharset (if defined)
+ */
+ if (!input_charset && output_charset)
+ input_charset = "utf-8";
+ }
+ else
+ {
+ wrbuf_printf(p->wr_error, "Element <marc inputformat='%s'>: "
+ " Unsupported input format"
+ " defined by attribute value",
+ input_format);
+ return -1;
+ }
+
+ if (!output_format)
+ {
+ wrbuf_printf(p->wr_error,
+ "Element <marc>: attribute 'outputformat' required");
+ return -1;
+ }
+ else if (!strcmp(output_format, "line"))
+ {
+ output_format_mode = YAZ_MARC_LINE;
+ }
+ else if (!strcmp(output_format, "marcxml"))
+ {
+ output_format_mode = YAZ_MARC_MARCXML;
+ if (input_charset && !output_charset)
+ output_charset = "utf-8";
+ }
+ else if (!strcmp(output_format, "marc"))
+ {
+ output_format_mode = YAZ_MARC_ISO2709;
+ }
+ else if (!strcmp(output_format, "marcxchange"))
+ {
+ output_format_mode = YAZ_MARC_XCHANGE;
+ if (input_charset && !output_charset)
+ output_charset = "utf-8";
+ }