normalize_record_t normalize_cache_get(normalize_cache_t nc,
struct conf_service *service,
- const char *spec)
+ const char *spec, int embed)
{
normalize_record_t nt;
struct cached_item *ci;
nt = ci->nt;
else
{
- nt = normalize_record_create(service, spec);
+ nt = normalize_record_create(service, spec, embed);
if (nt)
{
ci = nmem_malloc(nc->nmem, sizeof(*ci));
normalize_record_t normalize_cache_get(normalize_cache_t nc,
struct conf_service *service,
- const char *spec);
+ const char *spec, int embed);
void normalize_cache_destroy(normalize_cache_t nc);
#endif
};
normalize_record_t normalize_record_create(struct conf_service *service,
- const char *spec)
+ const char *spec, int embed)
{
NMEM nmem = nmem_create();
normalize_record_t nt = nmem_malloc(nmem, sizeof(*nt));
struct normalize_step **m = &nt->steps;
- int i, num;
int no_errors = 0;
- char **stylesheets;
- struct conf_config *conf = service->server->config;
nt->nmem = nmem;
- nmem_strsplit(nt->nmem, ",", spec, &stylesheets, &num);
- for (i = 0; i < num; i++)
+ if (embed)
{
- WRBUF fname = conf_get_fname(conf, stylesheets[i]);
-
- *m = nmem_malloc(nt->nmem, sizeof(**m));
- (*m)->marcmap = NULL;
- (*m)->stylesheet = NULL;
-
- (*m)->stylesheet2 = service_xslt_get(service, stylesheets[i]);
- if ((*m)->stylesheet2)
- ;
- else if (!strcmp(&stylesheets[i][strlen(stylesheets[i])-4], ".xsl"))
- {
- if (!((*m)->stylesheet =
- xsltParseStylesheetFile((xmlChar *) wrbuf_cstr(fname))))
- {
- yaz_log(YLOG_FATAL|YLOG_ERRNO, "Unable to load stylesheet: %s",
- stylesheets[i]);
+ xmlDoc *xsp_doc = xmlParseMemory(spec, strlen(spec));
+
+ if (!xsp_doc)
+ no_errors++;
+ {
+ *m = nmem_malloc(nt->nmem, sizeof(**m));
+ (*m)->marcmap = NULL;
+ (*m)->stylesheet = NULL;
+ (*m)->stylesheet2 = NULL;
+
+
+ (*m)->stylesheet = xsltParseStylesheetDoc(xsp_doc);
+ if (!(*m)->stylesheet)
no_errors++;
- }
+ m = &(*m)->next;
}
- else if (!strcmp(&stylesheets[i][strlen(stylesheets[i])-5], ".mmap"))
+ }
+ else
+ {
+ struct conf_config *conf = service->server->config;
+ int i, num;
+ char **stylesheets;
+ nmem_strsplit(nt->nmem, ",", spec, &stylesheets, &num);
+
+ for (i = 0; i < num; i++)
{
- if (!((*m)->marcmap = marcmap_load(wrbuf_cstr(fname), nt->nmem)))
+ WRBUF fname = conf_get_fname(conf, stylesheets[i]);
+
+ *m = nmem_malloc(nt->nmem, sizeof(**m));
+ (*m)->marcmap = NULL;
+ (*m)->stylesheet = NULL;
+
+ (*m)->stylesheet2 = service_xslt_get(service, stylesheets[i]);
+ if ((*m)->stylesheet2)
+ ;
+ else if (!strcmp(&stylesheets[i][strlen(stylesheets[i])-4], ".xsl"))
+ {
+ if (!((*m)->stylesheet =
+ xsltParseStylesheetFile((xmlChar *) wrbuf_cstr(fname))))
+ {
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "Unable to load stylesheet: %s",
+ stylesheets[i]);
+ no_errors++;
+ }
+ }
+ else if (!strcmp(&stylesheets[i][strlen(stylesheets[i])-5], ".mmap"))
+ {
+ if (!((*m)->marcmap = marcmap_load(wrbuf_cstr(fname), nt->nmem)))
+ {
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "Unable to load marcmap: %s",
+ stylesheets[i]);
+ no_errors++;
+ }
+ }
+ else
{
- yaz_log(YLOG_FATAL|YLOG_ERRNO, "Unable to load marcmap: %s",
- stylesheets[i]);
+ yaz_log(YLOG_FATAL, "Cannot handle stylesheet: %s", stylesheets[i]);
no_errors++;
}
+
+ wrbuf_destroy(fname);
+ m = &(*m)->next;
}
- else
- {
- yaz_log(YLOG_FATAL, "Cannot handle stylesheet: %s", stylesheets[i]);
- no_errors++;
- }
-
- wrbuf_destroy(fname);
- m = &(*m)->next;
}
*m = 0; /* terminate list of steps */
struct conf_service;
normalize_record_t normalize_record_create(struct conf_service *service,
- const char *spec);
+ const char *spec, int embed);
void normalize_record_destroy(normalize_record_t nt);
// setting. However, this is not a realistic use scenario.
static int prepare_map(struct session *se, struct session_database *sdb)
{
- const char *s;
-
- if (sdb->settings && sdb->settings[PZ_XSLT] && !sdb->map &&
- (s = session_setting_oneval(sdb, PZ_XSLT)))
+ if (sdb->settings && !sdb->map)
{
- char auto_stylesheet[256];
+ const char *s;
- if (!strcmp(s, "auto"))
+ if (sdb->settings[PZ_EMBED_XSLT] &&
+ (s = session_setting_oneval(sdb, PZ_EMBED_XSLT)))
+ {
+ sdb->map = normalize_cache_get(se->normalize_cache,
+ se->service, s, 1);
+ if (!sdb->map)
+ return -1;
+ }
+ else if (sdb->settings[PZ_XSLT] &&
+ (s = session_setting_oneval(sdb, PZ_XSLT)))
{
- const char *request_syntax = session_setting_oneval(
- sdb, PZ_REQUESTSYNTAX);
- if (request_syntax)
+ char auto_stylesheet[256];
+
+ if (!strcmp(s, "auto"))
{
- char *cp;
- yaz_snprintf(auto_stylesheet, sizeof(auto_stylesheet),
- "%s.xsl", request_syntax);
- for (cp = auto_stylesheet; *cp; cp++)
+ const char *request_syntax = session_setting_oneval(
+ sdb, PZ_REQUESTSYNTAX);
+ if (request_syntax)
+ {
+ char *cp;
+ yaz_snprintf(auto_stylesheet, sizeof(auto_stylesheet),
+ "%s.xsl", request_syntax);
+ for (cp = auto_stylesheet; *cp; cp++)
+ {
+ /* deliberately only consider ASCII */
+ if (*cp > 32 && *cp < 127)
+ *cp = tolower(*cp);
+ }
+ s = auto_stylesheet;
+ }
+ else
{
- /* deliberately only consider ASCII */
- if (*cp > 32 && *cp < 127)
- *cp = tolower(*cp);
+ session_log(se, YLOG_WARN,
+ "No pz:requestsyntax for auto stylesheet");
}
- s = auto_stylesheet;
- }
- else
- {
- session_log(se, YLOG_WARN,
- "No pz:requestsyntax for auto stylesheet");
}
+ sdb->map = normalize_cache_get(se->normalize_cache,
+ se->service, s, 0);
+ if (!sdb->map)
+ return -1;
}
- sdb->map = normalize_cache_get(se->normalize_cache,
- se->service, s);
- if (!sdb->map)
- return -1;
}
return 0;
}
"pz:sortmap:",
"pz:present_chunk",
"pz:block_timeout",
+ "pz:embed_xslt",
0
};
#define PZ_SORTMAP 31
#define PZ_PRESENT_CHUNK 32
#define PZ_BLOCK_TIMEOUT 33
-#define PZ_MAX_EOF 34
+#define PZ_EMBED_XSLT 34
+#define PZ_MAX_EOF 35
struct setting
{