YAZ 5.37.0
marc_read_sax.c File Reference

Implements reading of MARCXML using SAX parsing. More...

#include <stdio.h>
#include <yaz/log.h>
#include <yaz/marc_sax.h>
#include <yaz/wrbuf.h>
#include <yaz/nmem_xml.h>

Go to the source code of this file.

Data Structures

struct  yaz_marc_sax_t_

Macros

#define MAX_IND   9

Functions

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_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)
static void yaz_end_element_ns (void *vp, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI)
static void yaz_characters (void *vp, const xmlChar *text, int len)
yaz_marc_sax_t yaz_marc_sax_new (yaz_marc_t mt, void(*cb)(yaz_marc_t, void *), void *cb_data)
 construct marc SAX parser
xmlSAXHandlerPtr yaz_marc_sax_get_handler (yaz_marc_sax_t ctx)
 return Libxml SAX handler pointer
void yaz_marc_sax_destroy (yaz_marc_sax_t ctx)
 destroys marc SAX parser

Detailed Description

Implements reading of MARCXML using SAX parsing.

Definition in file marc_read_sax.c.

Macro Definition Documentation

◆ MAX_IND

#define MAX_IND   9

Definition at line 20 of file marc_read_sax.c.

Function Documentation

◆ get_attribute()

int get_attribute ( const char * name,
int nb_attributes,
const xmlChar ** attributes,
WRBUF result )
static

Definition at line 36 of file marc_read_sax.c.

References name, and wrbuf_putc.

Referenced by get_indicators(), and yaz_start_element_ns().

◆ get_indicators()

void get_indicators ( yaz_marc_sax_t ctx,
int nb_attributes,
const xmlChar ** attributes )
static

◆ yaz_characters()

void yaz_characters ( void * vp,
const xmlChar * text,
int len )
static

Definition at line 135 of file marc_read_sax.c.

References yaz_marc_sax_t_::cdata, and wrbuf_write().

Referenced by yaz_marc_sax_new().

◆ yaz_end_element_ns()

void yaz_end_element_ns ( void * vp,
const xmlChar * localname,
const xmlChar * prefix,
const xmlChar * URI )
static

◆ yaz_marc_sax_destroy()

void yaz_marc_sax_destroy ( yaz_marc_sax_t ctx)

destroys marc SAX parser

Parameters
ctx

Definition at line 164 of file marc_read_sax.c.

References yaz_marc_sax_t_::cdata, yaz_marc_sax_t_::indicators, yaz_marc_sax_t_::tag, wrbuf_destroy(), and xfree.

◆ yaz_marc_sax_get_handler()

xmlSAXHandlerPtr yaz_marc_sax_get_handler ( yaz_marc_sax_t ctx)

return Libxml SAX handler pointer

Returns
pointer

Definition at line 159 of file marc_read_sax.c.

References yaz_marc_sax_t_::saxHandler.

◆ yaz_marc_sax_new()

yaz_marc_sax_t yaz_marc_sax_new ( yaz_marc_t mt,
void(* cb )(yaz_marc_t mt, void *),
void * cb_data )

construct marc SAX parser

Parameters
mtmarc handle
cbfunction called for each record
cb_datadata to be passed to each cb call

Definition at line 141 of file marc_read_sax.c.

References yaz_marc_sax_t_::cb_data, yaz_marc_sax_t_::cb_func, yaz_marc_sax_t_::cdata, yaz_marc_sax_t_::indicators, yaz_marc_sax_t_::mt, yaz_marc_sax_t_::saxHandler, yaz_marc_sax_t_::tag, wrbuf_alloc(), xmalloc, yaz_characters(), yaz_end_element_ns(), and yaz_start_element_ns().

◆ yaz_start_element_ns()

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 )
static