3 /* $Id: xpath4.c,v 1.1 2004-10-29 14:16:22 heikki Exp $
4 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
7 This file is part of the Zebra server.
9 Zebra is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
14 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License
20 along with Zebra; see the file LICENSE.zebra. If not, write to the
21 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
28 /** xpath4.c - Attributes */
30 const char *myrec[] = {
32 " <title>foo</title> \n"
33 " <title>bar</title> \n"
34 " <author>gryf</author> \n"
38 " <title>foo bar</title> \n"
39 " <author>gryf</author> \n"
43 " <title lang=en>foo gryf</title> \n"
44 " <author>grunt</author> \n"
48 " <title lang=da>foo grunt</title> \n"
49 " <value>bar</value> \n"
53 " <title>hamlet</title> \n"
54 " <author>foo bar grunt</author> \n"
60 int main(int argc, char **argv)
62 ZebraService zs = start_up("zebraxpath.cfg", argc, argv);
63 ZebraHandle zh = zebra_open (zs);
66 #define q(qry,hits) do_query(__LINE__,zh,qry,hits)
68 q("@attr 1=/record/title foo",4);
69 q("@attr 1=/record/title bar",2);
70 q("@attr 1=/record/title[@lang='da'] foo",1);
71 q("@attr 1=/record/title[@lang='en'] foo",1);
72 q("@attr 1=/record/title @and foo bar",2);
73 /* The last one returns two hits, as the and applies to the whole
74 record, so it matches <title>foo</title><title>bar</title>
75 This might not have to be like that, but currently that is what
77 q("@and @attr 1=/record/title foo @attr 1=/record/title bar ",2);
78 return close_down(zh, zs, 0);