dnl Zebra, Index Data Aps, 1995-2004
-dnl $Id: configure.in,v 1.107 2004-11-29 21:55:25 adam Exp $
+dnl $Id: configure.in,v 1.108 2004-12-02 14:05:01 adam Exp $
dnl
AC_INIT(include/idzebra/version.h)
AM_INIT_AUTOMAKE(idzebra,1.4.0)
doc/zebraphp.dsl
doc/tkl.xsl
test/Makefile test/gils/Makefile test/usmarc/Makefile test/api/Makefile
+ test/xpath/Makefile
test/rusmarc/Makefile test/cddb/Makefile test/malxml/Makefile
test/config/Makefile test/sort2/Makefile
test/xelm/Makefile
-/* $Id: extract.c,v 1.168 2004-12-01 11:37:45 adam Exp $
+/* $Id: extract.c,v 1.169 2004-12-02 14:05:03 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
key.mem[2] = p->section_id;
key.mem[3] = p->seqno;
-#if 0
+#if 1
/* just for debugging .. */
yaz_log(YLOG_LOG, "add: set=%d use=%d "
"record_id=%lld section_id=%lld seqno=%lld",
const char *b = p->string;
int remain = p->length;
const char **map = 0;
+
+ yaz_log(YLOG_DEBUG, "Incomplete field, w='%.*s'", p->length, p->string);
if (remain > 0)
map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, 0);
int i = 0, remain = p->length;
int first; /* first position */
-yaz_log(YLOG_DEBUG, "Complete field, w='%.*s'", p->length, p->string);
+ yaz_log(YLOG_DEBUG, "Complete field, w='%.*s'", p->length, p->string);
if (remain > 0)
map = zebra_maps_input (p->zebra_maps, p->reg_type, &b, remain, 1);
-SUBDIRS=codec api gils malxml config usmarc dmoz sort sort2 xelm cddb \
+SUBDIRS=codec api xpath gils malxml config usmarc dmoz sort sort2 xelm cddb \
rusmarc zsh marcxml charmap
-# $Id: Makefile.am,v 1.26 2004-11-29 21:55:28 adam Exp $
+# $Id: Makefile.am,v 1.27 2004-12-02 14:05:04 adam Exp $
noinst_PROGRAMS = testclient
testclient_SOURCES = testclient.c
simpletests = t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
-xpathtests= xpath1 xpath2 xpath3 xpath4 xpath5
safaritests = safari1
-check_PROGRAMS = $(simpletests) $(xpathtests) $(safaritests)
+check_PROGRAMS = $(simpletests) $(safaritests)
TESTS = $(check_PROGRAMS)
-EXTRA_DIST=zebra.cfg zebra6.cfg zebra8.cfg zebrazv.cfg \
- zebraxpath.cfg safari.cfg
+EXTRA_DIST=zebra.cfg zebra6.cfg zebra8.cfg zebrazv.cfg safari.cfg
noinst_LIBRARIES = libtestlib.a
t9_SOURCES = t9.c rankingrecords.h
t10_SOURCES = t10.c rankingrecords.h
-xpath1_SOURCES = xpath1.c
-xpath2_SOURCES = xpath2.c
-xpath3_SOURCES = xpath3.c
-xpath4_SOURCES = xpath4.c
-xpath5_SOURCES = xpath5.c
-
safari1_SOURCES = safari1.c testlib.c
AM_CPPFLAGS = -I$(top_srcdir)/include $(YAZINC)
-/* $Id: testlib.c,v 1.6 2004-11-29 21:55:28 adam Exp $
+/* $Id: testlib.c,v 1.7 2004-12-02 14:05:04 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
return start_service(cfgname);
}
+/**
+ * get_srcdir: return env srcdir or . (if does does not exist)
+ */
+const char *get_srcdir()
+{
+ const char *srcdir = getenv("srcdir");
+ if (!srcdir || ! *srcdir)
+ srcdir=".";
+ return srcdir;
+
+}
/** start_service - do a zebra_start with a decent config name */
ZebraService start_service(char *cfgname)
{
char cfg[256];
- char *srcdir = getenv("srcdir");
+ const char *srcdir = get_srcdir();
ZebraService zs;
- if (!srcdir || ! *srcdir)
- srcdir=".";
if (!cfgname || ! *cfgname )
cfgname="zebra.cfg";
- sprintf(cfg, "%.200s/%s",srcdir, cfgname);
+ sprintf(cfg, "%.200s/%.50s", srcdir, cfgname);
zs=zebra_start(cfg);
if (!zs)
{
+++ /dev/null
-/* $Id: xpath1.c,v 1.3 2004-12-02 11:28:20 adam Exp $
- Copyright (C) 2003,2004
- Index Data Aps
-
-This file is part of the Zebra server.
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
-*/
-
-#include <stdlib.h>
-#include <idzebra/api.h>
-#include "testlib.h"
-
-/** xpath1.c - index a simple sgml record and search in it */
-
-int main(int argc, char **argv)
-{
- ZebraService zs;
- ZebraHandle zh;
- const char *myrec[] = {
- "<sgml> \n"
- " before \n"
- " <tag> \n"
- " inside \n"
- " </tag> \n"
- " after \n"
- "</sgml> \n",
- 0};
-
- zs = start_up("zebraxpath.cfg", argc, argv);
- zh = zebra_open(zs);
- init_data(zh, myrec);
-
- do_query(__LINE__,zh, "@attr 1=/sgml/tag before", 0);
- do_query(__LINE__,zh, "@attr 1=/sgml/tag inside", 1);
- do_query(__LINE__,zh, "@attr 1=/sgml/tag after", 0);
-
- do_query(__LINE__,zh, "@attr 1=/sgml/none after", 0);
- do_query(__LINE__,zh, "@attr 1=/sgml/none inside", 0);
-
- do_query(__LINE__,zh, "@attr 1=/sgml before", 1);
- do_query(__LINE__,zh, "@attr 1=/sgml inside", 1);
- do_query(__LINE__,zh, "@attr 1=/sgml after", 1);
-
- return close_down(zh, zs, 0);
-}
+++ /dev/null
-/* $Id: xpath2.c,v 1.2 2004-12-02 11:28:20 adam Exp $
- Copyright (C) 2003,2004
- Index Data Aps
-
-This file is part of the Zebra server.
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
-*/
-
-#include "testlib.h"
-
-
-/** xpath2.c - index a a bit more complex sgml record and search in it */
-
-const char *myrec[] = {
- "<Zthes> \n"
- " <termId>10</termId> \n"
- " <termName>Sauropoda</termName> \n"
- " <termType>PT</termType> \n"
- " <relation> \n"
- " <relationType>BT</relationType> \n"
- " <termId>5</termId> \n"
- " <termName>Brontosauria</termName> \n"
- " <termType>PT</termType> \n"
- " </relation> \n"
- " <relation> \n"
- " <relationType>NT</relationType> \n"
- " <termId>11</termId> \n"
- " <termName>Eusauropoda</termName> \n"
- " <termType>PT</termType> \n"
- " </relation> \n"
- "</Zthes> \n",
-
- "<Zthes> \n"
- " <termId>5</termId> \n"
- " <termName>Brontosauria</termName> \n"
- " <termType>PT</termType> \n"
- " <relation> \n"
- " <relationType>BT</relationType> \n"
- " <termId>4</termId> \n"
- " <termName>Sauropodomorpha</termName> \n"
- " <termType>PT</termType> \n"
- " </relation> \n"
- " <relation> \n"
- " <relationType>NT</relationType> \n"
- " <termId>6</termId> \n"
- " <termName>Plateosauria</termName> \n"
- " <termType>PT</termType> \n"
- " </relation> \n"
- " <relation> \n"
- " <relationType>NT</relationType> \n"
- " <termId>10</termId> \n"
- " <termName>Sauropoda</termName> \n"
- " <termType>PT</termType> \n"
- " </relation> \n"
- "</Zthes> \n",
- 0};
-
-
-int main(int argc, char **argv)
-{
- ZebraService zs = start_up("zebraxpath.cfg", argc, argv);
- ZebraHandle zh = zebra_open (zs);
- init_data(zh, myrec);
-
- do_query(__LINE__,zh, "@attr 1=/Zthes/termName Sauropoda", 1);
- do_query(__LINE__,zh, "@attr 1=/Zthes/relation/termName Sauropoda",1);
-
- return close_down(zh, zs, 0);
-}
+++ /dev/null
-
-/* $Id: xpath3.c,v 1.2 2004-12-02 11:28:20 adam Exp $
- Copyright (C) 2003,2004
- Index Data Aps
-
-This file is part of the Zebra server.
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
-*/
-
-#include "testlib.h"
-
-
-/** xpath3.c - attributes, with Danish characters */
-
-const char *myrec[] = {
- "<root> \n"
- " <!-- Space in attribute --> \n"
- " <first attr=\"danish\">content</first> \n"
- " <second attr=\"danish lake\">content</second> \n"
- " <!-- Oslash in Latin-1 encoded below.. --> \n"
- " <third attr=\"dansk sø\">content<third> \n"
- "</root> \n",
- 0};
-
-
-int main(int argc, char **argv)
-{
- ZebraService zs = start_up("zebraxpath.cfg", argc, argv);
- ZebraHandle zh = zebra_open(zs);
- init_data(zh, myrec);
-
-#define q(qry,hits) do_query(__LINE__,zh,qry,hits)
-
- q("@attr 1=/root content",1);
- q("@attr 1=/root/first content",1);
- q("@attr {1=/root/first[@attr='danish']} content",1);
- q("@attr {1=/root/second[@attr='danish lake']} content",1);
- /*q("@attr {1=/root/third[@attr='dansk sø']} content",1); */
- /* FIXME - This triggers bug200 */
-
- return close_down(zh, zs, 0);
-}
+++ /dev/null
-/* $Id: xpath4.c,v 1.5 2004-12-02 11:28:20 adam Exp $
- Copyright (C) 2003,2004
- Index Data Aps
-
-This file is part of the Zebra server.
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
-*/
-
-#include "testlib.h"
-
-
-/** xpath4.c - Attributes */
-
-const char *myrec[] = {
- "<record> \n"
- " <title>foo</title> \n"
- " <title>bar</title> \n"
- " <author>gryf</author> \n"
- "</record> \n",
-
- "<record> \n"
- " <title>foo bar</title> \n"
- " <author>gryf</author> \n"
- "</record> \n",
-
- "<record> \n"
- " <title lang=en>foo gryf</title> \n"
- " <author>grunt</author> \n"
- "</record> \n",
-
- "<record> \n"
- " <title lang=da>foo grunt</title> \n"
- " <value>bar</value> \n"
- "</record> \n",
-
- "<record> \n"
- " <title lang=en>double english</title> \n"
- " <title lang=da>double danish</title> \n"
- " <author>grunt</author> \n"
- "</record> \n",
-
- "<record> \n"
- " <title>hamlet</title> \n"
- " <author>foo bar grunt grunt grunt</author> \n"
- "</record> \n",
-
- "<record> \n"
- " before \n"
- " <nested> \n"
- " early \n"
- " <nested> \n"
- " middle \n"
- " </nested> \n"
- " late \n"
- " </nested> \n"
- " after \n"
- "</record> \n",
-
- "<record> \n"
- " before \n"
- " <nestattr level=outer> \n"
- " early \n"
- " <nestattr level=inner> \n"
- " middle \n"
- " </nestattr> \n"
- " late \n"
- " </nestattr> \n"
- " after \n"
- "</record> \n",
- 0};
-
-
-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)
-
- q("@attr 1=/record/title foo",4);
- 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 previous one returns two hits, as the and applies to the whole
- record, so it matches <title>foo</title><title>bar</title>
- 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);
-}
+++ /dev/null
-/* $Id: xpath5.c,v 1.4 2004-12-02 11:28:20 adam Exp $
- Copyright (C) 2003,2004
- Index Data Aps
-
-This file is part of the Zebra server.
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
-*/
-
-#include "testlib.h"
-
-
-/** xpath4.c - Ranking in xpath */
-
-
-const char *recs[] = {
- "<record>\n"
- " <title>The first title</title>\n"
- " <abstract> \n"
- " The first common word is the: the the the \n"
- " The second common word is word \n"
- " but all have the foo bar \n"
- " </abstract>\n"
- "</record>\n",
-
- "<record>\n"
- " <title>The second title</title>\n"
- " <abstract> \n"
- " The first common word is the: the \n"
- " The second common word is foo: foo foo \n"
- " but all have the foo bar \n"
- " </abstract>\n"
- "</record>\n",
-
- "<record>\n"
- " <title>The third title</title>\n"
- " <abstract> \n"
- " The first common word is the: the \n"
- " The third common word is bar: bar \n"
- " but all have the foo bar \n"
- " </abstract>\n"
- "</record>\n",
-
- 0 };
-
-
-int main(int argc, char **argv)
-{
- ZebraService zs = start_up("zebraxpath.cfg", argc, argv);
- ZebraHandle zh = zebra_open(zs);
- init_data(zh, recs);
-
-// yaz_log_init_level(LOG_ALL);
-
-#define q(qry,hits,string,score) \
- ranking_query(__LINE__,zh,qry,hits,string,score)
-
- q("@attr 1=/record/title @attr 2=102 the",
- 3,"first title",952);
- q("@attr 1=/ @attr 2=102 @or third foo",
- 3,"third title",802);
-
- q("@attr 1=/ @attr 2=102 foo",
- 3,"second title",850);
-
- q("@attr 1=/record/ @attr 2=102 foo",
- 3,"second title",927);
-
- return close_down(zh, zs, 0);
-}
+++ /dev/null
-# $Id: zebraxpath.cfg,v 1.1 2004-10-29 14:16:22 heikki Exp $
-profilePath: ${srcdir:-.}/../../tab
-recordType: grs.sgml
-attset: bib1.att
-
-isam:b
-
-
-
-
-/* $Id: t1.c,v 1.1 2004-12-02 12:04:49 adam Exp $
+/* $Id: t1.c,v 1.2 2004-12-02 14:05:04 adam Exp $
Copyright (C) 2003,2004
Index Data Aps
{
ZebraService zs = start_up(0, argc, argv);
ZebraHandle zh = zebra_open(zs);
+ char path[256];
zebra_select_database(zh, "Default");
zebra_init(zh);
zebra_begin_trans(zh, 1);
- zebra_repository_update(zh, "m1.xml");
- zebra_repository_update(zh, "m2.xml");
- zebra_repository_update(zh, "m3.xml");
+ sprintf(path, "%.200s/m1.xml", get_srcdir());
+ zebra_repository_update(zh, path);
+ sprintf(path, "%.200s/m2.xml", get_srcdir());
+ zebra_repository_update(zh, path);
+ sprintf(path, "%.200s/m3.xml", get_srcdir());
+ zebra_repository_update(zh, path);
zebra_end_trans(zh);
zebra_commit(zh);
- do_query(__LINE__,zh, "@and @attr 1=54 eng @and @attr 1=1003 jack @attr 1=4 computer", 2);
+ do_query(__LINE__,zh, "@and "
+ "@attr 1=54 eng "
+ "@and @attr 1=1003 jack @attr 1=4 computer", 2);
return close_down(zh, zs, 0);
}
-/* $Id: t2.c,v 1.1 2004-12-02 12:04:49 adam Exp $
+/* $Id: t2.c,v 1.2 2004-12-02 14:05:04 adam Exp $
Copyright (C) 2003,2004
Index Data Aps
{
ZebraService zs = start_up(0, argc, argv);
ZebraHandle zh = zebra_open(zs);
+ char path[256];
zebra_select_database(zh, "Default");
zebra_set_resource(zh, "recordType", "grs.marcxml.record");
zebra_begin_trans(zh, 1);
- zebra_repository_update(zh, "sample-marc");
+
+ sprintf(path, "%.200s/sample-marc", get_srcdir());
+ zebra_repository_update(zh, path);
zebra_end_trans(zh);
zebra_commit(zh);
-# $Id: Makefile.am,v 1.9 2004-12-02 12:08:39 adam Exp $
+# $Id: Makefile.am,v 1.10 2004-12-02 14:05:04 adam Exp $
-check_SCRIPTS = dummy.sh
+check_PROGRAMS = xpath1 xpath2 xpath3 xpath4 xpath5
-TESTS = $(check_SCRIPTS)
+TESTS = $(check_PROGRAMS)
+EXTRA_DIST=zebraxpath.cfg
+
+xpath1_SOURCES = xpath1.c
+xpath2_SOURCES = xpath2.c
+xpath3_SOURCES = xpath3.c
+xpath4_SOURCES = xpath4.c
+xpath5_SOURCES = xpath5.c
+
+AM_CPPFLAGS = -I$(top_srcdir)/include $(YAZINC)
+
+zebralibs = \
+ ../../index/libidzebra-api.la \
+ ../../rset/libidzebra-rset.la \
+ ../../recctrl/libidzebra-recctrl.la \
+ ../../dict/libidzebra-dict.la \
+ ../../isams/libidzebra-isams.la \
+ ../../isamc/libidzebra-isamc.la \
+ ../../isamb/libidzebra-isamb.la \
+ ../../data1/libidzebra-data1.la \
+ ../../bfile/libidzebra-bfile.la \
+ ../../dfa/libidzebra-dfa.la \
+ ../../util/libidzebra-util.la
+
+LDADD = ../api/libtestlib.a $(zebralibs) $(YAZLALIB)
+++ /dev/null
-echo "xpath tests moved away"
--- /dev/null
+/* $Id: xpath1.c,v 1.1 2004-12-02 14:05:04 adam Exp $
+ Copyright (C) 2003,2004
+ Index Data Aps
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Zebra; see the file LICENSE.zebra. If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+*/
+
+#include "../api/testlib.h"
+
+/** xpath1.c - index a simple sgml record and search in it */
+
+int main(int argc, char **argv)
+{
+ ZebraService zs;
+ ZebraHandle zh;
+ const char *myrec[] = {
+ "<sgml> \n"
+ " before \n"
+ " <tag> \n"
+ " inside \n"
+ " </tag> \n"
+ " after \n"
+ "</sgml> \n",
+ 0};
+
+ zs = start_up("zebraxpath.cfg", argc, argv);
+ zh = zebra_open(zs);
+ init_data(zh, myrec);
+
+ do_query(__LINE__,zh, "@attr 1=/sgml/tag before", 0);
+ do_query(__LINE__,zh, "@attr 1=/sgml/tag inside", 1);
+ do_query(__LINE__,zh, "@attr 1=/sgml/tag after", 0);
+
+ do_query(__LINE__,zh, "@attr 1=/sgml/none after", 0);
+ do_query(__LINE__,zh, "@attr 1=/sgml/none inside", 0);
+
+ do_query(__LINE__,zh, "@attr 1=/sgml before", 1);
+ do_query(__LINE__,zh, "@attr 1=/sgml inside", 1);
+ do_query(__LINE__,zh, "@attr 1=/sgml after", 1);
+
+ return close_down(zh, zs, 0);
+}
--- /dev/null
+/* $Id: xpath2.c,v 1.1 2004-12-02 14:05:04 adam Exp $
+ Copyright (C) 2003,2004
+ Index Data Aps
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Zebra; see the file LICENSE.zebra. If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+*/
+
+#include "../api/testlib.h"
+
+/** xpath2.c - index a a bit more complex sgml record and search in it */
+
+const char *myrec[] = {
+ "<Zthes> \n"
+ " <termId>10</termId> \n"
+ " <termName>Sauropoda</termName> \n"
+ " <termType>PT</termType> \n"
+ " <relation> \n"
+ " <relationType>BT</relationType> \n"
+ " <termId>5</termId> \n"
+ " <termName>Brontosauria</termName> \n"
+ " <termType>PT</termType> \n"
+ " </relation> \n"
+ " <relation> \n"
+ " <relationType>NT</relationType> \n"
+ " <termId>11</termId> \n"
+ " <termName>Eusauropoda</termName> \n"
+ " <termType>PT</termType> \n"
+ " </relation> \n"
+ "</Zthes> \n",
+
+ "<Zthes> \n"
+ " <termId>5</termId> \n"
+ " <termName>Brontosauria</termName> \n"
+ " <termType>PT</termType> \n"
+ " <relation> \n"
+ " <relationType>BT</relationType> \n"
+ " <termId>4</termId> \n"
+ " <termName>Sauropodomorpha</termName> \n"
+ " <termType>PT</termType> \n"
+ " </relation> \n"
+ " <relation> \n"
+ " <relationType>NT</relationType> \n"
+ " <termId>6</termId> \n"
+ " <termName>Plateosauria</termName> \n"
+ " <termType>PT</termType> \n"
+ " </relation> \n"
+ " <relation> \n"
+ " <relationType>NT</relationType> \n"
+ " <termId>10</termId> \n"
+ " <termName>Sauropoda</termName> \n"
+ " <termType>PT</termType> \n"
+ " </relation> \n"
+ "</Zthes> \n",
+ 0};
+
+
+int main(int argc, char **argv)
+{
+ ZebraService zs = start_up("zebraxpath.cfg", argc, argv);
+ ZebraHandle zh = zebra_open (zs);
+ init_data(zh, myrec);
+
+ do_query(__LINE__,zh, "@attr 1=/Zthes/termName Sauropoda", 1);
+ do_query(__LINE__,zh, "@attr 1=/Zthes/relation/termName Sauropoda",1);
+
+ return close_down(zh, zs, 0);
+}
--- /dev/null
+
+/* $Id: xpath3.c,v 1.1 2004-12-02 14:05:04 adam Exp $
+ Copyright (C) 2003,2004
+ Index Data Aps
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Zebra; see the file LICENSE.zebra. If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+*/
+
+#include "../api/testlib.h"
+
+/** xpath3.c - attributes, with Danish characters */
+
+const char *myrec[] = {
+ "<root> \n"
+ " <!-- Space in attribute --> \n"
+ " <first attr=\"danish\">content</first> \n"
+ " <second attr=\"danish lake\">content</second> \n"
+ " <!-- Oslash in Latin-1 encoded below.. --> \n"
+ " <third attr=\"dansk sø\">content<third> \n"
+ "</root> \n",
+ 0};
+
+
+int main(int argc, char **argv)
+{
+ ZebraService zs = start_up("zebraxpath.cfg", argc, argv);
+ ZebraHandle zh = zebra_open(zs);
+ init_data(zh, myrec);
+
+#define q(qry,hits) do_query(__LINE__,zh,qry,hits)
+
+ q("@attr 1=/root content",1);
+ q("@attr 1=/root/first content",1);
+ q("@attr {1=/root/first[@attr='danish']} content",1);
+ q("@attr {1=/root/second[@attr='danish lake']} content",1);
+ /*q("@attr {1=/root/third[@attr='dansk sø']} content",1); */
+ /* FIXME - This triggers bug200 */
+
+ return close_down(zh, zs, 0);
+}
--- /dev/null
+/* $Id: xpath4.c,v 1.1 2004-12-02 14:05:04 adam Exp $
+ Copyright (C) 2003,2004
+ Index Data Aps
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Zebra; see the file LICENSE.zebra. If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+*/
+
+#include "../api/testlib.h"
+
+/** xpath4.c - Attributes */
+
+const char *myrec[] = {
+ "<record> \n"
+ " <title>foo</title> \n"
+ " <title>bar</title> \n"
+ " <author>gryf</author> \n"
+ "</record> \n",
+
+ "<record> \n"
+ " <title>foo bar</title> \n"
+ " <author>gryf</author> \n"
+ "</record> \n",
+
+ "<record> \n"
+ " <title lang=en>foo gryf</title> \n"
+ " <author>grunt</author> \n"
+ "</record> \n",
+
+ "<record> \n"
+ " <title lang=da>foo grunt</title> \n"
+ " <value>bar</value> \n"
+ "</record> \n",
+
+ "<record> \n"
+ " <title lang=en>double english</title> \n"
+ " <title lang=da>double danish</title> \n"
+ " <author>grunt</author> \n"
+ "</record> \n",
+
+ "<record> \n"
+ " <title>hamlet</title> \n"
+ " <author>foo bar grunt grunt grunt</author> \n"
+ "</record> \n",
+
+ "<record> \n"
+ " before \n"
+ " <nested> \n"
+ " early \n"
+ " <nested> \n"
+ " middle \n"
+ " </nested> \n"
+ " late \n"
+ " </nested> \n"
+ " after \n"
+ "</record> \n",
+
+ "<record> \n"
+ " before \n"
+ " <nestattr level=outer> \n"
+ " early \n"
+ " <nestattr level=inner> \n"
+ " middle \n"
+ " </nestattr> \n"
+ " late \n"
+ " </nestattr> \n"
+ " after \n"
+ "</record> \n",
+ 0};
+
+
+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)
+
+ q("@attr 1=/record/title foo",4);
+ 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 previous one returns two hits, as the and applies to the whole
+ record, so it matches <title>foo</title><title>bar</title>
+ 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);
+}
--- /dev/null
+/* $Id: xpath5.c,v 1.1 2004-12-02 14:05:04 adam Exp $
+ Copyright (C) 2003,2004
+ Index Data Aps
+
+This file is part of the Zebra server.
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Zebra; see the file LICENSE.zebra. If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+*/
+
+#include "../api/testlib.h"
+
+/** xpath4.c - Ranking in xpath */
+
+const char *recs[] = {
+ "<record>\n"
+ " <title>The first title</title>\n"
+ " <abstract> \n"
+ " The first common word is the: the the the \n"
+ " The second common word is word \n"
+ " but all have the foo bar \n"
+ " </abstract>\n"
+ "</record>\n",
+
+ "<record>\n"
+ " <title>The second title</title>\n"
+ " <abstract> \n"
+ " The first common word is the: the \n"
+ " The second common word is foo: foo foo \n"
+ " but all have the foo bar \n"
+ " </abstract>\n"
+ "</record>\n",
+
+ "<record>\n"
+ " <title>The third title</title>\n"
+ " <abstract> \n"
+ " The first common word is the: the \n"
+ " The third common word is bar: bar \n"
+ " but all have the foo bar \n"
+ " </abstract>\n"
+ "</record>\n",
+
+ 0 };
+
+
+int main(int argc, char **argv)
+{
+ ZebraService zs = start_up("zebraxpath.cfg", argc, argv);
+ ZebraHandle zh = zebra_open(zs);
+ init_data(zh, recs);
+
+// yaz_log_init_level(LOG_ALL);
+
+#define q(qry,hits,string,score) \
+ ranking_query(__LINE__,zh,qry,hits,string,score)
+
+ q("@attr 1=/record/title @attr 2=102 the",
+ 3,"first title",952);
+ q("@attr 1=/ @attr 2=102 @or third foo",
+ 3,"third title",802);
+
+ q("@attr 1=/ @attr 2=102 foo",
+ 3,"second title",850);
+
+ q("@attr 1=/record/ @attr 2=102 foo",
+ 3,"second title",927);
+
+ return close_down(zh, zs, 0);
+}
--- /dev/null
+# $Id: zebraxpath.cfg,v 1.1 2004-12-02 14:05:04 adam Exp $
+profilePath: ${srcdir:-.}/../../tab
+recordType: grs.sgml
+attset: bib1.att
+
+isam:b
+
+
+
+