#include <yaz/srw.h>
#include <metaproxy/package.hpp>
#include <metaproxy/util.hpp>
+#include <metaproxy/xmlutil.hpp>
#include "torus.hpp"
#include <libxslt/xsltutils.h>
std::string element_set;
std::string record_encoding;
std::string transform_xsl_fname;
+ std::string urlRecipe;
bool use_turbomarc;
bool piggyback;
CCL_bibset ccl_bibset;
s->transform_xsl_fname = mp::xml::get_text(ptr);
}
else if (!strcmp((const char *) ptr->name,
+ "urlRecipe"))
+ {
+ s->urlRecipe = mp::xml::get_text(ptr);
+ }
+ else if (!strcmp((const char *) ptr->name,
"useTurboMarc"))
{
; // useTurboMarc is ignored
Z_Records *records = 0;
bool enable_pz2_retrieval = false; // whether target profile is used
bool enable_pz2_transform = false; // whether XSLT is used as well
+ bool assume_marc8_charset = false;
if (start < 0 || number_to_present <= 0)
return records;
if (enable_pz2_retrieval)
{
if (b->sptr->request_syntax.length())
+ {
syntax_name = b->sptr->request_syntax.c_str();
+ const Odr_oid *syntax_oid =
+ yaz_string_to_oid(yaz_oid_std(), CLASS_RECSYN, syntax_name);
+ if (!oid_oidcmp(syntax_oid, yaz_oid_recsyn_usmarc)
+ || !oid_oidcmp(syntax_oid, yaz_oid_recsyn_opac))
+ assume_marc8_charset = true;
+ }
}
else if (preferredRecordSyntax)
syntax_name =
else if (enable_pz2_retrieval)
{
char rec_type_str[100];
+ const char *record_encoding = 0;
- strcpy(rec_type_str, b->sptr->use_turbomarc ?
- "txml" : "xml");
- // prevent buffer overflow ...
- if (b->sptr->record_encoding.length() > 0 &&
- b->sptr->record_encoding.length() <
- (sizeof(rec_type_str)-20))
+ if (b->sptr->record_encoding.length())
+ record_encoding = b->sptr->record_encoding.c_str();
+ else if (assume_marc8_charset)
+ record_encoding = "marc8";
+
+ strcpy(rec_type_str, b->sptr->use_turbomarc ? "txml" : "xml");
+ if (record_encoding)
{
strcat(rec_type_str, "; charset=");
- strcat(rec_type_str, b->sptr->record_encoding.c_str());
+ strcat(rec_type_str, record_encoding);
}
int rec_len;
if (rec_buf)
{
+ xmlDoc *doc = xmlParseMemory(rec_buf, rec_len);
+ mp::xml::url_recipe_handle(doc, b->sptr->urlRecipe);
+ xmlFreeDoc(doc);
+ }
+ if (rec_buf)
+ {
npr = (Z_NamePlusRecord *) odr_malloc(odr, sizeof(*npr));
npr->databaseName = odr_database;
npr->which = Z_NamePlusRecord_databaseRecord;