-/* $Id: logic.c,v 1.50 2007-07-11 19:41:40 adam Exp $
+/* $Id: logic.c,v 1.54 2007-07-16 17:01:46 adam Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
}
else if (rec->which == Z_External_OPAC)
{
- /* OPAC gets converted to XML too */
- WRBUF wrbuf_opac = wrbuf_alloc();
- yaz_display_OPAC(wrbuf_opac, rec->u.opac, 0);
-
- rdoc = xmlParseMemory((char*) wrbuf_buf(wrbuf_opac),
- wrbuf_len(wrbuf_opac));
- if (!rdoc)
- yaz_log(YLOG_WARN, "Unable to parse OPAC XML");
- wrbuf_destroy(wrbuf_opac);
+ if (!sdb->yaz_marc)
+ {
+ yaz_log(YLOG_WARN, "MARC decoding not configured");
+ return 0;
+ }
+ else
+ {
+ /* OPAC gets converted to XML too */
+ WRBUF wrbuf_opac = wrbuf_alloc();
+ /* MARCXML inside the OPAC XML. Charset is in effect because we
+ use the yaz_marc handle */
+ yaz_marc_xml(sdb->yaz_marc, YAZ_MARC_MARCXML);
+ yaz_opac_decode_wrbuf(sdb->yaz_marc, rec->u.opac, wrbuf_opac);
+
+ rdoc = xmlParseMemory((char*) wrbuf_buf(wrbuf_opac),
+ wrbuf_len(wrbuf_opac));
+ if (!rdoc)
+ yaz_log(YLOG_WARN, "Unable to parse OPAC XML");
+ wrbuf_destroy(wrbuf_opac);
+ }
}
else if (oid && yaz_oid_is_iso2709(oid))
{
/* ISO2709 gets converted to MARCXML */
if (!sdb->yaz_marc)
{
- yaz_log(YLOG_FATAL, "Unable to handle ISO2709 record");
+ yaz_log(YLOG_WARN, "MARC decoding not configured");
return 0;
}
else
return 0;
}
- if (global_parameters.dump_records){
- fprintf(stderr,
- "Input Record (normalized) from %s\n----------------\n",
- db->url);
+ if (global_parameters.dump_records)
+ {
+ FILE *lf = yaz_log_file();
+ if (lf)
+ {
+ yaz_log(YLOG_LOG, "Un-normalized record from %s", db->url);
#if LIBXML_VERSION >= 20600
- xmlDocFormatDump(stderr, rdoc, 1);
+ xmlDocFormatDump(lf, rdoc, 1);
#else
- xmlDocDump(stderr, rdoc);
+ xmlDocDump(lf, rdoc);
#endif
+ fprintf(lf, "\n");
+ }
}
return rdoc;
}
}
if (global_parameters.dump_records)
{
- fprintf(stderr, "Record from %s\n----------------\n",
- sdb->database->url);
+ FILE *lf = yaz_log_file();
+
+ if (lf)
+ {
+ yaz_log(YLOG_LOG, "Normalized record from %s",
+ sdb->database->url);
#if LIBXML_VERSION >= 20600
- xmlDocFormatDump(stderr, rdoc, 1);
+ xmlDocFormatDump(lf, rdoc, 1);
#else
- xmlDocDump(stderr, rdoc);
+ xmlDocDump(lf, rdoc);
#endif
+ fprintf(lf, "\n");
+ }
}
}
return rdoc;
}
#endif
-struct record_cluster *show_single(struct session *s, int id)
+struct record_cluster *show_single(struct session *s, const char *id)
{
struct record_cluster *r;
reclist_rewind(s->reclist);
while ((r = reclist_read_record(s->reclist)))
- if (r->recid == id)
+ if (!strcmp(r->recid, id))
return r;
return 0;
}
record, (char *) mergekey_norm,
&se->total_merged);
if (global_parameters.dump_records)
- yaz_log(YLOG_LOG, "Cluster id %d from %s (#%d)", cluster->recid,
+ yaz_log(YLOG_LOG, "Cluster id %s from %s (#%d)", cluster->recid,
client_get_database(cl)->database->url, record_no);
if (!cluster)
{