1 /* This file is part of the Zebra server.
2 Copyright (C) 1995-2008 Index Data
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
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
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
24 void index_more(ZebraHandle zh, const char *filter, const char *file)
27 char profile_path[256];
29 sprintf(profile_path, "%.80s:%.80s/../../tab",
30 tl_get_srcdir(), tl_get_srcdir());
31 zebra_set_resource(zh, "profilePath", profile_path);
33 zebra_set_resource(zh, "recordType", filter);
35 YAZ_CHECK(zebra_begin_trans(zh, 1) == ZEBRA_OK);
36 sprintf(path, "%.80s/%.80s", tl_get_srcdir(), file);
38 YAZ_CHECK(zebra_repository_update(zh, path) == ZEBRA_OK);
39 YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
43 ZebraHandle index_some(ZebraService zs,
44 const char *filter, const char *file)
46 ZebraHandle zh = zebra_open(zs, 0);
48 tl_check_filter(zs, "dom");
50 YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
54 index_more(zh, filter, file);
58 void tst(int argc, char **argv)
62 ZebraService zs = tl_start_up(0, argc, argv);
64 zh = index_some(zs, "dom.bad.xml", "marc-col.xml");
68 /* testing XMLREADER input with PI stylesheet */
69 zh = index_some(zs, "dom.dom-config-col.xml", "marc-col.xml");
70 YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 3));
72 /* fetch first using dom-brief.xsl */
73 YAZ_CHECK_EQ(tl_fetch_first_compare(
74 zh, "B", yaz_oid_recsyn_xml,
75 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
76 "<title>How to program a computer</title>\n"),
78 /* fetch first using dom-snippets.xsl */
79 YAZ_CHECK_EQ(tl_fetch_first_compare(
80 zh, "snippet", yaz_oid_recsyn_xml,
81 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
83 " <z:meta xmlns:z=\"http://indexdata.com/zebra-2.0\" name=\"snippet\">"
84 "<record xmlns=\"http://www.indexdata.com/zebra/\">\n"
85 " <snippet name=\"title\" type=\"w\">How to program a <s>computer</s></snippet>\n"
86 "</record></z:meta>\n"
87 " <title>How to program a computer</title>\n"
91 YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1));
93 YAZ_CHECK(tl_query_x(zh, "@attr 1=titl computer", 0, 114));
94 YAZ_CHECK(tl_query_x(zh, "@attr 1=4 computer", 0, 121));
98 /* testing XMLREADER input with ELEMENT stylesheet */
99 zh = index_some(zs, "dom.dom-config-one.xml", "marc-one.xml");
100 YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 1));
101 YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1));
102 YAZ_CHECK(tl_query_x(zh, "@attr 1=titl computer", 0, 114));
103 YAZ_CHECK(tl_query_x(zh, "@attr 1=4 computer", 0, 121));
106 /* testing MARC input with ELEMENT stylesheet */
107 zh = index_some(zs, "dom.dom-config-marc.xml", "marc-col.mrc");
108 YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 3));
109 YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1));
110 YAZ_CHECK(tl_query_x(zh, "@attr 1=titl computer", 0, 114));
111 YAZ_CHECK(tl_query_x(zh, "@attr 1=4 computer", 0, 121));
114 /* testing XMLREADER input with ELEMENT stylesheet and skipped records */
115 zh = index_some(zs, "dom.dom-config-skipped.xml", "marc-col.xml");
116 YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 1));
117 YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 0));
118 YAZ_CHECK(tl_query(zh, "@attr 1=control 11224467", 1));
119 YAZ_CHECK(tl_query(zh, "@attr 1=control 73090924", 0));
121 /* testing XMLREADER input with type attributes (insert,delete,..) */
122 zh = index_some(zs, "dom.dom-config-del.xml", "del-col.xml");
123 YAZ_CHECK(tl_query(zh, "@attr 1=title a", 1));
124 YAZ_CHECK(tl_query(zh, "@attr 1=title 1", 0));
125 YAZ_CHECK(tl_query(zh, "@attr 1=title 2", 0));
126 YAZ_CHECK(tl_query(zh, "@attr 1=title 3", 1));
127 YAZ_CHECK(tl_query(zh, "@attr 1=title b", 1));
129 zh = index_some(zs, "dom.gutenberg.xml", "gutenberg-sample.xml");
130 YAZ_CHECK(tl_query(zh, "selected", 1));
132 YAZ_CHECK_EQ(tl_fetch_first_compare(
133 zh, "zebra::snippet", yaz_oid_recsyn_xml,
134 "<record xmlns=\"http://www.indexdata.com/zebra/\">\n"
135 " <snippet name=\"any\" type=\"w\">etext/1338\n"
136 " Project Gutenberg\n"
137 " <s>Selected</s> Prose of Oscar Wilde</snippet>\n"
144 YAZ_CHECK(tl_close_down(0, zs));
152 * indent-tabs-mode: nil
154 * vim: shiftwidth=4 tabstop=8 expandtab