X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Fapi%2Fxpath4.c;h=2c97f22265c43fd2fbb32947d87efab41dcd014d;hb=9fb43159103ddd82437c71d7f82eed86614d0f1b;hp=993bc2a77ee38d93ef0f9a179e51efc78db167c5;hpb=ae8b5430a1c36e6b53abd04577757b58c8e5cd65;p=idzebra-moved-to-github.git diff --git a/test/api/xpath4.c b/test/api/xpath4.c index 993bc2a..2c97f22 100644 --- a/test/api/xpath4.c +++ b/test/api/xpath4.c @@ -1,6 +1,6 @@ -/* $Id: xpath4.c,v 1.1 2004-10-29 14:16:22 heikki Exp $ +/* $Id: xpath4.c,v 1.4 2004-11-05 18:08:06 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -50,10 +50,39 @@ const char *myrec[] = { " \n", " \n" + " double english \n" + " double danish \n" + " grunt \n" + " \n", + + " \n" " hamlet \n" - " foo bar grunt \n" + " foo bar grunt grunt grunt \n" + " \n", + + " \n" + " before \n" + " \n" + " early \n" + " \n" + " middle \n" + " \n" + " late \n" + " \n" + " after \n" " \n", + " \n" + " before \n" + " \n" + " early \n" + " \n" + " middle \n" + " \n" + " late \n" + " \n" + " after \n" + " \n", 0}; @@ -61,6 +90,11 @@ int main(int argc, char **argv) { ZebraService zs = start_up("zebraxpath.cfg", argc, argv); ZebraHandle zh = zebra_open (zs); + +#if 0 + yaz_log_init_level( yaz_log_mask_str_x("xpath4,rsbetween", LOG_DEFAULT_LEVEL)); +#endif + init_data(zh,myrec); #define q(qry,hits) do_query(__LINE__,zh,qry,hits) @@ -69,11 +103,53 @@ int main(int argc, char **argv) q("@attr 1=/record/title bar",2); q("@attr 1=/record/title[@lang='da'] foo",1); q("@attr 1=/record/title[@lang='en'] foo",1); + + q("@attr 1=/record/title[@lang='en'] english",1); + q("@attr 1=/record/title[@lang='da'] english",0); + q("@attr 1=/record/title[@lang='da'] danish",1); + q("@attr 1=/record/title[@lang='en'] danish",0); + q("@attr 1=/record/title @and foo bar",2); - /* The last one returns two hits, as the and applies to the whole + /* The previous one returns two hits, as the and applies to the whole record, so it matches foobar This might not have to be like that, but currently that is what zebra does. */ q("@and @attr 1=/record/title foo @attr 1=/record/title bar ",2); + + /* check we get all the occureences for 'grunt' */ + /* this can only be seen in the log, with debugs on. bug #202 */ + q("@attr 1=/record/author grunt",3); + + /* check nested tags */ + q("@attr 1=/record/nested before",0); + q("@attr 1=/record/nested early",1); + q("@attr 1=/record/nested middle",1); + q("@attr 1=/record/nested late",1); + q("@attr 1=/record/nested after",0); + + q("@attr 1=/record/nested/nested before",0); + q("@attr 1=/record/nested/nested early",0); + q("@attr 1=/record/nested/nested middle",1); + q("@attr 1=/record/nested/nested late",0); + q("@attr 1=/record/nested/nested after",0); + + q("@attr 1=/record/nestattr[@level='outer'] before",0); + q("@attr 1=/record/nestattr[@level='outer'] early",1); + q("@attr 1=/record/nestattr[@level='outer'] middle",1); + q("@attr 1=/record/nestattr[@level='outer'] late",1); + q("@attr 1=/record/nestattr[@level='outer'] after",0); + + q("@attr 1=/record/nestattr[@level='inner'] before",0); + q("@attr 1=/record/nestattr[@level='inner'] early",0); + q("@attr 1=/record/nestattr[@level='inner'] middle",0); + q("@attr 1=/record/nestattr[@level='inner'] late",0); + q("@attr 1=/record/nestattr[@level='inner'] after",0); + + q("@attr 1=/record/nestattr/nestattr[@level='inner'] before",0); + q("@attr 1=/record/nestattr/nestattr[@level='inner'] early",0); + q("@attr 1=/record/nestattr/nestattr[@level='inner'] middle",1); + q("@attr 1=/record/nestattr/nestattr[@level='inner'] late",0); + q("@attr 1=/record/nestattr/nestattr[@level='inner'] after",0); + return close_down(zh, zs, 0); }