normalize_record_t normalize_cache_get(normalize_cache_t nc,
struct conf_service *service,
- const char *spec, int embed)
+ const char *spec)
{
normalize_record_t nt;
struct cached_item *ci;
nt = ci->nt;
else
{
- nt = normalize_record_create(service, spec, embed);
+ nt = normalize_record_create(service, spec);
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, int embed);
+ const char *spec);
void normalize_cache_destroy(normalize_cache_t nc);
#endif
};
normalize_record_t normalize_record_create(struct conf_service *service,
- const char *spec, int embed)
+ const char *spec)
{
NMEM nmem = nmem_create();
normalize_record_t nt = nmem_malloc(nmem, sizeof(*nt));
struct normalize_step **m = &nt->steps;
int no_errors = 0;
+ int embed = 0;
+
+ if (*spec == '<')
+ embed = 1;
nt->nmem = nmem;
struct conf_service;
normalize_record_t normalize_record_create(struct conf_service *service,
- const char *spec, int embed);
+ const char *spec);
void normalize_record_destroy(normalize_record_t nt);
{
const char *s;
- 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)))
+ if (sdb->settings[PZ_XSLT] &&
+ (s = session_setting_oneval(sdb, PZ_XSLT)))
{
char auto_stylesheet[256];
}
}
sdb->map = normalize_cache_get(se->normalize_cache,
- se->service, s, 0);
+ se->service, s);
if (!sdb->map)
return -1;
}
"pz:sortmap:",
"pz:present_chunk",
"pz:block_timeout",
- "pz:embed_xslt",
0
};
continue;
if (!strcmp((const char *) n->name, "set"))
{
+ xmlNode *root = n->children;
struct setting set;
char *name = (char *) xmlGetProp(n, (xmlChar *) "name");
char *target = (char *) xmlGetProp(n, (xmlChar *) "target");
char *value = (char *) xmlGetProp(n, (xmlChar *) "value");
char *user = (char *) xmlGetProp(n, (xmlChar *) "user");
char *precedence = (char *) xmlGetProp(n, (xmlChar *) "precedence");
+ xmlChar *buf_out = 0;
+
+ set.next = 0;
if (precedence)
set.precedence = atoi((char *) precedence);
set.target = target ? target : targeta;
set.name = name ? name : namea;
- set.value = value ? value : valuea;
- set.next = 0;
+
+ while (root && root->type != XML_ELEMENT_NODE)
+ root = root->next;
+ if (!root)
+ set.value = value ? value : valuea;
+ else
+ { /* xml document content for this setting */
+ xmlDoc *doc = xmlNewDoc(BAD_CAST "1.0");
+ if (!doc)
+ {
+ if (set.name)
+ yaz_log(YLOG_WARN, "bad XML content for setting "
+ "name=%s", set.name);
+ else
+ yaz_log(YLOG_WARN, "bad XML content for setting");
+ ret_val = -1;
+ }
+ else
+ {
+ int len_out;
+ xmlDocSetRootElement(doc, xmlCopyNode(root, 1));
+ xmlDocDumpMemory(doc, &buf_out, &len_out);
+ /* xmlDocDumpMemory 0-terminates */
+ set.value = (char *) buf_out;
+ xmlFreeDoc(doc);
+ }
+ }
if (set.name && set.value && set.target)
(*fun)(client_data, &set);
yaz_log(YLOG_WARN, "missing name/value/target for setting");
ret_val = -1;
}
+ xmlFree(buf_out);
xmlFree(name);
xmlFree(precedence);
xmlFree(value);
#define PZ_SORTMAP 31
#define PZ_PRESENT_CHUNK 32
#define PZ_BLOCK_TIMEOUT 33
-#define PZ_EMBED_XSLT 34
-#define PZ_MAX_EOF 35
+#define PZ_MAX_EOF 34
struct setting
{