#include <metaproxy/util.hpp>
#include <yaz/log.h>
#include <yaz/oid_db.h>
+#include <yaz/diagbib1.h>
#include <map>
#include <string>
#include <iostream>
std::string zorba_filename;
std::string zorba_script;
std::string zorba_record_variable;
+ std::string elementset_input;
+ std::string elementset_output;
Zorba *lZorba;
XQuery_t lQuery;
};
result = ss.str();
return true;
} catch ( ZorbaException &e) {
- std::string msg = e.what();
- yaz_log(YLOG_WARN, "XQuery execute failure: %s", msg.c_str());
+ result = e.what();
+ yaz_log(YLOG_WARN, "XQuery execute: %s", result.c_str());
return false;
}
}
const char *backend_schema = 0;
const Odr_oid *backend_syntax = 0;
- if (input_schema && !strcmp(input_schema, "bibframe") &&
+ if (input_schema && !strcmp(input_schema, elementset_input.c_str()) &&
(!input_syntax || !oid_oidcmp(input_syntax, yaz_oid_recsyn_xml)))
{
- backend_schema = "marcxml";
+ backend_schema = elementset_output.c_str();
backend_syntax = yaz_oid_recsyn_xml;
}
else
int i;
for (i = 0; i < records->num_records; i++)
{
- Z_NamePlusRecord *npr = records->records[i];
- if (npr->which == Z_NamePlusRecord_databaseRecord)
+ Z_NamePlusRecord **npr = &records->records[i];
+ if ((*npr)->which == Z_NamePlusRecord_databaseRecord)
{
const char *details = 0;
- Z_External *r = npr->u.databaseRecord;
+ Z_External *r = (*npr)->u.databaseRecord;
int ret_trans = -1;
if (r->which == Z_External_octet &&
!oid_oidcmp(r->direct_reference, yaz_oid_recsyn_xml))
r->u.octet_aligned->buf, r->u.octet_aligned->len,
result))
{
- npr->u.databaseRecord =
+ (*npr)->u.databaseRecord =
z_ext_record_oid(odr_en, yaz_oid_recsyn_xml,
result.c_str(),
result.length());
}
+ else
+ {
+ *npr = zget_surrogateDiagRec(
+ odr_en, (*npr)->databaseName,
+ YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS,
+ result.c_str());
+ }
}
}
}
{
if (ptr->type != XML_ELEMENT_NODE)
continue;
- if (!strcmp((const char *) ptr->name, "setVariable"))
+ if (!strcmp((const char *) ptr->name, "elementset"))
+ {
+ struct _xmlAttr *attr;
+ for (attr = ptr->properties; attr; attr = attr->next)
+ if (!strcmp((const char *) attr->name, "name"))
+ elementset_input = mp::xml::get_text(attr->children);
+ else if (!strcmp((const char *) attr->name, "backend"))
+ elementset_output = mp::xml::get_text(attr->children);
+ else
+ throw mp::filter::FilterException(
+ "Bad attribute " + std::string((const char *)
+ attr->name));
+ }
+ else if (!strcmp((const char *) ptr->name, "variable"))
{
std::string name;
std::string value;
}
else if (!strcmp((const char *) ptr->name, "script"))
{
- std::string value;
+ std::string name;
struct _xmlAttr *attr;
for (attr = ptr->properties; attr; attr = attr->next)
- if (!strcmp((const char *) attr->name, "value"))
- value = mp::xml::get_text(attr->children);
+ if (!strcmp((const char *) attr->name, "name"))
+ name = mp::xml::get_text(attr->children);
else
throw mp::filter::FilterException(
"Bad attribute " + std::string((const char *)
attr->name));
- zorba_script = value;
+ zorba_script = name;
}
else if (!strcmp((const char *) ptr->name, "record"))
{
- std::string value;
+ std::string name;
struct _xmlAttr *attr;
for (attr = ptr->properties; attr; attr = attr->next)
- if (!strcmp((const char *) attr->name, "value"))
- value = mp::xml::get_text(attr->children);
+ if (!strcmp((const char *) attr->name, "name"))
+ name = mp::xml::get_text(attr->children);
else
throw mp::filter::FilterException(
"Bad attribute " + std::string((const char *)
attr->name));
- zorba_record_variable = value;
+ zorba_record_variable = name;
}
else
{
Zorba_CompilerHints lHints;
lQuery->compile(*qfile, lHints);
} catch ( ZorbaException &e) {
- std::string msg = "XQuery compile failure: ";
+ std::string msg = "XQuery compile: ";
msg += e.what();
throw mp::filter::FilterException(msg);
}