File: marc.html

package info (click to toggle)
yaz 3.0.34-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 13,404 kB
  • ctags: 12,108
  • sloc: xml: 116,075; ansic: 52,205; sh: 9,746; tcl: 2,043; makefile: 1,141; yacc: 347
file content (78 lines) | stat: -rw-r--r-- 5,202 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>5.�MARC</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="YAZ User's Guide and Reference"><link rel="up" href="tools.html" title="Chapter�7.�Supporting Tools"><link rel="prev" href="tools.log.html" title="4.�Log"><link rel="next" href="tools.retrieval.html" title="6.�Retrieval Facility"></head><body><link rel="stylesheet" type="text/css" href="common/style1.css"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.�MARC</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="tools.log.html">Prev</a>�</td><th width="60%" align="center">Chapter�7.�Supporting Tools</th><td width="20%" align="right">�<a accesskey="n" href="tools.retrieval.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="marc"></a>5.�MARC</h2></div></div></div><p>
    YAZ provides a fast utility that decodes MARC records and
    encodes to a varity of output formats. The MARC records must
    be encoded in ISO2709.
   </p><pre class="synopsis">
    #include &lt;yaz/marcdisp.h&gt;

    /* create handler */
    yaz_marc_t yaz_marc_create(void);
    /* destroy */
    void yaz_marc_destroy(yaz_marc_t mt);

    /* set XML mode YAZ_MARC_LINE, YAZ_MARC_SIMPLEXML, ... */
    void yaz_marc_xml(yaz_marc_t mt, int xmlmode);
    #define YAZ_MARC_LINE      0
    #define YAZ_MARC_SIMPLEXML 1
    #define YAZ_MARC_OAIMARC   2
    #define YAZ_MARC_MARCXML   3
    #define YAZ_MARC_ISO2709   4
    #define YAZ_MARC_XCHANGE   5

    /* supply iconv handle for character set conversion .. */
    void yaz_marc_iconv(yaz_marc_t mt, yaz_iconv_t cd);

    /* set debug level, 0=none, 1=more, 2=even more, .. */
    void yaz_marc_debug(yaz_marc_t mt, int level);

    /* decode MARC in buf of size bsize. Returns &gt;0 on success; &lt;=0 on failure.
    On success, result in *result with size *rsize. */
    int yaz_marc_decode_buf (yaz_marc_t mt, const char *buf, int bsize,
                             char **result, int *rsize);

    /* decode MARC in buf of size bsize. Returns &gt;0 on success; &lt;=0 on failure.
       On success, result in WRBUF */
    int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf,
                               int bsize, WRBUF wrbuf);

   </pre><p>
    A MARC conversion handle must be created by using
    <code class="function">yaz_marc_create</code> and destroyed
    by calling <code class="function">yaz_marc_destroy</code>.
  </p><p>
    All other function operate on a <code class="literal">yaz_marc_t</code> handle.
    The output is specified by a call to <code class="function">yaz_marc_xml</code>.
    The <code class="literal">xmlmode</code> must be one of
    </p><div class="variablelist"><dl><dt><span class="term">YAZ_MARC_LINE</span></dt><dd><p>
	A simple line-by-line format suitable for display but not
	recommend for further (machine) processing.
       </p></dd><dt><span class="term">YAZ_MARC_MARCXML</span></dt><dd><p>
	The resulting record is converted to MARCXML.
       </p></dd><dt><span class="term">YAZ_MARC_ISO2709</span></dt><dd><p>
	The resulting record is converted to ISO2709 (MARC).
       </p></dd></dl></div><p>
   </p><p>
    The actual conversion functions are 
    <code class="function">yaz_marc_decode_buf</code> and
    <code class="function">yaz_marc_decode_wrbuf</code> which decodes and encodes
    a MARC record. The former function operates on simple buffers, the
    stores the resulting record in a WRBUF handle (WRBUF is a simple string
    type).
   </p><div class="example"><a name="example.marc.display"></a><p class="title"><b>Example�7.18.�Display of MARC record</b></p><div class="example-contents"><p>
     The followint program snippet illustrates how the MARC API may
     be used to convert a MARC record to the line-by-line format:
     </p><pre class="programlisting">
      void print_marc(const char *marc_buf, int marc_buf_size)
      {
         char *result;      /* for result buf */
         int result_len;    /* for size of result */
         yaz_marc_t mt = yaz_marc_create();
         yaz_marc_xml(mt, YAZ_MARC_LINE);
         yaz_marc_decode_buf(mt, marc_buf, marc_buf_size,
                             &amp;result, &amp;result_len);
         fwrite(result, result_len, 1, stdout);
         yaz_marc_destroy(mt);  /* note that result is now freed... */
      }

      </pre><p>
    </p></div></div><br class="example-break"></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="tools.log.html">Prev</a>�</td><td width="20%" align="center"><a accesskey="u" href="tools.html">Up</a></td><td width="40%" align="right">�<a accesskey="n" href="tools.retrieval.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4.�Log�</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">�6.�Retrieval Facility</td></tr></table></div></body></html>