20 if (ptr && ptr->type == XML_ELEMENT_NODE &&
21 !xmlStrcmp(ptr->name, BAD_CAST elem))
34 struct _xmlAttr *attr;
39 for (attr = ptr->properties; attr; attr = attr->next)
40 if (!strcmp(attr->name,
"type") &&
41 attr->children && attr->children->type == XML_TEXT_NODE)
43 const char *t = strchr(attr->children->content,
':');
47 t = attr->children->content;
48 if (!strcmp(t,
"string"))
55 if (!ptr || ptr->type != XML_TEXT_NODE)
60 *val =
nmem_strdup(nmem, (
const char *) ptr->content);
62 *len = xmlStrlen(ptr->content);
78 char **val,
int *len,
int fixup_root)
81 int no_root_nodes = 0;
86 buf = xmlBufferCreate();
93 for (ptr = ptr->children; ptr; ptr = ptr->next)
95 if (ptr->type == XML_ELEMENT_NODE)
98 xmlNode *tmp = xmlCopyNode(ptr, 1);
100 xmlNodeDump(buf, tmp->doc, tmp, 0, 0);
106 if (no_root_nodes != 1 && fixup_root)
109 xmlBufferAddHead(buf, (
const xmlChar *)
"<yaz_record>", -1);
110 xmlBufferAdd(buf, (
const xmlChar *)
"</yaz_record>", -1);
119 char **val,
int *len)
128 struct _xmlAttr *attr;
133 for (attr = ptr->properties; attr; attr = attr->next)
134 if (!strcmp(attr->name,
"type") &&
135 attr->children && attr->children->type == XML_TEXT_NODE)
137 const char *t = strchr(attr->children->content,
':');
141 t = attr->children->content;
142 if (!strcmp(t,
"integer"))
149 if (!ptr || ptr->type != XML_TEXT_NODE)
struct nmem_control * NMEM
NMEM handle (an opaque pointer to memory).
char * nmem_from_xml_buffer(NMEM nmem, const xmlBufferPtr buf, int *ret_len)
copies xmlBuffer data to NMEM
Header for Nibble Memory functions + Libxml2 specific stuff.
char * nmem_strdup(NMEM mem, const char *src)
allocates string on NMEM handle (similar strdup)
Odr_int * odr_intdup(ODR o, Odr_int v)
Odr_int odr_atoi(const char *s)
int yaz_match_xsd_element(xmlNodePtr ptr, const char *elem)
int yaz_match_xsd_string_n_nmem(xmlNodePtr ptr, const char *elem, NMEM nmem, char **val, int *len)
int yaz_match_xsd_XML_n2(xmlNodePtr ptr, const char *elem, ODR o, char **val, int *len, int fixup_root)
int yaz_match_xsd_XML_n(xmlNodePtr ptr, const char *elem, ODR o, char **val, int *len)
int yaz_match_xsd_string_n(xmlNodePtr ptr, const char *elem, ODR o, char **val, int *len)
int yaz_match_xsd_string(xmlNodePtr ptr, const char *elem, ODR o, char **val)
int yaz_match_xsd_integer(xmlNodePtr ptr, const char *elem, ODR o, Odr_int **val)