00df235d7a5166d72c71dfb0896a14e5bcab8168
[yaz-moved-to-github.git] / include / yaz / record_conv.h
1 /*
2  * Copyright (C) 2005-2006, Index Data ApS
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation, in whole or in part, for any purpose, is hereby granted,
6  * provided that:
7  *
8  * 1. This copyright and permission notice appear in all copies of the
9  * software and its documentation. Notices of copyright or attribution
10  * which appear at the beginning of any file must remain unchanged.
11  *
12  * 2. The name of Index Data or the individual authors may not be used to
13  * endorse or promote products derived from this software without specific
14  * prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19  * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
20  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
21  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
22  * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24  * OF THIS SOFTWARE.
25  *
26  * $Id: record_conv.h,v 1.2 2006-05-03 13:04:46 adam Exp $
27  */
28 /**
29  * \file record_conv.h
30  * \brief Record Conversions Utility
31  */
32
33 #ifndef YAZ_RECORD_CONV_H
34 #define YAZ_RECORD_CONV_H
35
36 #include <stddef.h>
37 #include <yaz/wrbuf.h>
38 #include <yaz/yconfig.h>
39
40 YAZ_BEGIN_CDECL
41
42 /** record conversion handle  */
43 typedef struct yaz_record_conv_struct *yaz_record_conv_t;
44
45 /** creates record handle
46     \return record handle
47 */
48 YAZ_EXPORT yaz_record_conv_t yaz_record_conv_create(void);
49
50 /** destroys record handle
51     \param p record conversion handle
52 */
53 YAZ_EXPORT void yaz_record_conv_destroy(yaz_record_conv_t p);
54
55 /** configures record conversion
56     \param p record conversion handle
57     \param node xmlNode pointer (root element of XML config)
58     \retval 0 success
59     \retval -1 failure
60
61     On failure, use yaz_record_conv_get_error to get error string.
62     
63     \verbatim
64     <convert>
65       <xslt stylesheet="dc2marcxml.xsl"/>
66       <xmltomarc charset="marc-8"/>
67     </convert>
68     \endverbatim
69
70     \verbatim
71     <convert>
72       <marctoxml charset="marc-8"/>
73       <xslt stylesheet="marcxml2mods.xsl"/>
74       <xslt stylesheet="mods2dc.xsl"/>
75     </convert>
76     \endverbatim
77
78     For retrieval (ignore here):
79     \verbatim
80     <retrievalinfo>
81        <retrieval syntax="usmarc" name="marcxml"
82             identifier="info:srw/schema/1/marcxml-v1.1"
83        >
84          <title>MARCXML</title>
85          <backend syntax="xml" name="dc" charset="utf-8"/>
86          <convert>
87            <xslt stylesheet="dc2marcxml.xsl"/>
88            <xmltomarc charset="marc-8"/>
89          </convert>
90        </retrieval>
91     </retrievalinfo>
92     \endverbatim
93
94 */
95 YAZ_EXPORT
96 int yaz_record_conv_configure(yaz_record_conv_t p, const void *node);
97
98 /** performs record conversion
99     \param p record conversion handle
100     \param input_record record to be converted (0-terminated)
101     \param output_record resultint record (WRBUF string)
102     \retval 0 success
103     \retval -1 failure
104
105     On failure, use yaz_record_conv_get_error to get error string.
106 */
107 YAZ_EXPORT
108 int yaz_record_conv_record(yaz_record_conv_t p, const char *input_record,
109                            WRBUF output_record);
110
111 /** returns error string (for last error)
112     \param p record conversion handle
113     \return error string
114 */    
115 YAZ_EXPORT
116 const char *yaz_record_conv_get_error(yaz_record_conv_t p);
117
118
119 /** set path for opening stylesheets etc.
120     \param p record conversion handle
121     \param path file path (UNIX style with : / Windows with ;)
122 */    
123 YAZ_EXPORT
124 void yaz_record_conv_set_path(yaz_record_conv_t p, const char *path);
125
126 YAZ_END_CDECL
127
128 #endif
129 /*
130  * Local variables:
131  * c-basic-offset: 4
132  * indent-tabs-mode: nil
133  * End:
134  * vim: shiftwidth=4 tabstop=8 expandtab
135  */
136