2 * Copyright (C) 1995-2005, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: opacdisp.c,v 1.6 2005-03-02 23:59:22 adam Exp $
9 * \brief Implements OPAC record display
17 #include <yaz/proto.h>
18 #include <yaz/marcdisp.h>
20 static void opac_element_str(WRBUF wrbuf, int l, const char *elem,
26 wrbuf_puts(wrbuf, " ");
27 wrbuf_puts(wrbuf, "<");
28 wrbuf_puts(wrbuf, elem);
29 wrbuf_puts(wrbuf, ">");
30 wrbuf_xmlputs(wrbuf, data);
31 wrbuf_puts(wrbuf, "</");
32 wrbuf_puts(wrbuf, elem);
33 wrbuf_puts(wrbuf, ">\n");
37 static void opac_element_bool(WRBUF wrbuf, int l, const char *elem, int *data)
42 wrbuf_puts(wrbuf, " ");
43 wrbuf_puts(wrbuf, "<");
44 wrbuf_puts(wrbuf, elem);
46 wrbuf_puts(wrbuf, " value=\"1\"");
48 wrbuf_puts(wrbuf, " value=\"0\"");
49 wrbuf_puts(wrbuf, "/>\n");
53 void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf)
57 wrbuf_puts(wrbuf, "<opacRecord>\n");
58 if (r->bibliographicRecord)
60 Z_External *ext = r->bibliographicRecord;
62 wrbuf_puts (wrbuf, " <bibliographicRecord>\n");
63 if (ext->which == Z_External_octet)
64 yaz_marc_decode_wrbuf(mt, ext->u.octet_aligned->buf,
65 ext->u.octet_aligned->len, wrbuf);
66 wrbuf_puts (wrbuf, " </bibliographicRecord>\n");
68 wrbuf_puts(wrbuf, "<holdings>\n");
70 for (i = 0; i < r->num_holdingsData; i++)
72 Z_HoldingsRecord *h = r->holdingsData[i];
73 wrbuf_puts(wrbuf, " <holding>\n");
75 if (h->which == Z_HoldingsRecord_marcHoldingsRecord)
77 Z_External *ext = h->u.marcHoldingsRecord;
79 wrbuf_puts (wrbuf, " <marcHoldingsRecord>\n");
80 if (ext->which == Z_External_octet)
81 yaz_marc_decode_wrbuf(mt, ext->u.octet_aligned->buf,
82 ext->u.octet_aligned->len, wrbuf);
83 wrbuf_puts (wrbuf, " </marcHoldingsRecord>\n");
85 else if (h->which == Z_HoldingsRecord_holdingsAndCirc)
89 Z_HoldingsAndCircData *d = h->u.holdingsAndCirc;
91 opac_element_str(wrbuf, 2, "typeOfRecord", d->typeOfRecord);
92 opac_element_str(wrbuf, 2, "encodingLevel", d->encodingLevel);
93 opac_element_str(wrbuf, 2, "format", d->format);
94 opac_element_str(wrbuf, 2, "receiptAcqStatus", d->receiptAcqStatus);
95 opac_element_str (wrbuf, 2, "generalRetention", d->generalRetention);
96 opac_element_str (wrbuf, 2, "completeness", d->completeness);
97 opac_element_str (wrbuf, 2, "dateOfReport", d->dateOfReport);
98 opac_element_str (wrbuf, 2, "nucCode", d->nucCode);
99 opac_element_str (wrbuf, 2, "localLocation", d->localLocation);
100 opac_element_str (wrbuf, 2, "shelvingLocation", d->shelvingLocation);
101 opac_element_str (wrbuf, 2, "callNumber", d->callNumber);
102 opac_element_str (wrbuf, 2, "shelvingData", d->shelvingData);
104 opac_element_str (wrbuf, 2, "copyNumber", d->copyNumber);
105 opac_element_str (wrbuf, 2, "publicNote", d->publicNote);
106 opac_element_str (wrbuf, 2, "reproductionNote", d->reproductionNote);
107 opac_element_str (wrbuf, 2, "termsUseRepro", d->termsUseRepro);
108 opac_element_str (wrbuf, 2, "enumAndChron", d->enumAndChron);
111 wrbuf_puts (wrbuf, " <volumes>\n");
112 for (j = 0; j<d->num_volumes; j++)
114 wrbuf_puts (wrbuf, " <volume>\n");
115 opac_element_str (wrbuf, 4, "enumeration",
116 d->volumes[j]->enumeration);
117 opac_element_str (wrbuf, 4, "chronology",
118 d->volumes[j]->chronology);
119 opac_element_str (wrbuf, 4, "enumAndChron",
120 d->volumes[j]->enumAndChron);
121 wrbuf_puts (wrbuf, " </volume>\n");
123 wrbuf_puts (wrbuf, " </volumes>\n");
125 if (d->num_circulationData)
127 wrbuf_puts (wrbuf, " <circulations>\n");
128 for (j = 0; j<d->num_circulationData; j++)
130 wrbuf_puts (wrbuf," <circulation>\n");
131 opac_element_bool (wrbuf, 4, "availableNow",
132 d->circulationData[j]->availableNow);
133 opac_element_str (wrbuf, 4, "availabiltyDate",
134 d->circulationData[j]->availablityDate);
135 opac_element_str (wrbuf, 4, "availableThru",
136 d->circulationData[j]->availableThru);
137 opac_element_str (wrbuf, 4, "restrictions",
138 d->circulationData[j]->restrictions);
139 opac_element_str (wrbuf, 4, "itemId",
140 d->circulationData[j]->itemId);
141 opac_element_bool (wrbuf, 4, "renewable",
142 d->circulationData[j]->renewable);
143 opac_element_bool (wrbuf, 4, "onHold",
144 d->circulationData[j]->onHold);
145 opac_element_str (wrbuf, 4, "enumAndChron",
146 d->circulationData[j]->enumAndChron);
147 opac_element_str (wrbuf, 4, "midspine",
148 d->circulationData[j]->midspine);
149 opac_element_str (wrbuf, 4, "temporaryLocation",
150 d->circulationData[j]->temporaryLocation);
151 wrbuf_puts (wrbuf, " </circulation>\n");
153 wrbuf_puts (wrbuf, " </circulations>\n");
156 wrbuf_puts(wrbuf, " </holding>\n");
158 wrbuf_puts(wrbuf, "</holdings>\n");
159 wrbuf_puts(wrbuf, "</opacRecord>\n");
162 void yaz_display_OPAC(WRBUF wrbuf, Z_OPACRecord *opac_rec, int flags)
164 yaz_marc_t mt = yaz_marc_create();
166 yaz_marc_xml(mt, YAZ_MARC_MARCXML);
167 yaz_opac_decode_wrbuf(mt, opac_rec, wrbuf);
168 yaz_marc_destroy(mt);