Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/idzebra
[idzebra-moved-to-github.git] / test / xpath / xpath2.c
1 /* This file is part of the Zebra server.
2    Copyright (C) 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 #if HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23 #include "../api/testlib.h"
24
25 /** xpath2.c - index a a bit more complex sgml record and search in it */
26
27 const char *myrec[] = {
28     "<Zthes> \n"
29     " <termId>10</termId> \n"
30     " <termName>Sauropoda</termName> \n"
31     " <termType>PT</termType> \n"
32     " <relation> \n"
33     "  <relationType>BT</relationType> \n"
34     "  <termId>5</termId> \n"
35     "  <termName>Brontosauria</termName> \n"
36     "  <termType>PT</termType> \n"
37     " </relation> \n"
38     " <relation> \n"
39     "  <relationType>NT</relationType> \n"
40     "  <termId>11</termId> \n"
41     "  <termName>Eusauropoda</termName> \n"
42     "  <termType>PT</termType> \n"
43     " </relation> \n"
44     "</Zthes> \n",
45
46     "<Zthes> \n"
47     " <termId>5</termId> \n"
48     " <termName>Brontosauria</termName> \n"
49     " <termType>PT</termType> \n"
50     " <relation> \n"
51     "  <relationType>BT</relationType> \n"
52     "  <termId>4</termId> \n"
53     "  <termName>Sauropodomorpha</termName> \n"
54     "  <termType>PT</termType> \n"
55     " </relation> \n"
56     " <relation> \n"
57     "  <relationType>NT</relationType> \n"
58     "  <termId>6</termId> \n"
59     "  <termName>Plateosauria</termName> \n"
60     "  <termType>PT</termType> \n"
61     " </relation> \n"
62     " <relation> \n"
63     "  <relationType>NT</relationType> \n"
64     "  <termId>10</termId> \n"
65     "  <termName>Sauropoda</termName> \n"
66     "  <termType>PT</termType> \n"
67     " </relation> \n"
68     "</Zthes> \n",
69     0};
70
71
72 static void tst(int argc, char **argv)
73 {
74     ZebraService zs = tl_start_up(0, argc, argv);
75     ZebraHandle zh = zebra_open(zs, 0);
76     YAZ_CHECK(tl_init_data(zh, myrec));
77
78     YAZ_CHECK(tl_query(zh, "@attr 1=/Zthes/termName Sauropoda", 1));
79     YAZ_CHECK(tl_query(zh, "@attr 1=/Zthes/relation/termName Sauropoda", 1));
80
81     YAZ_CHECK(tl_close_down(zh, zs));
82 }
83
84 TL_MAIN
85
86 /*
87  * Local variables:
88  * c-basic-offset: 4
89  * c-file-style: "Stroustrup"
90  * indent-tabs-mode: nil
91  * End:
92  * vim: shiftwidth=4 tabstop=8 expandtab
93  */
94