int *error,
char **addinfo,
mp::odr &odr,
+ std::string torus_url,
std::string &torus_db,
std::string &realm);
void handle_present(mp::Package &package);
}
else if (!strcmp(name, "realm"))
realm = value;
+ else if (!strcmp(name, "torus_url"))
+ torus_url = value;
else if (name[0] == 'x' && name[1] == '-')
{
out_names[no_out_args] = name;
}
if (torus_db.compare("IR-Explain---1") == 0)
- return explain_search(package, database, error, addinfo, odr, torus_db,
- realm);
+ return explain_search(package, database, error, addinfo, odr, torus_url,
+ torus_db, realm);
SearchablePtr sptr;
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);
}
int *error,
char **addinfo,
mp::odr &odr,
+ std::string torus_url,
std::string &torus_db,
std::string &realm)
{
else if (query->which == Z_Query_type_104 &&
query->u.type_104->which == Z_External_CQL)
{
- std::string torus_url = m_p->torus_searchable_url;
std::string torus_query(query->u.type_104->u.cql);
xmlDoc *doc = mp::get_searchable(package, torus_url, "",
torus_query,