Odr_oct *odr_create_Odr_oct(ODR o, const char *buf, int sz) { Odr_oct *p = (Odr_oct *) odr_malloc(o, sizeof(Odr_oct)); p->buf = odr_strdupn(o, buf, sz); p->len = sz; return p; }
int yaz_match_xsd_XML_n2(xmlNodePtr ptr, const char *elem, ODR o, char **val, int *len, int fixup_root) { xmlBufferPtr buf; int no_root_nodes = 0; if (!yaz_match_xsd_element(ptr, elem)) return 0; buf = xmlBufferCreate(); /* Copy each element nodes at top. In most cases there is only one root node.. At least one server http://www.theeuropeanlibrary.org/sru/sru.pl has multiple root nodes in recordData. */ for (ptr = ptr->children; ptr; ptr = ptr->next) { if (ptr->type == XML_ELEMENT_NODE) { /* copy node to get NS right (bug #740). */ xmlNode *tmp = xmlCopyNode(ptr, 1); xmlNodeDump(buf, tmp->doc, tmp, 0, 0); xmlFreeNode(tmp); no_root_nodes++; } } if (no_root_nodes != 1 && fixup_root) { /* does not appear to be an XML document. Make it so */ xmlBufferAddHead(buf, (const xmlChar *) "<yaz_record>", -1); xmlBufferAdd(buf, (const xmlChar *) "</yaz_record>", -1); } *val = odr_strdupn(o, (const char *) buf->content, buf->use); if (len) *len = buf->use; xmlBufferFree(buf); return 1; }
static char *yaz_decode_sru_dbpath_odr(ODR n, const char *uri, size_t len) { return odr_strdupn(n, uri, len); }