From: Adam Dickmeiss Date: Tue, 4 May 2010 10:14:16 +0000 (+0200) Subject: record_conv: copy XML doc before passing to XSLT X-Git-Tag: v4.0.7~3 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=8a3b23f59f0d6558128f35b0973e08ec933fc012;p=yaz-moved-to-github.git record_conv: copy XML doc before passing to XSLT The record_conv reads the XSL file in two steps.. Reads XSL as XML Document.. Then passes that to XSL at each invocation to ensure the record_conv is multi-threaded. This patch ensures that XML document is copied before passed to XSL (instead of after). This makes at least one XSL transform behave differently (and correct). --- diff --git a/src/record_conv.c b/src/record_conv.c index dbca156..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;