1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2010 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
20 /** \brief test special element set names zebra:: and friends */
24 const char *myrec[] = {
26 " <title>My title</title>\n"
30 static void tst(int argc, char **argv)
34 const char * zebra_xml_sysno
35 = "<record xmlns=\"http://www.indexdata.com/zebra/\" sysno=\"2\"/>\n";
37 const char * zebra_xml_meta
38 = "<record xmlns=\"http://www.indexdata.com/zebra/\" sysno=\"2\" base=\"Default\" type=\"grs.sgml\" rank=\"0\" size=\"41\" set=\"zebra::meta\"/>\n";
40 const char * zebra_xml_index_title_p
41 = "<record xmlns=\"http://www.indexdata.com/zebra/\" sysno=\"2\" set=\"zebra::index::title:p\">\n"
42 " <index name=\"title\" type=\"p\" seq=\"4\">my title</index>\n"
45 const char * zebra_xml_index_title_s
46 = "<record xmlns=\"http://www.indexdata.com/zebra/\" sysno=\"2\" set=\"zebra::index::title:s\">\n"
47 " <index name=\"title\" type=\"s\">my title</index>\n"
50 ZebraService zs = tl_start_up(0, argc, argv);
51 ZebraHandle zh = zebra_open(zs, 0);
53 YAZ_CHECK(tl_init_data(zh, myrec));
55 res = zebra_search_PQF(zh, "@attr 1=4 my", "rsetname", &hits);
56 YAZ_CHECK_EQ(res, ZEBRA_OK);
57 YAZ_CHECK_EQ(hits, 1);
59 YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::data", yaz_oid_recsyn_xml,
60 "mismatch"), ZEBRA_FAIL);
62 YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::data", yaz_oid_recsyn_sutrs,
65 YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::data", yaz_oid_recsyn_xml,
68 YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::meta::sysno",
72 YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::meta::sysno",
74 zebra_xml_sysno), ZEBRA_OK);
76 YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::meta", yaz_oid_recsyn_xml,
77 zebra_xml_meta), ZEBRA_OK);
79 YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::index::title:p",
81 zebra_xml_index_title_p), ZEBRA_OK);
83 YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::index::title:s",
85 zebra_xml_index_title_s), ZEBRA_OK);
87 YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::nonexistent",
88 yaz_oid_recsyn_xml, ""), ZEBRA_OK);
90 YAZ_CHECK_EQ(tl_fetch_first_compare(zh, "zebra::index::nonexistent",
91 yaz_oid_recsyn_xml, ""), ZEBRA_OK);
93 YAZ_CHECK(tl_close_down(zh, zs));
101 * c-file-style: "Stroustrup"
102 * indent-tabs-mode: nil
104 * vim: shiftwidth=4 tabstop=8 expandtab