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