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);
}