YAZ  5.23.1
Data Structures | Macros | Functions
record_conv.c File Reference

Record Conversions utility. More...

#include <string.h>
#include <yaz/log.h>
#include <yaz/yaz-iconv.h>
#include <yaz/marcdisp.h>
#include <yaz/record_conv.h>
#include <yaz/wrbuf.h>
#include <yaz/xmalloc.h>
#include <yaz/nmem.h>
#include <yaz/tpath.h>
#include <yaz/z-opac.h>
#include <yaz/xml_get.h>
#include <yaz/url.h>
#include <yaz/srw.h>
#include <yaz/timing.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xinclude.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <libxslt/xsltutils.h>
#include <libxslt/transform.h>

Go to the source code of this file.

Data Structures

struct  yaz_record_conv_struct
 The internal structure for yaz_record_conv_t. More...
 
struct  marc_info
 
struct  yaz_record_conv_rule
 transformation info (rule info) More...
 
struct  xslt_info
 
struct  select_info
 
struct  rdf_lookup_info
 

Macros

#define RDF_LOOKUP_MAX_KEYS   20
 
#define RDF_LOOKUP_MAX_NAMESPACES   20
 

Functions

static void yaz_record_conv_reset (yaz_record_conv_t p)
 reset rules+configuration More...
 
void yaz_record_conv_destroy (yaz_record_conv_t p)
 
static void * construct_xslt (const xmlNode *ptr, const char *path, WRBUF wr_error)
 
static int convert_xslt (void *vinfo, WRBUF record, WRBUF wr_error)
 
static void destroy_xslt (void *vinfo)
 
static void * construct_select (const xmlNode *ptr, const char *path, WRBUF wr_error)
 
static int convert_select (void *vinfo, WRBUF record, WRBUF wr_error)
 
static void destroy_select (void *vinfo)
 
static void * construct_solrmarc (const xmlNode *ptr, const char *path, WRBUF wr_error)
 
static int convert_solrmarc (void *info, WRBUF record, WRBUF wr_error)
 
static void destroy_solrmarc (void *info)
 
static void * construct_marc (const xmlNode *ptr, const char *path, WRBUF wr_error)
 
static int convert_marc (void *info, WRBUF record, WRBUF wr_error)
 
static void destroy_marc (void *info)
 
static struct rdf_lookup_infoconstruct_one_rdf_lookup (NMEM nmem, const xmlNode *ptr, WRBUF wr_error, int timeout)
 
static void * construct_rdf_lookup (const xmlNode *ptr, const char *path, WRBUF wr_error)
 
static void destroy_rdf_lookup (void *info)
 
static void rdf_lookup_debug_comment (xmlNode *n, WRBUF uri, Z_HTTP_Response *resp, struct rdf_lookup_info *info, yaz_timing_t tim, const char *msg, int yloglevel)
 
static void rdf_lookup_node (xmlNode *n, xmlXPathContextPtr xpathCtx, struct rdf_lookup_info *info)
 
static int convert_rdf_lookup (void *rinfo, WRBUF record, WRBUF wr_error)
 
int yaz_record_conv_configure_t (yaz_record_conv_t p, const xmlNode *ptr, struct yaz_record_conv_type *types)
 
int yaz_record_conv_configure (yaz_record_conv_t p, const xmlNode *ptr)
 
static int yaz_record_conv_record_rule (yaz_record_conv_t p, struct yaz_record_conv_rule *r, const char *input_record_buf, size_t input_record_len, WRBUF output_record)
 
int yaz_record_conv_opac_record (yaz_record_conv_t p, Z_OPACRecord *input_record, WRBUF output_record)
 
int yaz_record_conv_record (yaz_record_conv_t p, const char *input_record_buf, size_t input_record_len, WRBUF output_record)
 
const char * yaz_record_conv_get_error (yaz_record_conv_t p)
 
void yaz_record_conv_set_path (yaz_record_conv_t p, const char *path)
 
yaz_record_conv_t yaz_record_conv_create ()
 

Detailed Description

Record Conversions utility.

Definition in file record_conv.c.

Macro Definition Documentation

#define RDF_LOOKUP_MAX_KEYS   20

Definition at line 689 of file record_conv.c.

Referenced by construct_one_rdf_lookup().

#define RDF_LOOKUP_MAX_NAMESPACES   20

Definition at line 690 of file record_conv.c.

Referenced by construct_rdf_lookup().

Function Documentation

static void* construct_marc ( const xmlNode *  ptr,
const char *  path,
WRBUF  wr_error 
)
static
static struct rdf_lookup_info* construct_one_rdf_lookup ( NMEM  nmem,
const xmlNode *  ptr,
WRBUF  wr_error,
int  timeout 
)
static
static void* construct_rdf_lookup ( const xmlNode *  ptr,
const char *  path,
WRBUF  wr_error 
)
static
static void* construct_select ( const xmlNode *  ptr,
const char *  path,
WRBUF  wr_error 
)
static
static void* construct_solrmarc ( const xmlNode *  ptr,
const char *  path,
WRBUF  wr_error 
)
static

Definition at line 415 of file record_conv.c.

References yaz_record_conv_struct::wr_error.

Referenced by yaz_record_conv_configure_t().

