int output_format;
int debug;
int write_using_libxml2;
- int turbo_format;
enum yaz_collection_state enable_collection;
yaz_iconv_t iconv_cd;
char subfield_str[8];
n->u.controlfield.tag = nmem_text_node_cdata(ptr_tag, mt->nmem);
n->u.controlfield.data = nmem_text_node_cdata(ptr_data, mt->nmem);
}
+
+void yaz_marc_add_controlfield_turbo_xml(yaz_marc_t mt, const char *tag,
+ const xmlNode *ptr_data)
+{
+ struct yaz_marc_node *n = yaz_marc_add_node(mt);
+ n->which = YAZ_MARC_CONTROLFIELD;
+ n->u.controlfield.tag = tag;
+ n->u.controlfield.data = nmem_text_node_cdata(ptr_data, mt->nmem);
+}
+
#endif
switch(mt->output_format)
{
case YAZ_MARC_MARCXML:
+ case YAZ_MARC_TMARCXML:
wrbuf_printf(wr, "</collection>\n");
break;
case YAZ_MARC_XCHANGE:
int ret;
xmlNode *root_ptr;
- if (!mt->turbo_format)
+ if (yaz_marc_get_write_format(mt) == YAZ_MARC_MARCXML)
ret = yaz_marc_write_xml(mt, &root_ptr, ns, format, type);
- else
+ else // Check for Turbo XML
ret = yaz_marc_write_turbo_xml(mt, &root_ptr, ns, format, type);
if (ret == 0)
{
{
xmlNode *ptr;
struct yaz_marc_subfield *s;
- int turbo = mt->turbo_format;
+ int turbo = mt->output_format == YAZ_MARC_TMARCXML;
if (!turbo) {
ptr = xmlNewChild(record_ptr, ns_record, BAD_CAST "datafield", 0);
xmlNewProp(ptr, BAD_CAST "tag", BAD_CAST n->u.datafield.tag);
char field[10];
field[0] = 'd';
strncpy(field + 1, n->u.datafield.tag, 3);
+ field[4] = '\0';
ptr = xmlNewChild(record_ptr, ns_record, BAD_CAST field, 0);
}
if (n->u.datafield.indicator)
xmlNode *record_ptr;
xmlNsPtr ns_record;
WRBUF wr_cdata = 0;
- int turbo = mt->turbo_format;
+ int turbo = mt->output_format == YAZ_MARC_TMARCXML;
for (n = mt->nodes; n; n = n->next)
if (n->which == YAZ_MARC_LEADER)
{
char field[10];
field[0] = 'c';
strncpy(field + 1, n->u.controlfield.tag, 3);
+ field[4] = '\0';
ptr = xmlNewTextChild(record_ptr, ns_record,
BAD_CAST field,
BAD_CAST wrbuf_cstr(wr_cdata));
void yaz_marc_set_write_format(yaz_marc_t mt, int format)
{
- if (mt)
+ if (mt) {
mt->output_format = format;
+ // Force using libxml2
+ if (mt->output_format == YAZ_MARC_TMARCXML)
+ mt->write_using_libxml2 = 1;
+ }
}
int yaz_marc_get_write_format(yaz_marc_t mt)
*/
void yaz_marc_xml(yaz_marc_t mt, int xmlmode)
{
- if (mt)
- mt->output_format = xmlmode;
+ yaz_marc_set_write_format(mt, xmlmode);
}
mt->write_using_libxml2 = enable;
}
-void yaz_marc_write_turbo_format(yaz_marc_t mt, int enable)
-{
- mt->turbo_format = enable;
-}
-
int yaz_marc_is_turbo_format(yaz_marc_t mt)
{
- return mt->turbo_format;
+ return mt->output_format == YAZ_MARC_TMARCXML;
}