/*
- * Copyright (c) 2003-2004, Index Data.
+ * Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: opacdisp.c,v 1.3 2004-10-15 00:19:00 adam Exp $
+ * $Id: opacdisp.c,v 1.6 2005-03-02 23:59:22 adam Exp $
*/
/**
* \file opacdisp.c
#include <ctype.h>
#include <yaz/proto.h>
+#include <yaz/marcdisp.h>
static void opac_element_str(WRBUF wrbuf, int l, const char *elem,
const char *data)
}
}
-void yaz_display_OPAC(WRBUF wrbuf, Z_OPACRecord *r, int flags)
+void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf)
{
int i;
+
+ wrbuf_puts(wrbuf, "<opacRecord>\n");
+ if (r->bibliographicRecord)
+ {
+ Z_External *ext = r->bibliographicRecord;
+
+ wrbuf_puts (wrbuf, " <bibliographicRecord>\n");
+ if (ext->which == Z_External_octet)
+ yaz_marc_decode_wrbuf(mt, ext->u.octet_aligned->buf,
+ ext->u.octet_aligned->len, wrbuf);
+ wrbuf_puts (wrbuf, " </bibliographicRecord>\n");
+ }
wrbuf_puts(wrbuf, "<holdings>\n");
for (i = 0; i < r->num_holdingsData; i++)
if (h->which == Z_HoldingsRecord_marcHoldingsRecord)
{
- wrbuf_puts (wrbuf, " <marc/>\n");
- /* h->u.marcHoldingsRecord) */
+ Z_External *ext = h->u.marcHoldingsRecord;
+
+ wrbuf_puts (wrbuf, " <marcHoldingsRecord>\n");
+ if (ext->which == Z_External_octet)
+ yaz_marc_decode_wrbuf(mt, ext->u.octet_aligned->buf,
+ ext->u.octet_aligned->len, wrbuf);
+ wrbuf_puts (wrbuf, " </marcHoldingsRecord>\n");
}
else if (h->which == Z_HoldingsRecord_holdingsAndCirc)
{
wrbuf_puts(wrbuf, " </holding>\n");
}
wrbuf_puts(wrbuf, "</holdings>\n");
+ wrbuf_puts(wrbuf, "</opacRecord>\n");
}
+
+void yaz_display_OPAC(WRBUF wrbuf, Z_OPACRecord *opac_rec, int flags)
+{
+ yaz_marc_t mt = yaz_marc_create();
+
+ yaz_marc_xml(mt, YAZ_MARC_MARCXML);
+ yaz_opac_decode_wrbuf(mt, opac_rec, wrbuf);
+ yaz_marc_destroy(mt);
+}
+