#if YAZ_HAVE_XML2
/** \brief Converts XML to OPAC
- \param mt marc handle
+ \param mt marc handle
\param buf_in XML buffer
\param size_in size of XML buffer
\param dst Z39.50 OPAC result - allocated by NMEM on marc handle
\param cd iconv handle for the OPAC content (not ISO2709 part)
\param nmem memory for OPACRecord (if NULL, mt NMEM memory is used)
+ \param syntax OID for embedded MARC (if NULL, USMARC is used)
\retval 1 conversion OK
\retval 0 conversion NOT OK
\*/
YAZ_EXPORT int yaz_xml_to_opac(yaz_marc_t mt,
const char *buf_in, size_t size_in,
Z_OPACRecord **dst, yaz_iconv_t cd,
- NMEM nmem);
+ NMEM nmem, const Odr_oid *syntax);
#endif
/** \brief flushes records
}
static int bibliographicRecord(yaz_marc_t mt, xmlNode *ptr, Z_External **ext,
- yaz_iconv_t cd, NMEM nmem)
+ yaz_iconv_t cd, NMEM nmem, const Odr_oid *syntax)
{
int ret = 0;
if (yaz_marc_read_xml(mt, ptr) == 0)
WRBUF wr = wrbuf_alloc();
if (yaz_marc_write_iso2709(mt, wr) == 0)
{
- *ext = z_ext_record_oid_nmem(nmem, yaz_oid_recsyn_usmarc,
- wrbuf_buf(wr), wrbuf_len(wr));
+ *ext = z_ext_record_oid_nmem(
+ nmem, syntax ? syntax : yaz_oid_recsyn_usmarc,
+ wrbuf_buf(wr), wrbuf_len(wr));
ret = 1;
}
wrbuf_destroy(wr);
static int yaz_xml_to_opac_ptr(yaz_marc_t mt, xmlNode *ptr,
Z_OPACRecord **dst,
- yaz_iconv_t cd, NMEM nmem)
+ yaz_iconv_t cd, NMEM nmem,
+ const Odr_oid *syntax)
{
int i;
Z_External *ext = 0;
ptr = ptr->next;
if (!match_element(ptr, "bibliographicRecord"))
return 0;
- if (!bibliographicRecord(mt, ptr->children, &ext, cd, nmem))
+ if (!bibliographicRecord(mt, ptr->children, &ext, cd, nmem, syntax))
return 0;
*dst = opac = (Z_OPACRecord *) nmem_malloc(nmem, sizeof(*opac));
opac->num_holdingsData = 0;
}
int yaz_xml_to_opac(yaz_marc_t mt, const char *buf_in, size_t size_in,
- Z_OPACRecord **dst, yaz_iconv_t cd, NMEM nmem)
+ Z_OPACRecord **dst, yaz_iconv_t cd, NMEM nmem,
+ const Odr_oid *syntax)
{
xmlDocPtr doc = xmlParseMemory(buf_in, size_in);
int r = 0;
if (doc)
{
- r = yaz_xml_to_opac_ptr(mt, xmlDocGetRootElement(doc), dst, cd, nmem);
+ r = yaz_xml_to_opac_ptr(mt, xmlDocGetRootElement(doc), dst, cd, nmem,
+ syntax);
xmlFreeDoc(doc);
}
return r;