X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fretrieval.c;h=4c2920a0d2dbb205ec7b06faaa29403290344953;hp=26d28fdbf4950e20ae061e246118d8f1ae0961a1;hb=8cb8947e3a7bff4dbf8f124871cb4905df1adce7;hpb=a3e65bcd3250b107397675bc65b35b5939355025 diff --git a/src/retrieval.c b/src/retrieval.c index 26d28fd..4c2920a 100644 --- a/src/retrieval.c +++ b/src/retrieval.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2012 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ /** @@ -147,7 +147,7 @@ static int conf_retrieval(yaz_retrieval_t p, const xmlNode *ptr, nmem_strdup(p->nmem, (const char *) attr->children->content); else if (!xmlStrcmp(attr->name, BAD_CAST "name") && attr->children && attr->children->type == XML_TEXT_NODE) - el->name = + el->name = nmem_strdup(p->nmem, (const char *) attr->children->content); else { @@ -191,18 +191,18 @@ static int conf_retrieval(yaz_retrieval_t p, const xmlNode *ptr, /* parsing attributees */ for (attr = ptr->properties; attr; attr = attr->next) { - if (!xmlStrcmp(attr->name, BAD_CAST "name") - && attr->children + if (!xmlStrcmp(attr->name, BAD_CAST "name") + && attr->children && attr->children->type == XML_TEXT_NODE) - el->backend_name - = nmem_strdup(p->nmem, + el->backend_name + = nmem_strdup(p->nmem, (const char *) attr->children->content); - - else if (!xmlStrcmp(attr->name, BAD_CAST "syntax") - && attr->children + + else if (!xmlStrcmp(attr->name, BAD_CAST "syntax") + && attr->children && attr->children->type == XML_TEXT_NODE) { - el->backend_syntax + el->backend_syntax = yaz_string_to_oid_odr( yaz_oid_std(), CLASS_RECSYN, @@ -210,24 +210,24 @@ static int conf_retrieval(yaz_retrieval_t p, const xmlNode *ptr, p->odr); if (!el->backend_syntax) { - wrbuf_printf(p->wr_error, + wrbuf_printf(p->wr_error, "Element : " "attribute 'syntax' has invalid " - "value '%s'", + "value '%s'", attr->children->content, attr->children->content); return -1; - } + } } else { wrbuf_printf(p->wr_error, "Element : expected " - "attributes 'syntax' or 'name, got '%s'", + "attributes 'syntax' or 'name, got '%s'", attr->name); return -1; } } - + /* parsing internal of record conv */ el->record_conv = yaz_record_conv_create(); @@ -242,7 +242,7 @@ static int conf_retrieval(yaz_retrieval_t p, const xmlNode *ptr, } } } - + *p->list_p = el; p->list_p = &el->next; return 0; @@ -268,7 +268,7 @@ int yaz_retrieval_configure_t(yaz_retrieval_t p, const xmlNode *ptr, else { wrbuf_printf(p->wr_error, "Element : " - "expected element , got <%s>", + "expected element , got <%s>", ptr->name); return -1; } @@ -317,7 +317,7 @@ int yaz_retrieval_request(yaz_retrieval_t p, if (!el->name && !el->identifier) schema_ok = 1; } - + if (syntax && el->syntax && !oid_oidcmp(syntax, el->syntax)) syntax_ok = 1; if (!syntax) @@ -337,9 +337,12 @@ int yaz_retrieval_request(yaz_retrieval_t p, if (backend_schema) { if (el->backend_name) - *backend_schema = el->backend_name; + { + if (*el->backend_name) + *backend_schema = el->backend_name; + } else if (el->name) - *backend_schema = el->name; + *backend_schema = el->name; else *backend_schema = schema; }