X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fpazpar2_config.c;h=3b9d47a6278e47671aa4ff53dae2f277e384ac2e;hb=074ed4b3116930e53285769df06bd2b785825d71;hp=426627578cfb1f59b60956330fba9395326911ac;hpb=ca08c2d3db58c82d203a9f98070a67f67d9ea6c1;p=pazpar2-moved-to-github.git diff --git a/src/pazpar2_config.c b/src/pazpar2_config.c index 4266275..3b9d47a 100644 --- a/src/pazpar2_config.c +++ b/src/pazpar2_config.c @@ -1,5 +1,5 @@ /* This file is part of Pazpar2. - Copyright (C) 2006-2013 Index Data + Copyright (C) Index Data Pazpar2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include +#include #include #include @@ -511,6 +512,18 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, return 0; } + +static void service_add_metadata(xmlNode *n, int *num_metadata, int *num_sortkeys) +{ + xmlChar *sortkey = xmlGetProp(n, (xmlChar *) "sortkey"); + (*num_metadata)++; + + if (sortkey && strcmp((const char *) sortkey, "no")) + (*num_sortkeys)++; + xmlFree(sortkey); +} + + static struct conf_service *service_create_static(struct conf_server *server, xmlNode *node, const char *service_id) @@ -529,11 +542,18 @@ static struct conf_service *service_create_static(struct conf_server *server, if (n->type == XML_ELEMENT_NODE && !strcmp((const char *) n->name, "metadata")) { - xmlChar *sortkey = xmlGetProp(n, (xmlChar *) "sortkey"); - num_metadata++; - if (sortkey && strcmp((const char *) sortkey, "no")) - num_sortkeys++; - xmlFree(sortkey); + if (n->children) // This is a container, look at its contents. + { + xmlNode *m; + for (m = n->children; m; m = m->next) + { + if (m->type == XML_ELEMENT_NODE && + !strcmp((const char *) m->name, "metadata")) + service_add_metadata(m, &num_metadata, &num_sortkeys); + } + } + else // This is a metadata-element proper, count it right away. + service_add_metadata(n, &num_metadata, &num_sortkeys); } service = service_init(server, num_metadata, num_sortkeys, service_id); @@ -630,8 +650,17 @@ static struct conf_service *service_create_static(struct conf_server *server, } else if (!strcmp((const char *) n->name, (const char *) "metadata")) { - if (parse_metadata(service, n, &md_node, &sk_node)) - return 0; + if (n->children) // This is a container, look at its content. + { + xmlNode *m; + for (m = n->children; m; m = m->next) + if ((!strcmp((const char *) m->name, (const char *) "metadata"))) + if (parse_metadata(service, m, &md_node, &sk_node)) + return 0; + } + else // This is a metadata-element proper, count it right away. + if (parse_metadata(service, n, &md_node, &sk_node)) + return 0; } else if (!strcmp((const char *) n->name, (const char *) "xslt")) { @@ -682,7 +711,7 @@ static struct conf_service *service_create_static(struct conf_server *server, if (!strcmp(rank_length, "linear")) service->rank_length = 2; else if (!strcmp(rank_length, "log")) - service->rank_length = 1; + service->rank_length = 1; else if (!strcmp(rank_length, "none")) service->rank_length = 0; else @@ -1232,7 +1261,10 @@ static int parse_config(struct conf_config *config, xmlNode *root) struct conf_config *config_create(const char *fname, int verbose) { - xmlDoc *doc = xmlParseFile(fname); + xmlDoc *doc = xmlReadFile(fname, + NULL, + XML_PARSE_XINCLUDE + XML_PARSE_NOBLANKS + + XML_PARSE_NSCLEAN + XML_PARSE_NONET ); xmlNode *n; const char *p; int r; @@ -1248,6 +1280,14 @@ struct conf_config *config_create(const char *fname, int verbose) return 0; } + // Perform XInclude. + r = xmlXIncludeProcess(doc); + if (r == -1) + { + yaz_log(YLOG_FATAL, "XInclude processing failed"); + return 0; + } + config->nmem = nmem; config->servers = 0; config->no_threads = 0;