X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=test%2Fxslt%2Fdom1.c;h=095aa64c3b4c41be17b424fb1e3426486e2b49df;hp=efa7edc7d06eeacd88f7a38d3f73ed04184ce4d1;hb=a030c87bc444608639905eca95e29f84a4f1d991;hpb=97dc097858772a66c8e90e8b07f77c9c20450131 diff --git a/test/xslt/dom1.c b/test/xslt/dom1.c index efa7edc..095aa64 100644 --- a/test/xslt/dom1.c +++ b/test/xslt/dom1.c @@ -1,8 +1,5 @@ -/* $Id: dom1.c,v 1.1 2007-02-07 12:08:54 adam Exp $ - Copyright (C) 1995-2007 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) 1994-2011 Index Data 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 @@ -23,20 +20,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include "testlib.h" -ZebraHandle index_some(ZebraService zs, - const char *filter, const char *file) + +void index_more(ZebraHandle zh, const char *filter, const char *file) { char path[256]; char profile_path[256]; - ZebraHandle zh = zebra_open(zs, 0); - - tl_check_filter(zs, "dom"); - - YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); - - zebra_init(zh); - sprintf(profile_path, "%.80s:%.80s/../../tab", tl_get_srcdir(), tl_get_srcdir()); zebra_set_resource(zh, "profilePath", profile_path); @@ -49,6 +38,20 @@ ZebraHandle index_some(ZebraService zs, YAZ_CHECK(zebra_repository_update(zh, path) == ZEBRA_OK); YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); zebra_commit(zh); +} + +ZebraHandle index_some(ZebraService zs, + const char *filter, const char *file) +{ + ZebraHandle zh = zebra_open(zs, 0); + + tl_check_filter(zs, "dom"); + + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); + + zebra_init(zh); + + index_more(zh, filter, file); return zh; } @@ -60,14 +63,38 @@ void tst(int argc, char **argv) zh = index_some(zs, "dom.bad.xml", "marc-col.xml"); zebra_close(zh); - + + + /* testing XMLREADER input with PI stylesheet */ zh = index_some(zs, "dom.dom-config-col.xml", "marc-col.xml"); YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 3)); + + /* fetch first using dom-brief.xsl */ + YAZ_CHECK_EQ(tl_fetch_first_compare( + zh, "B", yaz_oid_recsyn_xml, + "\n" + "How to program a computer\n"), + ZEBRA_OK); + /* fetch first using dom-snippets.xsl */ + YAZ_CHECK_EQ(tl_fetch_first_compare( + zh, "snippet", yaz_oid_recsyn_xml, + "\n" + "\n" + " \n" + " How to program a computer\n" + "\n" + " How to program a computer\n" + "\n"), + ZEBRA_OK); + YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=titl computer", 0, 114)); YAZ_CHECK(tl_query_x(zh, "@attr 1=4 computer", 0, 121)); zebra_close(zh); + + /* testing XMLREADER input with ELEMENT stylesheet */ zh = index_some(zs, "dom.dom-config-one.xml", "marc-one.xml"); YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 1)); YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); @@ -75,6 +102,7 @@ void tst(int argc, char **argv) YAZ_CHECK(tl_query_x(zh, "@attr 1=4 computer", 0, 121)); zebra_close(zh); + /* testing MARC input with ELEMENT stylesheet */ zh = index_some(zs, "dom.dom-config-marc.xml", "marc-col.mrc"); YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 3)); YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 1)); @@ -82,6 +110,39 @@ void tst(int argc, char **argv) YAZ_CHECK(tl_query_x(zh, "@attr 1=4 computer", 0, 121)); zebra_close(zh); + /* testing XMLREADER input with ELEMENT stylesheet and skipped records */ + zh = index_some(zs, "dom.dom-config-skipped.xml", "marc-col.xml"); + YAZ_CHECK(tl_query(zh, "@attr 1=title computer", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=control 11224466", 0)); + YAZ_CHECK(tl_query(zh, "@attr 1=control 11224467", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=control 73090924", 0)); + + /* testing XMLREADER input with type attributes (insert,delete,..) */ + zh = index_some(zs, "dom.dom-config-del.xml", "del-col.xml"); + YAZ_CHECK(tl_query(zh, "@attr 1=title a", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=title 1", 0)); + YAZ_CHECK(tl_query(zh, "@attr 1=title 2", 0)); + YAZ_CHECK(tl_query(zh, "@attr 1=title 3", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=title b", 1)); + + zh = index_some(zs, "dom.gutenberg.xml", "gutenberg-sample.xml"); + YAZ_CHECK(tl_query(zh, "oscar", 1)); + + YAZ_CHECK_EQ(tl_fetch_first_compare( + zh, "zebra::snippet", yaz_oid_recsyn_xml, + "\n" + " " + "Selected Prose of Oscar Wilde" + "\n" + " " + "Wilde, Oscar, 1854-1900" + "\n" + ""), + ZEBRA_OK); + + zebra_close(zh); + + YAZ_CHECK(tl_close_down(0, zs)); } @@ -90,6 +151,7 @@ TL_MAIN /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab