2007.
[idzebra-moved-to-github.git] / test / xslt / xslt5.c
1 /* $Id: xslt5.c,v 1.4 2007-01-15 15:10:26 adam Exp $
2    Copyright (C) 1995-2007
3    Index Data ApS
4
5 This file is part of the Zebra server.
6
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
21 */
22
23 #include <stdio.h>
24 #include "testlib.h"
25
26 #if YAZ_HAVE_XML2
27 #include <libxml/xmlversion.h>
28 #endif
29
30 static void tst(int argc, char **argv)
31 {
32     char path[256];
33     char profile_path[256];
34     char record_buf[20000];
35     FILE *f;
36     size_t r;
37
38     ZebraService zs = tl_start_up(0, argc, argv);
39     ZebraHandle  zh = zebra_open(zs, 0);
40
41     tl_check_filter(zs, "alvis");
42
43     YAZ_CHECK_EQ(zebra_select_database(zh, "Default"), ZEBRA_OK);
44     
45     zebra_init(zh);
46
47     sprintf(profile_path, "%s:%s/../../tab", 
48             tl_get_srcdir(), tl_get_srcdir());
49     zebra_set_resource(zh, "profilePath", profile_path);
50
51     zebra_set_resource(zh, "recordType", "alvis.marcschema-one.xml");
52
53     sprintf(path, "%.200s/marc-missing-ns.xml", tl_get_srcdir());
54     f = fopen(path, "rb");
55     YAZ_CHECK(f);
56     if (f)
57     {
58         r = fread(record_buf, 1, sizeof(record_buf)-1, f);
59         YAZ_CHECK(r > 0);
60         fclose(f);
61         YAZ_CHECK(r > 2);
62         record_buf[r] = '\0';
63
64 #if 0
65 /* disable this test for now: bug #730 */ 
66 /* http://xmlsoft.org/html/libxml-parser.html#xmlReadIO */
67 #if YAZ_HAVE_XML2
68         /* On Mac OSX using Libxml 2.6.16, we xmlTextReaderExpand does
69            not return 0 ptr even though the record has an error in it */
70 #if LIBXML_VERSION >= 20617
71         YAZ_CHECK_EQ(zebra_add_record(zh, record_buf, strlen(record_buf)),
72                      ZEBRA_FAIL);
73 #else
74         zebra_add_record(zh, record_buf, strlen(record_buf));
75 #endif
76 #endif
77 #endif
78     }
79     YAZ_CHECK(tl_close_down(zh, zs));
80 }
81
82 TL_MAIN
83
84 /*
85  * Local variables:
86  * c-basic-offset: 4
87  * indent-tabs-mode: nil
88  * End:
89  * vim: shiftwidth=4 tabstop=8 expandtab
90  */
91