+ const char *name = 0;
+ const char *value = 0;
+ char *qvalue = 0;
+ if (ptr->type != XML_ELEMENT_NODE)
+ continue;
+ if (strcmp((const char *) ptr->name, "param"))
+ {
+ wrbuf_printf(wr_error, "Bad element '%s'"
+ "Expected param.", ptr->name);
+ nmem_destroy(nmem);
+ return 0;
+ }
+ for (attr = ptr->properties; attr; attr = attr->next)
+ {
+ if (!xmlStrcmp(attr->name, BAD_CAST "name") &&
+ attr->children && attr->children->type == XML_TEXT_NODE)
+ name = (const char *) attr->children->content;
+ else if (!xmlStrcmp(attr->name, BAD_CAST "value") &&
+ attr->children && attr->children->type == XML_TEXT_NODE)
+ value = (const char *) attr->children->content;
+ else
+ {
+ wrbuf_printf(wr_error, "Bad attribute '%s'"
+ "Expected name or value.", attr->name);
+ nmem_destroy(nmem);
+ return 0;
+ }
+ }
+ if (!name || !value)
+ {
+ wrbuf_printf(wr_error, "Missing attributes name or value");
+ nmem_destroy(nmem);
+ return 0;
+ }
+ if (no_parms >= max_parms)
+ {
+ wrbuf_printf(wr_error, "Too many parameters given");
+ nmem_destroy(nmem);
+ return 0;
+ }
+
+ qvalue = nmem_malloc(nmem, strlen(value) + 3);
+ strcpy(qvalue, "\'");
+ strcat(qvalue, value);
+ strcat(qvalue, "\'");
+
+ info->xsl_parms[2 * no_parms] = nmem_strdup(nmem, name);
+ info->xsl_parms[2 * no_parms + 1] = qvalue;
+ no_parms++;
+ }
+ info->xsl_parms[2 * no_parms] = 0;
+
+ if (!stylesheet)
+ {
+ wrbuf_printf(wr_error, "Element <xslt>: "
+ "attribute 'stylesheet' expected");
+ nmem_destroy(nmem);
+ }
+ else
+ {
+ char fullpath[1024];
+ xsltStylesheetPtr xsp;
+ if (!yaz_filepath_resolve(stylesheet, path, 0, fullpath))
+ {
+ wrbuf_printf(wr_error, "Element <xslt stylesheet=\"%s\"/>:"
+ " could not locate stylesheet '%s'",
+ stylesheet, stylesheet);
+ if (path)
+ wrbuf_printf(wr_error, " with path '%s'", path);
+
+ nmem_destroy(nmem);
+ return 0;
+ }
+ info->xsp_doc = xmlParseFile(fullpath);
+ if (!info->xsp_doc)
+ {
+ wrbuf_printf(wr_error, "Element: <xslt stylesheet=\"%s\"/>:"
+ " xml parse failed: %s", stylesheet, fullpath);
+ if (path)
+ wrbuf_printf(wr_error, " with path '%s'", path);
+ nmem_destroy(nmem);
+ return 0;
+ }
+ /* need to copy this before passing it to the processor. It will
+ be encapsulated in the xsp and destroyed by xsltFreeStylesheet */
+ xsp = xsltParseStylesheetDoc(xmlCopyDoc(info->xsp_doc, 1));
+ if (!xsp)
+ {
+ wrbuf_printf(wr_error, "Element: <xslt stylesheet=\"%s\"/>:"
+ " xslt parse failed: %s", stylesheet, fullpath);
+ if (path)
+ wrbuf_printf(wr_error, " with path '%s'", path);
+ wrbuf_printf(wr_error, " ("
+#if YAZ_HAVE_EXSLT
+
+ "EXSLT enabled"
+#else
+ "EXSLT not supported"
+#endif
+ ")");
+ xmlFreeDoc(info->xsp_doc);
+ nmem_destroy(info->nmem);
+ }
+ else
+ {
+ xsltFreeStylesheet(xsp);
+ return info;
+ }