X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Frecord_conv.c;h=9da5a448ea9f4950b596e56eb102c2c8b74535cd;hp=41e98819df185cbced1961c3e02be7fb9bb6f7b5;hb=a5795a2df2095d5a44b012a59426e7b906db3ec9;hpb=77f27a99f17bdd5e6fc4d8a202ecc6da4ef95660 diff --git a/src/record_conv.c b/src/record_conv.c index 41e9881..9da5a44 100644 --- a/src/record_conv.c +++ b/src/record_conv.c @@ -192,7 +192,9 @@ static int conv_xslt(yaz_record_conv_t p, const xmlNode *ptr) wrbuf_printf(p->wr_error, " with path '%s'", p->path); return -1; } - xsp = xsltParseStylesheetDoc(xsp_doc); + /* need to copy this before passing it to the processor. It will + be encapsulated in the xsp and destroyed by xsltFreeStylesheet */ + xsp = xsltParseStylesheetDoc(xmlCopyDoc(xsp_doc, 1)); if (!xsp) { wrbuf_printf(p->wr_error, "Element: :" @@ -207,14 +209,15 @@ static int conv_xslt(yaz_record_conv_t p, const xmlNode *ptr) "EXSLT not supported" #endif ")"); + xmlFreeDoc(xsp_doc); return -1; } else { struct yaz_record_conv_rule *r = add_rule(p, YAZ_RECORD_CONV_RULE_XSLT); - r->u.xslt.xsp_doc = xmlCopyDoc(xsp_doc, 1); - xsltFreeStylesheet(xsp); /* will free xsp_doc */ + r->u.xslt.xsp_doc = xsp_doc; + xsltFreeStylesheet(xsp); } } return 0; @@ -304,6 +307,12 @@ static int conv_marc(yaz_record_conv_t p, const xmlNode *ptr) if (input_charset && !output_charset) output_charset = "utf-8"; } + else if (!strcmp(output_format, "turbomarc")) + { + output_format_mode = YAZ_MARC_TURBOMARC; + if (input_charset && !output_charset) + output_charset = "utf-8"; + } else if (!strcmp(output_format, "marc")) { output_format_mode = YAZ_MARC_ISO2709; @@ -473,7 +482,7 @@ static int yaz_record_conv_record_rule(yaz_record_conv_t p, ret = -1; } else if (r->u.marc.input_format == YAZ_MARC_MARCXML || - r->u.marc.input_format == YAZ_MARC_TMARCXML) + r->u.marc.input_format == YAZ_MARC_TURBOMARC) { xmlDocPtr doc = xmlParseMemory(wrbuf_buf(record), wrbuf_len(record)); @@ -484,7 +493,7 @@ static int yaz_record_conv_record_rule(yaz_record_conv_t p, } else { - ret = yaz_marc_read_xml(mt, xmlDocGetRootElement(doc)); + ret = yaz_marc_read_xml(mt, xmlDocGetRootElement(doc)); if (ret) wrbuf_printf(p->wr_error, "yaz_marc_read_xml failed"); } @@ -526,7 +535,7 @@ static int yaz_record_conv_record_rule(yaz_record_conv_t p, xmlChar *out_buf = 0; int out_len; -#if YAZ_HAVE_XSLTSAVERESULTTOSTRING +#if HAVE_XSLTSAVERESULTTOSTRING xsltSaveResultToString(&out_buf, &out_len, res, xsp); #else xmlDocDumpFormatMemory (res, &out_buf, &out_len, 1);