39 for (i = 0; i < nb_attributes; i++)
41 if (strcmp(
name, (
const char *)attributes[5 * i]) == 0)
43 const char *buf = (
const char *)attributes[5 * i + 3];
44 const char *end = (
const char *)attributes[5 * i + 4];
45 size_t len = end - buf;
47 for (i = 0; i < len; i++) {
49 if (i < len - 4 && buf[i] ==
'&'
50 && buf[i+1] ==
'#' && buf[i+2] ==
'3' && buf[i+3] ==
'8' && buf[i+4] ==
';')
62 strcpy(ind_cstr,
"indX");
67 ind_cstr[3] =
'1' + i;
74 const xmlChar *localname,
const xmlChar *prefix,
75 const xmlChar *URI,
int nb_namespaces,
const xmlChar **namespaces,
76 int nb_attributes,
int nb_defaulted,
const xmlChar **attributes)
81 if (strcmp((
const char *)localname,
"controlfield") == 0)
86 else if (strcmp((
const char *)localname,
"datafield") == 0)
94 else if (strcmp((
const char *)localname,
"subfield") == 0)
98 else if (strcmp((
const char *)localname,
"record") == 0)
105 const xmlChar *prefix,
const xmlChar *URI)
108 if (strcmp((
const char *)localname,
"leader") == 0)
110 int identifier_length;
112 int length_data_entry;
114 int length_implementation;
117 &length_data_entry, &length_starting, &length_implementation);
119 else if (strcmp((
const char *)localname,
"controlfield") == 0)
124 else if (strcmp((
const char *)localname,
"subfield") == 0)
128 else if (strcmp((
const char *)localname,
"record") == 0)
static void yaz_start_element_ns(void *vp, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes)
yaz_marc_sax_t yaz_marc_sax_new(yaz_marc_t mt, void(*cb)(yaz_marc_t, void *), void *cb_data)
static int get_attribute(const char *name, int nb_attributes, const xmlChar **attributes, WRBUF result)
static void get_indicators(yaz_marc_sax_t ctx, int nb_attributes, const xmlChar **attributes)
static void yaz_characters(void *vp, const xmlChar *text, int len)
static void yaz_end_element_ns(void *vp, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI)
void yaz_marc_sax_destroy(yaz_marc_sax_t ctx)
destroys marc SAX parser
xmlSAXHandlerPtr yaz_marc_sax_get_handler(yaz_marc_sax_t ctx)
return Libxml SAX handler pointer
Parsing MARCXML collection using Libxml2's SAX parser.
void yaz_marc_add_subfield(yaz_marc_t mt, const char *code_data, size_t code_data_len)
adds subfield to MARC structure
void yaz_marc_add_datafield(yaz_marc_t mt, const char *tag, const char *indicator, size_t indicator_len)
adds datafield to MARC structure using strings
void yaz_marc_set_leader(yaz_marc_t mt, const char *leader_c, int *indicator_length, int *identifier_length, int *base_address, int *length_data_entry, int *length_starting, int *length_implementation)
sets leader, validates it, and returns important values
void yaz_marc_add_controlfield(yaz_marc_t mt, const char *tag, const char *data, size_t data_len)
adds controlfield to MARC structure
void yaz_marc_reset(yaz_marc_t mt)
clears memory and MARC record
struct yaz_marc_t_ * yaz_marc_t
a yaz_marc_t handle (private content)
Header for Nibble Memory functions + Libxml2 specific stuff.
void(* cb_func)(yaz_marc_t, void *)
the internals of a yaz_marc_t handle
void wrbuf_destroy(WRBUF b)
destroy WRBUF and its buffer
void wrbuf_rewind(WRBUF b)
empty WRBUF content (length of buffer set to 0)
WRBUF wrbuf_alloc(void)
construct WRBUF
const char * wrbuf_cstr(WRBUF b)
returns WRBUF content as C-string
void wrbuf_write(WRBUF b, const char *buf, size_t size)
append constant size buffer to WRBUF
Header for WRBUF (growing buffer)
#define xfree(x)
utility macro which calls xfree_f
#define xmalloc(x)
utility macro which calls malloc_f