- if (n->type != XML_ELEMENT_NODE)
- continue;
- if (!strcmp(n->name, "requestsyntax"))
- {
- xmlChar *content = xmlNodeGetContent(n);
- if (content)
- r->requestsyntax = nmem_strdup(nmem, content);
- }
- else if (!strcmp(n->name, "nativesyntax"))
- {
- xmlChar *name = xmlGetProp(n, "name");
- xmlChar *format = xmlGetProp(n, "format");
- xmlChar *encoding = xmlGetProp(n, "encoding");
- xmlChar *mapto = xmlGetProp(n, "mapto");
- if (!name)
- {
- yaz_log(YLOG_WARN, "Missing name in 'nativesyntax' element");
- return 0;
- }
- if (!strcmp(name, "iso2709"))
- {
- r->native_syntax = Nativesyn_iso2709;
- // Set a few defaults, too
- r->native_format = Nativeform_marc21;
- r->native_mapto = Nativemapto_marcxml;
- r->native_encoding = "marc-8";
- setup_marc(r);
- }
- else if (!strcmp(name, "xml"))
- r->native_syntax = Nativesyn_xml;
- else
- {
- yaz_log(YLOG_WARN, "Unknown native syntax name %s", name);
- return 0;
- }
- if (format)
- {
- if (!strcmp(format, "marc21") || !strcmp(format, "usmarc"))
- r->native_format = Nativeform_marc21;
- else
- {
- yaz_log(YLOG_WARN, "Unknown native format name %s", format);
- return 0;
- }
- }
- if (encoding)
- r->native_encoding = encoding;
- if (mapto)
- {
- if (!strcmp(mapto, "marcxml"))
- r->native_mapto = Nativemapto_marcxml;
- else if (!strcmp(mapto, "marcxchange"))
- r->native_mapto = Nativemapto_marcxchange;
- else
- {
- yaz_log(YLOG_WARN, "Unknown mapto target %s", format);
- return 0;
- }
- }
- xmlFree(name);
- xmlFree(format);
- xmlFree(encoding);
- xmlFree(mapto);
- }
- else if (!strcmp(n->name, "map"))
- {
- struct conf_retrievalmap *m = nmem_malloc(nmem, sizeof(struct conf_retrievalmap));
- xmlChar *type = xmlGetProp(n, "type");
- xmlChar *charset = xmlGetProp(n, "charset");
- xmlChar *format = xmlGetProp(n, "format");
- xmlChar *stylesheet = xmlGetProp(n, "stylesheet");
- memset(m, 0, sizeof(*m));
- if (type)
- {
- if (!strcmp(type, "xslt"))
- m->type = Map_xslt;
- else
- {
- yaz_log(YLOG_WARN, "Unknown map type: %s", type);
- return 0;
- }
- }
- if (charset)
- m->charset = nmem_strdup(nmem, charset);
- if (format)
- m->format = nmem_strdup(nmem, format);
- if (stylesheet)
- {
- if (!(m->stylesheet = load_stylesheet(stylesheet)))
- return 0;
- }
- *rm = m;
- rm = &m->next;
- xmlFree(type);
- xmlFree(charset);
- xmlFree(format);
- xmlFree(stylesheet);
- }