+#if YAZ_HAVE_XSLT
+ else if (r->which == YAZ_RECORD_CONV_RULE_XSLT)
+ {
+ xmlDocPtr doc = xmlParseMemory(wrbuf_buf(record),
+ wrbuf_len(record));
+ if (!doc)
+ {
+ wrbuf_printf(p->wr_error, "xmlParseMemory failed");
+ ret = -1;
+ }
+ else
+ {
+ xmlDocPtr res = xsltApplyStylesheet(r->u.xslt.xsp, doc, 0);
+ if (res)
+ {
+ xmlChar *out_buf = 0;
+ int out_len;
+
+#if YAZ_HAVE_XSLTSAVERESULTTOSTRING
+ xsltSaveResultToString(&out_buf, &out_len, res,
+ r->u.xslt.xsp);
+#else
+ xmlDocDumpFormatMemory (res, &out_buf, &out_len, 1);
+#endif
+ if (!out_buf)
+ {
+ wrbuf_printf(p->wr_error,
+ "xsltSaveResultToString failed");
+ ret = -1;
+ }
+ else
+ {
+ wrbuf_rewind(record);
+ wrbuf_write(record, (const char *) out_buf, out_len);
+
+ xmlFree(out_buf);
+ }
+ xmlFreeDoc(res);
+ }
+ else
+ {
+ wrbuf_printf(p->wr_error, "xsltApplyStylesheet failed");
+ ret = -1;
+ }
+ xmlFreeDoc(doc);
+ }
+ }
+#endif