2bcde1e9c62941cb1fef87ee8cb62af480517d95
[idzebra-moved-to-github.git] / test / api / xpath2.c
1 /* $Id: xpath2.c,v 1.2 2004-12-02 11:28:20 adam Exp $
2    Copyright (C) 2003,2004
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 Zebra; see the file LICENSE.zebra.  If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.
21 */
22
23 #include "testlib.h"
24
25
26 /** xpath2.c - index a a bit more complex sgml record and search in it */
27
28 const char *myrec[] = {
29     "<Zthes> \n"
30     " <termId>10</termId> \n"
31     " <termName>Sauropoda</termName> \n"
32     " <termType>PT</termType> \n"
33     " <relation> \n"
34     "  <relationType>BT</relationType> \n"
35     "  <termId>5</termId> \n"
36     "  <termName>Brontosauria</termName> \n"
37     "  <termType>PT</termType> \n"
38     " </relation> \n"
39     " <relation> \n"
40     "  <relationType>NT</relationType> \n"
41     "  <termId>11</termId> \n"
42     "  <termName>Eusauropoda</termName> \n"
43     "  <termType>PT</termType> \n"
44     " </relation> \n"
45     "</Zthes> \n",
46
47     "<Zthes> \n"
48     " <termId>5</termId> \n"
49     " <termName>Brontosauria</termName> \n"
50     " <termType>PT</termType> \n"
51     " <relation> \n"
52     "  <relationType>BT</relationType> \n"
53     "  <termId>4</termId> \n"
54     "  <termName>Sauropodomorpha</termName> \n"
55     "  <termType>PT</termType> \n"
56     " </relation> \n"
57     " <relation> \n"
58     "  <relationType>NT</relationType> \n"
59     "  <termId>6</termId> \n"
60     "  <termName>Plateosauria</termName> \n"
61     "  <termType>PT</termType> \n"
62     " </relation> \n"
63     " <relation> \n"
64     "  <relationType>NT</relationType> \n"
65     "  <termId>10</termId> \n"
66     "  <termName>Sauropoda</termName> \n"
67     "  <termType>PT</termType> \n"
68     " </relation> \n"
69     "</Zthes> \n",
70     0};
71
72
73 int main(int argc, char **argv)
74 {
75     ZebraService zs = start_up("zebraxpath.cfg", argc, argv);
76     ZebraHandle zh = zebra_open (zs);
77     init_data(zh, myrec);
78
79     do_query(__LINE__,zh, "@attr 1=/Zthes/termName Sauropoda", 1);
80     do_query(__LINE__,zh, "@attr 1=/Zthes/relation/termName Sauropoda",1);
81
82     return close_down(zh, zs, 0);
83 }