static void* construct_xslt ( const xmlNode *  ptr,
const char *  path,
WRBUF  wr_error 
)
static
static int convert_marc ( void *  info,
WRBUF  record,
WRBUF  wr_error 
)
static
static int convert_rdf_lookup ( void *  rinfo,
WRBUF  record,
WRBUF  wr_error 
)
static
static int convert_select ( void *  vinfo,
WRBUF  record,
WRBUF  wr_error 
)
static
static int convert_solrmarc ( void *  info,
WRBUF  record,
WRBUF  wr_error 
)
static
static int convert_xslt ( void *  vinfo,
WRBUF  record,
WRBUF  wr_error 
)
static
static void destroy_marc ( void *  info)
static

Definition at line 680 of file record_conv.c.

References marc_info::nmem, and nmem_destroy().

Referenced by yaz_record_conv_configure_t().

static void destroy_rdf_lookup ( void *  info)
static

Definition at line 911 of file record_conv.c.

References rdf_lookup_info::nmem, nmem_destroy(), yaz_log(), and YLOG_DEBUG.

Referenced by yaz_record_conv_configure_t().

static void destroy_select ( void *  vinfo)
static

Definition at line 406 of file record_conv.c.

References select_info::nmem, and nmem_destroy().

Referenced by yaz_record_conv_configure_t().

static void destroy_solrmarc ( void *  info)
static

Definition at line 444 of file record_conv.c.

Referenced by yaz_record_conv_configure_t().

static void destroy_xslt ( void *  vinfo)
static

Definition at line 312 of file record_conv.c.

References xslt_info::nmem, nmem_destroy(), and xslt_info::xsp_doc.

Referenced by yaz_record_conv_configure_t().

static void rdf_lookup_debug_comment ( xmlNode *  n,
WRBUF  uri,
Z_HTTP_Response resp,
struct rdf_lookup_info info,
yaz_timing_t  tim,
const char *  msg,
int  yloglevel 
)
static
static void rdf_lookup_node ( xmlNode *  n,
xmlXPathContextPtr  xpathCtx,
struct rdf_lookup_info info 
)
static
int yaz_record_conv_configure ( yaz_record_conv_t  p,
const xmlNode *  node 
)

configures record conversion

Parameters
precord conversion handle
nodexmlNode pointer (root element of XML config)
Return values
0success
-1failure

On failure, use yaz_record_conv_get_error to get error string.

<backend syntax='xml'>
  <xslt stylesheet="dc2marcxml.xsl"/>
  <marc inputformat="xml" outputformat="marcxml" outputcharset="marc-8"/>
</backend>
<backend syntax='usmarc' name='F'>
  <marc inputformat="marc" outputformat="marcxml" inputcharset="marc-8"/>
  <xslt stylesheet="marcxml2mods.xsl"/>
  <xslt stylesheet="mods2dc.xsl"/>
</backend>

Definition at line 1208 of file record_conv.c.

References yaz_record_conv_configure_t().

int yaz_record_conv_configure_t ( yaz_record_conv_t  p,
const xmlNode *  node,
struct yaz_record_conv_type types 
)
yaz_record_conv_t yaz_record_conv_create ( void  )
void yaz_record_conv_destroy ( yaz_record_conv_t  p)

destroys record handle

Parameters
precord conversion handle

Definition at line 94 of file record_conv.c.

References yaz_record_conv_struct::nmem, nmem_destroy(), yaz_record_conv_struct::path, yaz_record_conv_struct::wr_error, wrbuf_destroy(), xfree, and yaz_record_conv_reset().

Referenced by conf_retrieval(), and yaz_retrieval_reset().

const char* yaz_record_conv_get_error ( yaz_record_conv_t  p)

returns error string (for last error)

Parameters
precord conversion handle
Returns
error string

Definition at line 1284 of file record_conv.c.

References yaz_record_conv_struct::wr_error, and wrbuf_cstr().

Referenced by conf_retrieval(), and retrieve_fetch().

int yaz_record_conv_opac_record ( yaz_record_conv_t  p,
Z_OPACRecord input_record,
WRBUF  output_record 
)
int yaz_record_conv_record ( yaz_record_conv_t  p,
const char *  input_record_buf,
size_t  input_record_len,
WRBUF  output_record 
)

performs record conversion on record buffer (OCTET aligned)

Parameters
precord conversion handle
input_record_bufinput record buffer
input_record_lenlength of input record buffer
output_recordresultint record (WRBUF string)
Return values
0success
-1failure

On failure, use yaz_record_conv_get_error to get error string.

Definition at line 1274 of file record_conv.c.

References yaz_record_conv_struct::rules, and yaz_record_conv_record_rule().

Referenced by retrieve_fetch().

static int yaz_record_conv_record_rule ( yaz_record_conv_t  p,
struct yaz_record_conv_rule r,
const char *  input_record_buf,
size_t  input_record_len,
WRBUF  output_record 
)
static
static void yaz_record_conv_reset ( yaz_record_conv_t  p)
static
void yaz_record_conv_set_path ( yaz_record_conv_t  p,
const char *  path 
)

set path for opening stylesheets etc.

Parameters
precord conversion handle
pathfile path (UNIX style with : / Windows with ;)

Definition at line 1289 of file record_conv.c.

References yaz_record_conv_struct::path, xfree, and xstrdup.

Referenced by conf_retrieval().