27 #include <libxml/parser.h>
28 #include <libxml/tree.h>
30 #include <yaz/yaz-util.h>
32 #include <yaz/snprintf.h>
33 #include <yaz/xml_include.h>
41 xsltStylesheetPtr
xsp;
50 if (!strcmp(
id, sx->
id))
58 for (; sx; sx = sx->
next)
59 xsltFreeStylesheet(sx->
xsp);
65 xmlNode *root = n->children;
68 struct _xmlAttr *attr;
69 for (attr = n->properties; attr; attr = attr->next)
70 if (!strcmp((
const char *) attr->name,
"id"))
71 id = (
const char *) attr->children->content;
74 yaz_log(YLOG_FATAL,
"Invalid attribute %s for xslt element",
75 (
const char *) attr->name);
80 yaz_log(YLOG_FATAL,
"Missing attribute id for xslt element");
83 while (root && root->type != XML_ELEMENT_NODE)
87 yaz_log(YLOG_FATAL,
"Missing content for xslt element");
90 for (sx = service->xslt_list; sx; sx = sx->next)
91 if (!strcmp(sx->id,
id))
93 yaz_log(YLOG_FATAL,
"Multiple xslt with id=%s",
id);
97 sx = nmem_malloc(service->nmem,
sizeof(*sx));
98 sx->id = nmem_strdup(service->nmem,
id);
99 sx->next = service->xslt_list;
100 service->xslt_list = sx;
102 xsp_doc = xmlNewDoc(BAD_CAST
"1.0");
103 xmlDocSetRootElement(xsp_doc, xmlCopyNode(root, 1));
104 sx->xsp = xsltParseStylesheetDoc(xsp_doc);
108 yaz_log(YLOG_FATAL,
"Failed to parse XSLT");
int service_xslt_config(struct conf_service *service, xmlNode *n)
void service_xslt_destroy(struct conf_service *service)
xsltStylesheetPtr service_xslt_get(struct conf_service *service, const char *id)
struct service_xslt * xslt_list
struct service_xslt * next