From 4d1fada854feb955592489edf60f2e5121ffb148 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 1 Aug 2012 13:14:47 +0200 Subject: [PATCH] zoom: allow Torus record wrapped in single "record" elem --- src/filter_zoom.cpp | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/src/filter_zoom.cpp b/src/filter_zoom.cpp index b337b60..ae84b7b 100644 --- a/src/filter_zoom.cpp +++ b/src/filter_zoom.cpp @@ -1164,27 +1164,44 @@ yf::Zoom::BackendPtr yf::Zoom::Frontend::get_backend_from_databases( return b; } const xmlNode *ptr = xmlDocGetRootElement(doc); - if (ptr) - { // presumably ptr is a records element node - // parse first record in document - for (ptr = ptr->children; ptr; ptr = ptr->next) + if (ptr && ptr->type == XML_ELEMENT_NODE) + { + if (!strcmp((const char *) ptr->name, "record")) { - if (ptr->type == XML_ELEMENT_NODE - && !strcmp((const char *) ptr->name, "record")) + sptr = m_p->parse_torus_record(ptr); + } + else if (!strcmp((const char *) ptr->name, "records")) + { + for (ptr = ptr->children; ptr; ptr = ptr->next) { - if (sptr) + if (ptr->type == XML_ELEMENT_NODE + && !strcmp((const char *) ptr->name, "record")) { - *error = YAZ_BIB1_UNSPECIFIED_ERROR; - *addinfo = (char*) odr_malloc(odr, 40 + database.length()), - sprintf(*addinfo, "multiple records for udb=%s", - database.c_str()); - xmlFreeDoc(doc); - BackendPtr b; - return b; + if (sptr) + { + *error = YAZ_BIB1_UNSPECIFIED_ERROR; + *addinfo = (char*) + odr_malloc(odr, 40 + torus_db.length()); + sprintf(*addinfo, "multiple records for udb=%s", + database.c_str()); + xmlFreeDoc(doc); + BackendPtr b; + return b; + } + sptr = m_p->parse_torus_record(ptr); } - sptr = m_p->parse_torus_record(ptr); } } + else + { + *error = YAZ_BIB1_UNSPECIFIED_ERROR; + *addinfo = (char*) odr_malloc( + odr, 40 + strlen((const char *) ptr->name)); + sprintf(*addinfo, "bad root element for torus: %s", ptr->name); + xmlFreeDoc(doc); + BackendPtr b; + return b; + } } xmlFreeDoc(doc); } -- 1.7.10.4