SRW, CQL, 2003
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 6 Jan 2003 08:20:26 +0000 (08:20 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 6 Jan 2003 08:20:26 +0000 (08:20 +0000)
124 files changed:
CHANGELOG
LICENSE
Makefile.am
README
client/admin.c
client/admin.h
client/client.c
client/tabcomplete.c
comstack/tcpip.c
comstack/unix.c
configure.in
cql/.cvsignore [new file with mode: 0644]
cql/Makefile.am [new file with mode: 0644]
cql/cql.y [new file with mode: 0644]
cql/cql2pqf.c [new file with mode: 0644]
cql/cql2xcql.c [new file with mode: 0644]
cql/cqlstdio.c [new file with mode: 0644]
cql/cqlstring.c [new file with mode: 0644]
cql/cqltransform.c [new file with mode: 0644]
cql/cqlutil.c [new file with mode: 0644]
cql/lexer.c [new file with mode: 0644]
cql/xcqlutil.c [new file with mode: 0644]
debian/rules
etc/MARC21slim2DC.xsl [new file with mode: 0644]
etc/MARC21slim2MODS.xsl [new file with mode: 0644]
etc/MARC21slim2RDFDC.xsl [new file with mode: 0644]
etc/MARC21slimUtils.xsl [new file with mode: 0644]
etc/Makefile.am [new file with mode: 0644]
etc/maps.xml [new file with mode: 0644]
etc/pqf.properties [new file with mode: 0644]
include/yaz/Makefile.am
include/yaz/backend.h
include/yaz/cql.h [new file with mode: 0644]
include/yaz/log.h
include/yaz/logrpn.h
include/yaz/marcdisp.h
include/yaz/nmem.h
include/yaz/odr.h
include/yaz/oid.h
include/yaz/pquery.h
include/yaz/proto.h
include/yaz/prt-ext.h
include/yaz/srw-util.h [new file with mode: 0644]
include/yaz/tpath.h
include/yaz/unix.h
include/yaz/wrbuf.h
include/yaz/yaz-iconv.h
include/yaz/yaz-util.h
include/yaz/zoom.h
lib/Makefile.am
odr/ber_any.c
odr/ber_bit.c
odr/ber_bool.c
odr/ber_int.c
odr/ber_len.c
odr/ber_null.c
odr/ber_oct.c
odr/ber_oid.c
odr/ber_tag.c
odr/dumpber.c
odr/odr-priv.h
odr/odr.c
odr/odr_any.c
odr/odr_bit.c
odr/odr_bool.c
odr/odr_choice.c
odr/odr_cons.c
odr/odr_enum.c
odr/odr_int.c
odr/odr_mem.c
odr/odr_null.c
odr/odr_oct.c
odr/odr_oid.c
odr/odr_seq.c
odr/odr_tag.c
odr/odr_use.c
odr/odr_util.c
server/seshigh.c
server/session.h
server/statserv.c
srw/.cvsignore [new file with mode: 0644]
srw/Makefile.am [new file with mode: 0644]
srw/srw-diag.c [new file with mode: 0644]
srw/srw-namespace.c [new file with mode: 0644]
srw/srw-server.c [new file with mode: 0644]
srw/srw-xcql.c [new file with mode: 0644]
srw/srw-xslt.c [new file with mode: 0644]
srw/zing.h [new file with mode: 0644]
srwapps/.cvsignore [new file with mode: 0644]
srwapps/Makefile.am [new file with mode: 0644]
srwapps/srw-client.c [new file with mode: 0644]
srwapps/srw-gateway.c [new file with mode: 0644]
util/Makefile.am
util/atoin.c
util/log.c
util/marcdisp.c
util/marcdump.c
util/nmem.c
util/oid.c
util/siconv.c
util/siconvtst.c
util/tpath.c
util/wrbuf.c
util/xmalloc.c
win/LICENSE.txt
win/yaz.rc
yaz-config.in
z39.50/prt-ext.c
z39.50/z3950v3.asn
zoom/Makefile.am
zoom/zoomsh.c
ztest/read-grs.c
ztest/ztest.c
zutil/Makefile.am
zutil/diagbib1.c
zutil/logrpn.c
zutil/otherinfo.c
zutil/pquery.c
zutil/yaz-ccl.c
zutil/z3950oid.c
zutil/zget.c
zutil/zoom-c.c
zutil/zoom-opt.c
zutil/zoom-p.h

index 917ac97..0bbd392 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,20 @@
 Possible compatibility problems with earlier versions marked with '*'.
 
---- 1.9.3 2002/MM/DD
+--- 1.9.3 2003/MM/DD
+
+Support for SRW 1.0. This is an optional feature and requires
+gSOAP to operate. Enable it by specifying --with-gsoap for
+configure. SRW stuff is located in sub directory srw.
+Example applications are located in srwapps. 
+
+Z39.50 Query Type-104 added - to facilitate CQL within Z39.50.
+
+CQL support. Source is directory 'cql'. CQL is supported in ZOOM
+(both SRW and Z39.50) and the YAZ client (Z39.50 only).
+
+ZOOM connections are SRW based if host/port is specified
+as http. e.g.  z = ZOOM_connection_new("http://myserver");
+ZOOM_query may be of type CQL, e.g. ZOOM_query_cql(q, "dc.title=x");
 
 CCL proximity operators !n, %n converts to PQF @prox 0 n 1 2 k 2
 and @prox 0 n 0 1 k 2 respectively, meaning: exlusion=false,
diff --git a/LICENSE b/LICENSE
index 6235cb1..db81ecc 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995-2002, Index Data.
+ * Copyright (c) 1995-2003, Index Data.
  *
  * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation, in whole or in part, for any purpose, is hereby granted,
index 260c395..4c1ea35 100644 (file)
@@ -1,8 +1,10 @@
-## $Id: Makefile.am,v 1.17 2002-10-22 12:51:18 adam Exp $
+## Copyright (C) 1994-2003, Index Data
+## All rights reserved.
+## $Id: Makefile.am,v 1.18 2003-01-06 08:20:26 adam Exp $
 
 AUTOMAKE_OPTIONS = foreign 
 
-SUBDIRS = util odr comstack z39.50 ill zutil ccl server include lib client ztest zoom doc
+SUBDIRS = util odr comstack z39.50 ill srw zutil ccl cql server include lib client ztest zoom srwapps doc etc
 
 aclocaldir=$(datadir)/aclocal
 
diff --git a/README b/README
index bc2f56b..889f14a 100644 (file)
--- a/README
+++ b/README
@@ -1,11 +1,11 @@
-YAZ toolkit - $Id: README,v 1.41 2002-08-27 13:30:18 adam Exp $
+YAZ toolkit - $Id: README,v 1.42 2003-01-06 08:20:26 adam Exp $
 
-Copyright (C) 1995-2002, Index Data ApS.
+Copyright (C) 1995-2003, Index Data ApS.
 See the file LICENSE for details.
 
 The primary output of the source here is the YAZ library, which
 contains support functions for implementing the server or client
-role of Z39.50.
+role of Z39.50 and SRW.
 
 Windows programmers: refer to the file windows.txt which describes how
 to build the software using Microsoft Visual C++.
@@ -52,11 +52,19 @@ zoom     An implementation of Mike Taylors Z39.50 Object Oriented
          in C this may be good start. You'll find example programs in 
          this directory too.
 
-server   This is the implementation of the server frontend. It
+server   This is the implementation of the Z39.50 server frontend. It
         provides event-handling and server managament functions,
         and calls the backend primitives (best documentation of these
         is in the file include/yaz/backend.h).
 
+ccl      CCL parser.
+
+cql      CQL parser.
+
+srw      SRW support (based on gSOAP).
+
+srwapps  SRW applicaions, most notably a SRW-to-Z39.50 gateway.
+
 client   A demonstration client for testing the protocol. It's bug'n
          ugly. But, it supports many features.
 
index b94e968..4f96bce 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (c) 1995-2002, Index Data
+ * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: admin.c,v 1.14 2002-09-24 08:05:41 adam Exp $
+ * $Id: admin.c,v 1.15 2003-01-06 08:20:26 adam Exp $
  */
 
 #include <stdio.h>
index efa8483..f2d49fb 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (c) 1995-2002, Index Data
+ * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: admin.h,v 1.4 2002-09-17 11:07:30 adam Exp $
+ * $Id: admin.h,v 1.5 2003-01-06 08:20:26 adam Exp $
  */
 
 int cmd_adm_reindex(char* arg);
index 3db21cf..639feca 100644 (file)
@@ -1,8 +1,8 @@
 /* 
- * Copyright (c) 1995-2002, Index Data
+ * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: client.c,v 1.177 2002-12-16 13:30:41 adam Exp $
+ * $Id: client.c,v 1.178 2003-01-06 08:20:26 adam Exp $
  */
 
 #include <stdio.h>
@@ -97,7 +97,8 @@ static int auto_reconnect = 0;
 typedef enum {
     QueryType_Prefix,
     QueryType_CCL,
-    QueryType_CCL2RPN
+    QueryType_CCL2RPN,
+    QueryType_CQL
 } QueryType;
 
 static QueryType queryType = QueryType_Prefix;
@@ -144,6 +145,7 @@ const char* query_type_as_string(QueryType q)
     case QueryType_Prefix: return "prefix (RPN sent to server)";
     case QueryType_CCL: return "CCL (CCL sent to server) ";
     case QueryType_CCL2RPN: return "CCL -> RPN (RPN sent to server)";
+    case QueryType_CQL: return "CQL (CQL sent to server)";
     default: 
         return "unknown Query type internal yaz-client error";
     }
@@ -875,6 +877,7 @@ static int send_searchRequest(char *arg)
     Z_RPNQuery *RPNquery;
     Odr_oct ccl_query;
     YAZ_PQF_Parser pqf_parser;
+    Z_External *ext;
 
     if (queryType == QueryType_CCL2RPN)
     {
@@ -961,6 +964,16 @@ static int send_searchRequest(char *arg)
         query.u.type_1 = RPNquery;
         ccl_rpn_delete (rpn);
         break;
+    case QueryType_CQL:
+        query.which = Z_Query_type_104;
+        ext = odr_malloc(out, sizeof(*ext));
+        ext->direct_reference = odr_getoidbystr(out, "1.2.840.10003.16.2");
+        ext->indirect_reference = 0;
+        ext->descriptor = 0;
+        ext->which = Z_External_CQL;
+        ext->u.cql = odr_strdup(out, arg);
+        query.u.type_104 =  ext;
+        break;
     default:
         printf ("Unsupported query type\n");
         return 0;
@@ -2225,12 +2238,15 @@ int cmd_querytype (char *arg)
         queryType = QueryType_Prefix;
     else if (!strcmp (arg, "ccl2rpn") || !strcmp (arg, "cclrpn"))
         queryType = QueryType_CCL2RPN;
+    else if (!strcmp(arg, "cql"))
+        queryType = QueryType_CQL;        
     else
     {
         printf ("Querytype must be one of:\n");
         printf (" prefix         - Prefix query\n");
         printf (" ccl            - CCL query\n");
         printf (" ccl2rpn        - CCL query converted to RPN\n");
+        printf (" cql            - CQL\n");
         return 0;
     }
     return 1;
index ad48f3b..c1eeba4 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 2002, Index Data
  * See the file LICENSE for details.
  *
- * $Id: tabcomplete.c,v 1.8 2002-09-24 08:05:41 adam Exp $
+ * $Id: tabcomplete.c,v 1.9 2003-01-06 08:20:26 adam Exp $
  */
 
 #include <string.h>
 
 extern char** curret_global_list;
 
-/* *****************************************************************************
+/* ***************************************************************************
  *
- * generic compleater 
+ * generic completer 
  * 
- * *****************************************************************************/
+ * ***************************************************************************/
 
 char* complete_from_list(char* completions[], const char *text, int state)
 {      
@@ -44,11 +44,11 @@ char* complete_from_list(char* completions[], const char *text, int state)
 }
 
 
-/* *****************************************************************************
+/* ***************************************************************************
  * 
  * code for getting a list of valid strings from the oid subsystem
  * 
- * *****************************************************************************/
+ * ***************************************************************************/
    
 
 typedef struct {
@@ -59,8 +59,8 @@ typedef struct {
 } oid_callback_t;
 
 /*!
-  This is the call back function given to oid_trav... it updates the list of pointers into the oid
-  owned data 
+  This is the call back function given to oid_trav... it updates the list
+  of pointers into the oid owned data 
 */
 
 void oid_loader(struct oident* oid, void* data_)
@@ -91,15 +91,15 @@ char** build_list_for_oclass(oid_class oclass) {
        return data.values;        
 }
 
-/* *****************************************************************************
+/* ***************************************************************************
  * 
- * the compleater functions 
+ * the completer functions 
  * 
- * *****************************************************************************/
+ * ***************************************************************************/
 
 char* complete_querytype(const char *text, int state)
 {
-    char* querytypes[] = {"ccl2rpn","prefix","cclrpn","ccl",0};
+    char* querytypes[] = {"ccl2rpn","prefix","cclrpn","ccl","cql", 0};
     return complete_from_list(querytypes,text,state);  
 }
 
index 9e0e0cf..8649a3f 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (c) 1995-2002, Index Data
+ * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: tcpip.c,v 1.52 2002-12-19 14:04:22 adam Exp $
+ * $Id: tcpip.c,v 1.53 2003-01-06 08:20:27 adam Exp $
  */
 
 #include <stdio.h>
index 235c9b1..908ab7e 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (c) 1995-2002, Index Data
+ * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: unix.c,v 1.8 2002-12-15 21:22:58 adam Exp $
+ * $Id: unix.c,v 1.9 2003-01-06 08:20:27 adam Exp $
  * UNIX socket COMSTACK. By Morten B√łgeskov.
  */
 #ifndef WIN32
index 41cf8d1..50fcf89 100644 (file)
@@ -1,6 +1,6 @@
-dnl YAZ Toolkit, Index Data 1994-2002
+dnl YAZ Toolkit, Index Data 1994-2003
 dnl See the file LICENSE for details.
-dnl $Id: configure.in,v 1.99 2002-12-16 13:13:53 adam Exp $
+dnl $Id: configure.in,v 1.100 2003-01-06 08:20:26 adam Exp $
 AC_INIT(include/yaz/yaz-version.h)
 AM_INIT_AUTOMAKE(yaz, 1.9.2)
 dnl
@@ -9,6 +9,8 @@ AC_SUBST(YAZ_CONF_CFLAGS)
 dnl ------ Checking programs
 AC_PROG_CC
 AC_PROG_CPP
+AC_CHECK_PROGS(YACC, 'bison -y')
+test -z "$YACC" && AC_MSG_WARN([GNU bison not found])
 AC_PROG_INSTALL
 AM_DISABLE_SHARED
 AM_PROG_LIBTOOL
@@ -173,7 +175,7 @@ if test "$with_iconv" != "no"; then
        ])
 fi
 dnl ------ various functions
-AC_CHECK_FUNCS(vsnprintf gettimeofday poll)
+AC_CHECK_FUNCS(vsnprintf gettimeofday poll strerror_r)
 if test "$ac_cv_func_poll" = "yes"; then
         AC_CHECK_HEADERS(sys/poll.h)
 fi
@@ -306,6 +308,58 @@ if test "$enable_threads" = "yes" -a "$HAVETHREADS" = "0"; then
 fi
 AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
 dnl
+dnl ----- gSOAP
+AC_SUBST(GSOAP_LIB)
+AC_SUBST(GSOAP_INCLUDE)
+AC_SUBST(GSOAP_PREFIX)
+gsoapdir=NONE
+AC_ARG_WITH(gsoap, [  --with-gsoap[=PREFIX]   Use gSOAP in PREFIX/{lib,include}],[gsoapdir=$withval])
+if test "x$gsoapdir" = "xNONE"; then
+       for d in /usr /usr/local; do
+               if test -f $d/include/stdsoap2.h; then
+                       gsoapdir=$d
+               fi
+       done
+fi
+AC_MSG_CHECKING(for gSOAP prefix)
+GSOAP_PREFIX=$gsoapdir
+if test -x $gsoapdir/bin/soapcpp2; then
+       AC_MSG_RESULT($gsoapdir)
+       if test "$gsoapdir" != "/usr"; then
+               GSOAP_LIB="-L$gsoapdir/lib -lgsoap"
+               GSOAP_INCLUDE=-I$gsoapdir/include
+       fi
+        AC_DEFINE(HAVE_GSOAP)
+        usesrw=1
+else
+       AC_MSG_RESULT(Not found)
+        usesrw=0
+fi
+AM_CONDITIONAL(SRW, test $usesrw = "1")
+dnl
+dnl ----- XML/XSLT
+AC_SUBST(XSLT_LIB)
+AC_SUBST(XSLT_CFLAGS)
+xsltdir=NONE
+AC_ARG_WITH(xslt, [  --with-xslt[=PREFIX]    Use libxslt in PREFIX/{lib,include}],[xsltdir=$withval])
+if test "x$xsltdir" = "xNONE"; then
+       for d in /usr /usr/local; do
+               if test -x $d/bin/xslt-config; then
+                       xsltdir=$d
+               fi
+       done
+fi
+AC_MSG_CHECKING(for XSLT)
+if test -x $xsltdir/bin/xslt-config; then
+       XSLT_LIB=`$xsltdir/bin/xslt-config --libs`
+       XSLT_CFLAGS=`$xsltdir/bin/xslt-config --cflags`
+       XSLT_VER=`$xsltdir/bin/xslt-config --version`
+       AC_MSG_RESULT($XSLT_VER)
+       AC_DEFINE(HAVE_XSLT)
+else
+       AC_MSG_RESULT(Not found)
+fi
+dnl
 dnl ------ Memory debugging
 AC_ARG_ENABLE(memdebug, [  --enable-memdebug       enable memory debugging],[enable_memdebug=$enableval],[enable_memdebug=none])
 if test "$enable_memdebug" = "yes"; then
@@ -328,13 +382,16 @@ yaz.spec
 util/Makefile
 odr/Makefile
 z39.50/Makefile
+srw/Makefile
 ill/Makefile
 zutil/Makefile
 comstack/Makefile
 ccl/Makefile
+cql/Makefile
 server/Makefile
 include/Makefile
 include/yaz/Makefile
+srwapps/Makefile
 lib/Makefile
 client/Makefile
 ztest/Makefile
@@ -345,5 +402,6 @@ doc/yazhtml.dsl
 doc/yazphp.dsl
 doc/yazprint.dsl
 doc/tkl.xsl
+etc/Makefile
 yaz-config
 ],[sed s%yaz_echo_source=yes%yaz_echo_source=no%g < yaz-config > lib/yaz-config && chmod +x yaz-config lib/yaz-config])
diff --git a/cql/.cvsignore b/cql/.cvsignore
new file mode 100644 (file)
index 0000000..f995e38
--- /dev/null
@@ -0,0 +1,7 @@
+.deps
+.libs
+Makefile
+Makefile.in
+*.lo
+*.la
+cql.c
diff --git a/cql/Makefile.am b/cql/Makefile.am
new file mode 100644 (file)
index 0000000..c0c875e
--- /dev/null
@@ -0,0 +1,17 @@
+# $Id: Makefile.am,v 1.1 2003-01-06 08:20:27 adam Exp $
+AM_YFLAGS=-p cql_
+
+AM_CPPFLAGS=-I$(top_srcdir)/include
+
+noinst_LTLIBRARIES = libcql.la
+noinst_PROGRAMS = cql2pqf cql2xcql
+
+EXTRA_DIST=lexer.c
+
+libcql_la_SOURCES=cql.y cqlstdio.c cqltransform.c \
+ cqlutil.c xcqlutil.c cqlstring.c cql.h
+
+cql2pqf_SOURCES = cql2pqf.c
+cql2xcql_SOURCES = cql2xcql.c
+
+LDADD=libcql.la 
diff --git a/cql/cql.y b/cql/cql.y
new file mode 100644 (file)
index 0000000..4a816aa
--- /dev/null
+++ b/cql/cql.y
@@ -0,0 +1,267 @@
+/* $Id: cql.y,v 1.1 2003-01-06 08:20:27 adam Exp $
+   Copyright (C) 2002-2003
+   Index Data Aps
+
+This file is part of the YAZ toolkit.
+
+See the file LICENSE.
+
+ bison parser for CQL grammar.
+*/
+%{
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <yaz/cql.h>
+    
+    typedef struct {
+        struct cql_node *rel;
+        struct cql_node *cql;
+        char buf[80];
+        size_t len;
+        size_t max;
+    } token;        
+
+    struct cql_parser {
+        int (*getbyte)(void *client_data);
+        void (*ungetbyte)(int b, void *client_data);
+        void *client_data;
+        int last_error;
+        int last_pos;
+        struct cql_node *top;
+    };
+
+#define YYSTYPE token
+    
+#define YYPARSE_PARAM parm
+#define YYLEX_PARAM parm
+    
+    int yylex(YYSTYPE *lval, void *vp);
+    int yyerror(char *s);
+%}
+
+%pure_parser
+%token TERM AND OR NOT PROX EXACT ALL ANY GE LE NE SCR
+%expect 8
+
+%%
+
+top: { 
+    $$.rel = cql_node_mk_sc("srw.serverChoice", "scr", 0);
+    ((CQL_parser) parm)->top = 0;
+} cqlQuery1 {
+    cql_node_destroy($$.rel);
+    ((CQL_parser) parm)->top = $2.cql; 
+}
+;
+
+cqlQuery1: cqlQuery
+| cqlQuery error {
+    cql_node_destroy($1.cql);
+    $$.cql = 0;
+}
+;
+
+cqlQuery: 
+  searchClause
+|
+  cqlQuery boolean { 
+      $$.rel = $0.rel; 
+  } searchClause {
+      struct cql_node *cn = cql_node_mk_boolean($2.buf);
+      
+      cn->u.bool.modifiers = $2.rel;
+      cn->u.bool.left = $1.cql;
+      cn->u.bool.right = $4.cql;
+
+      $$.cql = cn;
+  }
+;
+
+searchClause: 
+  '(' { 
+      $$.rel = $0.rel;
+      
+  } cqlQuery ')' {
+      $$.cql = $3.cql;
+  }
+|
+  searchTerm {
+      struct cql_node *st = cql_node_dup ($0.rel);
+      st->u.st.term = strdup($1.buf);
+      $$.cql = st;
+  }
+| 
+  index relation {
+      $$.rel = $2.rel;
+      $$.rel->u.st.index = strdup($1.buf);
+  } searchClause {
+      $$.cql = $4.cql;
+      cql_node_destroy($$.rel);
+  }
+| '>' searchTerm '=' searchTerm {
+      $$.rel = $0.rel;
+  } cqlQuery {
+    $$.cql = cql_node_prefix($6.cql, $2.buf, $4.buf);
+  }
+| '>' searchTerm {
+      $$.rel = $0.rel;
+  } cqlQuery {
+    $$.cql = cql_node_prefix($4.cql, 0, $2.buf);
+   }
+;
+
+boolean: 
+  AND | OR | NOT | PROX proxqualifiers {
+      $$ = $1;
+      $$.rel = $2.rel;
+  }
+  ;
+
+proxqualifiers: 
+  Prelation { 
+      $$.rel = cql_node_mk_proxargs ($1.buf, 0, 0, 0);
+  }
+|
+  PrelationO Pdistance {
+      $$.rel = cql_node_mk_proxargs ($1.buf, $2.buf, 0, 0);
+  }
+|
+  PrelationO PdistanceO Punit {
+      $$.rel = cql_node_mk_proxargs ($1.buf, $2.buf, $3.buf, 0);
+  }
+|
+  PrelationO PdistanceO PunitO Pordering {
+      $$.rel = cql_node_mk_proxargs ($1.buf, $2.buf, $3.buf, $4.buf);
+  }
+|
+{ $$.rel = 0; }
+;
+
+Punit: '/' searchTerm { 
+      $$ = $2;
+   }
+;
+
+PunitO: '/' searchTerm {
+      $$ = $2;
+   } 
+| 
+'/' { $$.buf[0] = 0; }
+;
+Prelation: '/' baseRelation {
+    $$ = $2;
+}
+;
+PrelationO: '/' baseRelation {
+    $$ = $2;
+}
+| '/' { $$.buf[0] = 0; }
+;
+Pdistance: '/' searchTerm { 
+    $$ = $2;
+}
+;
+
+PdistanceO: '/' searchTerm {
+    $$ = $2;
+}
+| '/' { $$.buf[0] = 0; }
+;
+Pordering: '/' searchTerm { 
+    $$ = $2;
+}
+;
+
+relation: baseRelation modifiers {
+    struct cql_node *st = cql_node_mk_sc(/* index */ 0, 
+                                         /* relation */ $1.buf, 
+                                         /* term */ 0);
+
+    st->u.st.modifiers = $2.cql;
+    $$.rel = st;
+}
+;
+
+modifiers: '/' searchTerm modifiers
+{ 
+    struct cql_node *mod = cql_node_mk_mod(0, $2.buf);
+
+    mod->u.mod.next = $3.cql;
+    $$.cql = mod;
+}
+|  
+{ 
+    $$.cql = 0;
+}
+;
+
+baseRelation: 
+  '=' 
+| '>' 
+| '<'
+| GE
+| LE
+| NE
+| EXACT 
+| ALL
+| ANY
+| SCR
+;
+
+index: 
+  searchTerm;
+
+searchTerm:
+  TERM
+| AND
+| OR
+| NOT
+| EXACT
+| ALL
+| ANY
+| PROX
+;
+
+%%
+
+int yyerror(char *s)
+{
+    return 0;
+}
+
+#include "lexer.c"
+
+
+int cql_parser_stream(CQL_parser cp,
+                      int (*getbyte)(void *client_data),
+                      void (*ungetbyte)(int b, void *client_data),
+                      void *client_data)
+{
+    cp->getbyte = getbyte;
+    cp->ungetbyte = ungetbyte;
+    cp->client_data = client_data;
+    cql_parse(cp);
+    if (cp->top)
+        return 0;
+    return -1;
+}
+
+CQL_parser cql_parser_create(void)
+{
+    CQL_parser cp = malloc (sizeof(*cp));
+
+    return cp;
+}
+
+void cql_parser_destroy(CQL_parser cp)
+{
+    cql_node_destroy(cp->top);
+    free (cp);
+}
+
+struct cql_node *cql_parser_result(CQL_parser cp)
+{
+    return cp->top;
+}
diff --git a/cql/cql2pqf.c b/cql/cql2pqf.c
new file mode 100644 (file)
index 0000000..e5a3731
--- /dev/null
@@ -0,0 +1,52 @@
+/* $Id: cql2pqf.c,v 1.1 2003-01-06 08:20:27 adam Exp $
+   Copyright (C) 2002-2003
+   Index Data Aps
+
+This file is part of the YAZ toolkit.
+
+See the file LICENSE.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <yaz/cql.h>
+
+int main(int argc, char **argv)
+{
+    cql_transform_t ct;
+    int r;
+    CQL_parser cp = cql_parser_create();
+
+    if (argc < 2)
+    {
+        fprintf (stderr, "usage\n cqltransform <properties> [<query>]\n");
+        exit (1);
+    }
+    ct = cql_transform_open_fname(argv[1]);
+    if (!ct)
+    {
+        fprintf (stderr, "failed to read properties %s\n", argv[1]);
+        exit (1);
+    }
+    if (argc == 3)
+        r = cql_parser_string(cp, argv[2]);
+    else
+        r = cql_parser_stdio(cp, stdin);
+    if (r)
+        fprintf (stderr, "Syntax error\n");
+    else
+    {
+        r = cql_transform_FILE(ct, cql_parser_result(cp), stdout);
+       printf("\n");
+        if (r)
+        {
+            const char *addinfo;
+            cql_transform_error(ct, &addinfo);
+            printf ("Transform error %d %s\n", r, addinfo ? addinfo : "");
+        }
+    }
+    cql_transform_close(ct);
+    cql_parser_destroy(cp);
+    return 0;
+}
diff --git a/cql/cql2xcql.c b/cql/cql2xcql.c
new file mode 100644 (file)
index 0000000..b2db2e5
--- /dev/null
@@ -0,0 +1,28 @@
+/* $Id: cql2xcql.c,v 1.1 2003-01-06 08:20:27 adam Exp $
+   Copyright (C) 2002-2003
+   Index Data Aps
+
+This file is part of the YAZ toolkit.
+
+See the file LICENSE.
+*/
+
+#include <stdio.h>
+
+#include <yaz/cql.h>
+
+int main(int argc, char **argv)
+{
+    int r;
+    CQL_parser cp = cql_parser_create();
+    if (argc == 2)
+        r = cql_parser_string(cp, argv[1]);
+    else
+        r = cql_parser_stdio(cp, stdin);
+    if (r)
+        fprintf (stderr, "Syntax error\n");
+    else
+        cql_to_xml_stdio(cql_parser_result(cp), stdout);
+    cql_parser_destroy(cp);
+    return 0;
+}
diff --git a/cql/cqlstdio.c b/cql/cqlstdio.c
new file mode 100644 (file)
index 0000000..7846f0d
--- /dev/null
@@ -0,0 +1,36 @@
+/* $Id: cqlstdio.c,v 1.1 2003-01-06 08:20:27 adam Exp $
+   Copyright (C) 2002-2003
+   Index Data Aps
+
+This file is part of the YAZ toolkit.
+
+See the file LICENSE.
+*/
+
+#include <yaz/cql.h>
+
+int getbyte_stream(void *client_data)
+{
+    FILE *f = (FILE*) client_data;
+
+    int c = fgetc(f);
+    if (c == EOF)
+        return 0;
+    return c;
+}
+
+void ungetbyte_stream (int c, void *client_data)
+{
+    FILE *f = (FILE*) client_data;
+
+    if (c == 0)
+        c = EOF;
+    ungetc(c, f);
+}
+
+int cql_parser_stdio(CQL_parser cp, FILE *f)
+{
+    return cql_parser_stream(cp, getbyte_stream, ungetbyte_stream, f);
+}
+
+
diff --git a/cql/cqlstring.c b/cql/cqlstring.c
new file mode 100644 (file)
index 0000000..b04dd5b
--- /dev/null
@@ -0,0 +1,40 @@
+/* $Id: cqlstring.c,v 1.1 2003-01-06 08:20:27 adam Exp $
+   Copyright (C) 2002-2003
+   Index Data Aps
+
+This file is part of the YAZ toolkit.
+
+See the file LICENSE for details.
+*/
+#include <yaz/cql.h>
+
+struct cql_buf_info {
+    const char *str;
+    int off;
+};
+
+int getbuf(void *vp)
+{
+    struct cql_buf_info *bi = vp;
+    if (bi->str[bi->off] == 0)
+        return 0;
+    return bi->str[bi->off++];
+}
+
+void ungetbuf(int b, void *vp)
+{
+    struct cql_buf_info *bi = vp;
+    if (b)
+        (bi->off--);
+}
+
+int cql_parser_string(CQL_parser cp, const char *str)
+{
+    struct cql_buf_info b;
+
+    b.str = str;
+    b.off = 0;
+    
+    return cql_parser_stream(cp, getbuf, ungetbuf, &b);
+}
+
diff --git a/cql/cqltransform.c b/cql/cqltransform.c
new file mode 100644 (file)
index 0000000..d5e3ddb
--- /dev/null
@@ -0,0 +1,462 @@
+/* $Id: cqltransform.c,v 1.1 2003-01-06 08:20:27 adam Exp $
+   Copyright (C) 2002-2003
+   Index Data Aps
+
+This file is part of the YAZ toolkit.
+
+See the file LICENSE.
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <yaz/cql.h>
+
+struct cql_prop_entry {
+    char *pattern;
+    char *value;
+    struct cql_prop_entry *next;
+};
+
+struct cql_transform_t_ {
+    struct cql_prop_entry *entry;
+    int error;
+    char *addinfo;
+};
+
+cql_transform_t cql_transform_open_FILE(FILE *f)
+{
+    char line[1024];
+    cql_transform_t ct = malloc (sizeof(*ct));
+    struct cql_prop_entry **pp = &ct->entry;
+
+    ct->error = 0;
+    ct->addinfo = 0;
+    while (fgets(line, sizeof(line)-1, f))
+    {
+        const char *cp_value_start;
+        const char *cp_value_end;
+        const char *cp_pattern_end;
+        const char *cp = line;
+        while (*cp && !strchr(" \t=\r\n#", *cp))
+            cp++;
+        cp_pattern_end = cp;
+        if (cp == line)
+            continue;
+        while (*cp && strchr(" \t\r\n", *cp))
+            cp++;
+        if (*cp != '=')
+            continue;
+        cp++;
+        while (*cp && strchr(" \t\r\n", *cp))
+            cp++;
+        cp_value_start = cp;
+        if (!(cp_value_end = strchr(cp, '#')))
+            cp_value_end = strlen(line) + line;
+
+        if (cp_value_end != cp_value_start &&
+            strchr(" \t\r\n", cp_value_end[-1]))
+            cp_value_end--;
+        *pp = malloc (sizeof(**pp));
+        (*pp)->pattern = malloc (cp_pattern_end - line + 1);
+        memcpy ((*pp)->pattern, line, cp_pattern_end - line);
+        (*pp)->pattern[cp_pattern_end-line] = 0;
+
+        (*pp)->value = malloc (cp_value_end - cp_value_start + 1);
+        if (cp_value_start != cp_value_end)
+            memcpy ((*pp)->value, cp_value_start, cp_value_end-cp_value_start);
+        (*pp)->value[cp_value_end - cp_value_start] = 0;
+        pp = &(*pp)->next;
+    }
+    *pp = 0;
+    return ct;
+}
+
+void cql_transform_close(cql_transform_t ct)
+{
+    struct cql_prop_entry *pe;
+    if (!ct)
+        return;
+    pe = ct->entry;
+    while (pe)
+    {
+        struct cql_prop_entry *pe_next = pe->next;
+        free (pe->pattern);
+        free (pe->value);
+        free (pe);
+        pe = pe_next;
+    }
+    if (ct->addinfo)
+        free (ct->addinfo);
+    free (ct);
+}
+
+cql_transform_t cql_transform_open_fname(const char *fname)
+{
+    cql_transform_t ct;
+    FILE *f = fopen(fname, "r");
+    if (!f)
+        return 0;
+    ct = cql_transform_open_FILE(f);
+    fclose(f);
+    return ct;
+}
+
+static const char *cql_lookup_property(cql_transform_t ct,
+                                       const char *pat1, const char *pat2)
+{
+    char pattern[80];
+    struct cql_prop_entry *e;
+
+    if (pat2)
+        sprintf (pattern, "%.39s%.39s", pat1, pat2);
+    else
+        sprintf (pattern, "%.39s", pat1);
+    for (e = ct->entry; e; e = e->next)
+    {
+        if (!strcmp(e->pattern, pattern))
+            return e->value;
+    }
+    return 0;
+}
+
+static const char *cql_lookup_value(cql_transform_t ct,
+                                    const char *prefix,
+                                    const char *value)
+{
+    struct cql_prop_entry *e;
+    int len = strlen(prefix);
+
+    for (e = ct->entry; e; e = e->next)
+    {
+        if (!memcmp(e->pattern, prefix, len) && !strcmp(e->value, value))
+            return e->pattern + len;
+    }
+    return 0;
+}
+
+
+int cql_pr_attr(cql_transform_t ct, const char *category,
+                const char *val,
+                const char *default_val,
+                void (*pr)(const char *buf, void *client_data),
+                void *client_data,
+                int errcode)
+{
+    const char *res;
+    res = cql_lookup_property(ct, category, val ? val : default_val);
+    if (!res)
+        res = cql_lookup_property(ct, category, "*");
+    if (res)
+    {
+        char buf[64];
+
+        const char *cp0 = res, *cp1;
+        while ((cp1 = strchr(cp0, '=')))
+        {
+            while (*cp1 && *cp1 != ' ')
+                cp1++;
+            if (cp1 - cp0 >= sizeof(buf))
+                break;
+            memcpy (buf, cp0, cp1 - cp0);
+            buf[cp1-cp0] = 0;
+            (*pr)("@attr ", client_data);
+            (*pr)(buf, client_data);
+            (*pr)(" ", client_data);
+            cp0 = cp1;
+            while (*cp0 == ' ')
+                cp0++;
+        }
+        return 1;
+    }
+    /* error ... */
+    if (errcode && !ct->error)
+    {
+        ct->error = errcode;
+        ct->addinfo = strdup(val);
+    }
+    return 0;
+}
+
+void emit_term(cql_transform_t ct,
+               const char *term, int length,
+               void (*pr)(const char *buf, void *client_data),
+               void *client_data)
+{
+    int i;
+    if (length > 0)
+    {
+        if (length > 1 && term[0] == '^' && term[length-1] == '^')
+        {
+            cql_pr_attr(ct, "position.", "firstAndLast", 0,
+                        pr, client_data, 32);
+            term++;
+            length -= 2;
+        }
+        else if (term[0] == '^')
+        {
+            cql_pr_attr(ct, "position.", "first", 0,
+                        pr, client_data, 32);
+            term++;
+        }
+        else if (term[length-1] == '^')
+        {
+            cql_pr_attr(ct, "position.", "last", 0,
+                        pr, client_data, 32);
+            length--;
+        }
+        else
+        {
+            cql_pr_attr(ct, "position.", "any", 0,
+                        pr, client_data, 32);
+        }
+    }
+    (*pr)("\"", client_data);
+    for (i = 0; i<length; i++)
+    {
+        char buf[2];
+        buf[0] = term[i];
+        buf[1] = 0;
+        (*pr)(buf, client_data);
+    }
+    (*pr)("\" ", client_data);
+}
+
+void emit_wordlist(cql_transform_t ct,
+                   struct cql_node *cn,
+                   void (*pr)(const char *buf, void *client_data),
+                   void *client_data,
+                   const char *op)
+{
+    const char *cp0 = cn->u.st.term;
+    const char *cp1;
+    const char *last_term = 0;
+    int last_length = 0;
+    while(cp0)
+    {
+        while (*cp0 == ' ')
+            cp0++;
+        cp1 = strchr(cp0, ' ');
+        if (last_term)
+        {
+            (*pr)("@", client_data);
+            (*pr)(op, client_data);
+            (*pr)(" ", client_data);
+            emit_term(ct, last_term, last_length, pr, client_data);
+        }
+        last_term = cp0;
+        if (cp1)
+            last_length = cp1 - cp0;
+        else
+            last_length = strlen(cp0);
+        cp0 = cp1;
+    }
+    if (last_term)
+        emit_term(ct, last_term, last_length, pr, client_data);
+}
+
+
+static const char *cql_get_ns(cql_transform_t ct,
+                              struct cql_node *cn,
+                              struct cql_node **prefix_ar, int prefix_level,
+                              const char **n_prefix,
+                              const char **n_suffix)
+{
+    int i;
+    const char *ns = 0;
+    char prefix[32];
+    const char *cp = cn->u.st.index;
+    const char *cp_dot = strchr(cp, '.');
+
+    /* strz current prefix (empty if not given) */
+    if (cp_dot && cp_dot-cp < sizeof(prefix))
+    {
+        memcpy (prefix, cp, cp_dot - cp);
+        prefix[cp_dot - cp] = 0;
+    }
+    else
+        *prefix = 0;
+
+    /* 2. lookup in prefix_ar. and return NS */
+    for (i = prefix_level; !ns && --i >= 0; )
+    {
+        struct cql_node *cn_prefix = prefix_ar[i];
+        for (; cn_prefix; cn_prefix = cn_prefix->u.mod.next)
+        {
+            if (*prefix && cn_prefix->u.mod.name &&
+                !strcmp(prefix, cn_prefix->u.mod.name))
+            {
+                ns = cn_prefix->u.mod.value;
+                break;
+            }
+            else if (!*prefix && !cn_prefix->u.mod.name)
+            {
+                ns = cn_prefix->u.mod.value;
+                break;
+            }
+        }
+    }
+    if (!ns)
+    {
+        if (!ct->error)
+        {
+            ct->error = 15;
+            ct->addinfo = strdup(prefix);
+        }
+        return 0;
+    }
+    /* 3. lookup in set.NS for new prefix */
+    *n_prefix = cql_lookup_value(ct, "set.", ns);
+    if (!*n_prefix)
+    {
+        if (!ct->error)
+        {
+            ct->error = 15;
+            ct->addinfo = strdup(ns);
+        }
+        return 0;
+    }
+    /* 4. lookup qualifier.prefix. */
+    
+    cp = cn->u.st.index;
+    cp_dot = strchr(cp, '.');
+    
+    *n_suffix = cp_dot ? cp_dot+1 : cp;
+    return ns;
+}
+
+void cql_transform_r(cql_transform_t ct,
+                     struct cql_node *cn,
+                     void (*pr)(const char *buf, void *client_data),
+                     void *client_data,
+                     struct cql_node **prefix_ar, int prefix_level)
+{
+    const char *ns, *n_prefix, *n_suffix;
+
+    if (!cn)
+        return;
+    switch (cn->which)
+    {
+    case CQL_NODE_ST:
+        if (cn->u.st.prefixes && prefix_level < 20)
+            prefix_ar[prefix_level++] = cn->u.st.prefixes;
+        ns = cql_get_ns(ct, cn, prefix_ar, prefix_level, &n_prefix, &n_suffix);
+        if (ns)
+        {
+            char n_full[64];
+            sprintf (n_full, "%.20s.%.40s", n_prefix, n_suffix);
+        
+            if (!strcmp(ns, "http://www.loc.gov/zing/cql/srw-indexes/v1.0/")
+                && !strcmp(n_suffix, "resultSet"))
+            {
+                (*pr)("@set \"", client_data);
+                (*pr)(cn->u.st.term, client_data);
+                (*pr)("\" ", client_data);
+                return ;
+            }
+            cql_pr_attr(ct, "qualifier.", n_full, "srw.serverChoice",
+                        pr, client_data, 16);
+        }
+
+        if (cn->u.st.relation && !strcmp(cn->u.st.relation, "="))
+            cql_pr_attr(ct, "relation.", "eq", "scr",
+                        pr, client_data, 19);
+        else
+            cql_pr_attr(ct, "relation.", cn->u.st.relation, "eq",
+                        pr, client_data, 19);
+        if (cn->u.st.modifiers)
+        {
+            struct cql_node *mod = cn->u.st.modifiers;
+            for (; mod; mod = mod->u.mod.next)
+            {
+                cql_pr_attr(ct, "relationModifier.", mod->u.mod.value, 0,
+                            pr, client_data, 20);
+            }
+        }
+        cql_pr_attr(ct, "structure.", cn->u.st.relation, 0,
+                    pr, client_data, 24);
+        if (cn->u.st.relation && !strcmp(cn->u.st.relation, "all"))
+        {
+            emit_wordlist(ct, cn, pr, client_data, "and");
+        }
+        else if (cn->u.st.relation && !strcmp(cn->u.st.relation, "any"))
+        {
+            emit_wordlist(ct, cn, pr, client_data, "or");
+        }
+        else
+        {
+            emit_term(ct, cn->u.st.term, strlen(cn->u.st.term),
+                      pr, client_data);
+        }
+        break;
+    case CQL_NODE_BOOL:
+        if (cn->u.bool.prefixes && prefix_level < 20)
+            prefix_ar[prefix_level++] = cn->u.bool.prefixes;
+        (*pr)("@", client_data);
+        (*pr)(cn->u.bool.value, client_data);
+        (*pr)(" ", client_data);
+
+        cql_transform_r(ct, cn->u.bool.left, pr, client_data,
+                        prefix_ar, prefix_level);
+        cql_transform_r(ct, cn->u.bool.right, pr, client_data,
+                        prefix_ar, prefix_level);
+    }
+}
+
+int cql_transform(cql_transform_t ct,
+                  struct cql_node *cn,
+                  void (*pr)(const char *buf, void *client_data),
+                  void *client_data)
+{
+    struct cql_node *prefix_ar[20], **pp;
+    struct cql_prop_entry *e;
+
+    ct->error = 0;
+    if (ct->addinfo)
+        free (ct->addinfo);
+    ct->addinfo = 0;
+
+    prefix_ar[0] = 0;
+    pp = &prefix_ar[0];
+    for (e = ct->entry; e ; e = e->next)
+    {
+        if (!memcmp(e->pattern, "set.", 4))
+        {
+            *pp = cql_node_mk_mod(e->pattern+4, e->value);
+            pp = &(*pp)->u.mod.next;
+        }
+        else if (!strcmp(e->pattern, "set"))
+        {
+            *pp = cql_node_mk_mod(0, e->value);
+            pp = &(*pp)->u.mod.next;
+        }
+    }
+    cql_transform_r (ct, cn, pr, client_data, prefix_ar, 1);
+    return ct->error;
+}
+
+
+int cql_transform_FILE(cql_transform_t ct, struct cql_node *cn, FILE *f)
+{
+    return cql_transform(ct, cn, cql_fputs, f);
+}
+
+int cql_transform_buf(cql_transform_t ct, struct cql_node *cn,
+                      char *out, int max)
+{
+    struct cql_buf_write_info info;
+    int r;
+
+    info.off = 0;
+    info.max = max;
+    info.buf = out;
+    r = cql_transform(ct, cn, cql_buf_write_handler, &info);
+    if (info.off >= 0)
+        info.buf[info.off] = '\0';
+    return r;
+}
+
+int cql_transform_error(cql_transform_t ct, const char **addinfo)
+{
+    *addinfo = ct->addinfo;
+    return ct->error;
+}
diff --git a/cql/cqlutil.c b/cql/cqlutil.c
new file mode 100644 (file)
index 0000000..6207d19
--- /dev/null
@@ -0,0 +1,177 @@
+/* $Id: cqlutil.c,v 1.1 2003-01-06 08:20:27 adam Exp $
+   Copyright (C) 2002-2003
+   Index Data Aps
+
+This file is part of the YAZ toolkit.
+
+See the file LICENSE.
+*/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <yaz/cql.h>
+
+void cql_fputs(const char *buf, void *client_data)
+{
+    FILE *f = client_data;
+    fputs(buf, f);
+}
+
+struct cql_node *cql_node_dup (struct cql_node *cp)
+{
+    struct cql_node *cn;
+
+    if (!cp)
+        return 0;
+    switch (cp->which)
+    {
+    case CQL_NODE_ST:
+        cn = cql_node_mk_sc(cp->u.st.index,
+                            cp->u.st.relation,
+                            cp->u.st.term);
+        cn->u.st.modifiers = cql_node_dup(cp->u.st.modifiers);
+        cn->u.st.prefixes = cql_node_dup(cp->u.st.prefixes);
+        break;
+    case CQL_NODE_MOD:
+        cn = cql_node_mk_mod(cp->u.mod.name,
+                             cp->u.mod.value);
+        cn->u.mod.next = cql_node_dup(cp->u.mod.next);
+        break;
+    case CQL_NODE_BOOL:
+        cn = cql_node_mk_boolean(cp->u.bool.value);
+        cn->u.bool.left = cql_node_dup(cp->u.bool.left);
+        cn->u.bool.right = cql_node_dup(cp->u.bool.right);
+        cn->u.bool.prefixes = cql_node_dup(cp->u.bool.prefixes);
+    }
+    return cn;
+}
+
+struct cql_node *cql_node_mk_sc(const char *index,
+                                const char *relation,
+                                const char *term)
+{
+    struct cql_node *p = malloc(sizeof(*p));
+    p->which = CQL_NODE_ST;
+    p->u.st.index = 0;
+    if (index)
+        p->u.st.index = strdup(index);
+    p->u.st.term = 0;
+    if (term)
+        p->u.st.term = strdup(term);
+    p->u.st.relation = 0;
+    if (relation)
+        p->u.st.relation = strdup(relation);
+    p->u.st.modifiers = 0;
+    p->u.st.prefixes = 0;
+    return p;
+}
+
+struct cql_node *cql_node_mk_mod(const char *name,
+                                 const char *value)
+{
+    struct cql_node *p = malloc(sizeof(*p));
+    p->which = CQL_NODE_MOD;
+
+    p->u.mod.name = 0;
+    if (name)
+        p->u.mod.name = strdup(name);
+    p->u.mod.value = 0;
+    if (value)
+        p->u.mod.value = strdup(value);
+    p->u.mod.next = 0;
+    return p;
+}
+
+struct cql_node *cql_node_mk_boolean(const char *op)
+{
+    struct cql_node *p = malloc(sizeof(*p));
+    p->which = CQL_NODE_BOOL;
+    p->u.bool.value = 0;
+    if (op)
+        p->u.bool.value = strdup(op);
+    p->u.bool.left = 0;
+    p->u.bool.right = 0;
+    p->u.bool.modifiers = 0;
+    p->u.bool.prefixes = 0;
+    return p;
+}
+
+struct cql_node *cql_node_prefix(struct cql_node *n, const char *prefix,
+                                 const char *uri)
+{
+    struct cql_node **cpp = 0;
+    if (n->which == CQL_NODE_ST)
+    {
+        cpp = &n->u.st.prefixes;
+    }
+    else if (n->which == CQL_NODE_BOOL)
+    {
+        cpp = &n->u.bool.prefixes;
+    }
+    if (cpp)
+    {
+        struct cql_node *cp = cql_node_mk_mod(prefix, uri);
+        cp->u.mod.next = *cpp;
+        *cpp = cp;
+    }
+    return n;
+}
+
+struct cql_node *cql_node_mk_proxargs(const char *relation,
+                                      const char *distance,
+                                      const char *unit,
+                                      const char *ordering)
+{
+    struct cql_node *m = 0, *m1;
+
+    if (ordering && *ordering)
+        m = cql_node_mk_mod("ordering", ordering);
+    if (unit && *unit)
+    {
+        m1 = cql_node_mk_mod("unit", unit);
+        m1->u.mod.next = m;
+        m = m1;
+    }
+    if (distance && *distance)
+    {
+        m1 = cql_node_mk_mod("distance", distance);
+        m1->u.mod.next = m;
+        m = m1;
+    }
+    if (relation && *relation)
+    {
+        m1 = cql_node_mk_mod("relation", relation);
+        m1->u.mod.next = m;
+        m = m1;
+    }
+    return m;
+}
+
+void cql_node_destroy(struct cql_node *cn)
+{
+    if (!cn)
+        return;
+    switch (cn->which)
+    {
+    case CQL_NODE_ST:
+        free (cn->u.st.index);
+        free (cn->u.st.relation);
+        free (cn->u.st.term);
+        cql_node_destroy(cn->u.st.modifiers);
+        cql_node_destroy(cn->u.st.prefixes);
+        break;
+    case CQL_NODE_MOD:
+        free (cn->u.mod.name);
+        free (cn->u.mod.value);
+        cql_node_destroy(cn->u.mod.next);
+        break;
+    case CQL_NODE_BOOL:
+        free (cn->u.bool.value);
+        cql_node_destroy(cn->u.bool.left);
+        cql_node_destroy(cn->u.bool.right);
+        cql_node_destroy(cn->u.bool.prefixes);
+    }
+    free (cn);
+}
+
diff --git a/cql/lexer.c b/cql/lexer.c
new file mode 100644 (file)
index 0000000..8a26522
--- /dev/null
@@ -0,0 +1,108 @@
+/* $Id: lexer.c,v 1.1 2003-01-06 08:20:27 adam Exp $
+   Copyright (C) 2002-2003
+   Index Data Aps
+
+This file is part of the YAZ toolkit.
+
+See the file LICENSE.
+*/
+/*
+ * bison lexer for CQL.
+ */
+
+int yylex(YYSTYPE *lval, void *vp)
+{
+    CQL_parser cp = (CQL_parser) vp;
+    int c;
+    do
+    {
+        c = cp->getbyte(cp->client_data);
+        if (c == 0)
+            return 0;
+        if (c == '\n')
+            return 0;
+    } while (isspace(c));
+    lval->rel = 0;
+    lval->len = 0;
+    if (strchr("()=></", c))
+    {
+        int c1;
+        lval->buf[lval->len++] = c;
+        if (c == '>')
+        {
+            c1 = cp->getbyte(cp->client_data);
+            if (c1 == '=')
+            {
+                lval->buf[lval->len++] = c1;
+                lval->buf[lval->len] = 0;
+                return GE;
+            }
+            else
+                cp->ungetbyte(c1, cp->client_data);
+        }
+        else if (c == '<')
+        {
+            c1 = cp->getbyte(cp->client_data);
+            if (c1 == '=')
+            {
+                lval->buf[lval->len++] = c1;
+                lval->buf[lval->len] = 0;
+                return LE;
+            }
+            else if (c1 == '>')
+            {
+                lval->buf[lval->len++] = c1;
+                lval->buf[lval->len] = 0;
+                return NE;
+            }
+            else
+                cp->ungetbyte(c1, cp->client_data);
+        }
+        lval->buf[lval->len] = 0;
+        return c;
+    }
+    if (c == '"')
+    {
+        while ((c = cp->getbyte(cp->client_data)) != EOF && c != '"')
+        {
+            if (c == '\\')
+                c = cp->getbyte(cp->client_data);
+            lval->buf[lval->len++] = c;
+        }
+        lval->buf[lval->len] = 0;
+    }
+    else
+    {
+        lval->buf[lval->len++] = c;
+        while ((c = cp->getbyte(cp->client_data)) != 0 &&
+               !strchr(" \n()=<>/", c))
+        {
+            if (c == '\\')
+                c = cp->getbyte(cp->client_data);
+            lval->buf[lval->len++] = c;
+        }
+        lval->buf[lval->len] = 0;
+#if YYDEBUG
+        printf ("got %s\n", lval->buf);
+#endif
+        if (c != 0)
+            cp->ungetbyte(c, cp->client_data);
+        if (!strcmp(lval->buf, "and"))
+            return AND;
+        if (!strcmp(lval->buf, "or"))
+            return OR;
+        if (!strcmp(lval->buf, "not"))
+            return NOT;
+        if (!strcmp(lval->buf, "exact"))
+            return EXACT;
+        if (!strcmp(lval->buf, "all"))
+            return ALL;
+        if (!strncmp(lval->buf, "prox", 4))
+            return PROX;
+        if (!strcmp(lval->buf, "any"))
+            return ANY;
+        if (!strcmp(lval->buf, "scr"))
+            return SCR;
+    }
+    return TERM;
+}
diff --git a/cql/xcqlutil.c b/cql/xcqlutil.c
new file mode 100644 (file)
index 0000000..9294a02
--- /dev/null
@@ -0,0 +1,210 @@
+/* $Id: xcqlutil.c,v 1.1 2003-01-06 08:20:27 adam Exp $
+   Copyright (C) 2002-2003
+   Index Data Aps
+
+This file is part of the YAZ toolkit.
+
+See the file LICENSE.
+*/
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <yaz/cql.h>
+
+static void pr_n(const char *buf, 
+                void (*pr)(const char *buf, void *client_data),
+                void *client_data, int n)
+{
+    int i;
+    for (i = 0; i<n; i++)
+        (*pr)(" ", client_data);
+    (*pr)(buf, client_data);
+}
+
+static void pr_cdata(const char *buf,
+                     void (*pr)(const char *buf, void *client_data),
+                     void *client_data)
+{
+    const char *src = buf;
+    char bf[2];
+    while (*src)
+    {
+        switch(*src)
+        {
+        case '&':
+            (*pr)("&amp;", client_data);
+            break;
+        case '<':
+            (*pr)("&lt;", client_data);
+            break;
+        case '>':
+            (*pr)("&gt;", client_data);
+            break;
+        default:
+            bf[0] = *src;
+            bf[1] = 0;
+            (*pr)(bf, client_data);
+        }
+        src++;
+    }
+}
+                    
+static void prefixes(struct cql_node *cn,
+                     void (*pr)(const char *buf, void *client_data),
+                     void *client_data, int level)
+{
+    if (cn)
+    {
+        pr_n("<prefixes>\n", pr, client_data, level);
+        for (; cn; cn = cn->u.mod.next)
+        {
+            pr_n("<prefix>\n", pr, client_data, level+2);
+            if (cn->u.mod.name)
+            {
+                pr_n("<name>", pr, client_data, level+4);
+                pr_cdata(cn->u.mod.name, pr, client_data);
+                pr_n("</name>\n", pr, client_data, 0);
+            }
+            if (cn->u.mod.value)
+            {
+                pr_n("<identifier>", pr, client_data, level+4);
+                pr_cdata(cn->u.mod.value, pr, client_data);
+                pr_n("</identifier>\n", pr, client_data, 0);
+            }
+            pr_n("</prefix>\n", pr, client_data, level+2);
+        }
+        pr_n("</prefixes>\n", pr, client_data, level);
+    }
+}
+                     
+static void cql_to_xml_r(struct cql_node *cn,
+                         void (*pr)(const char *buf, void *client_data),
+                         void *client_data, int level)
+{
+    if (!cn)
+        return;
+    switch (cn->which)
+    {
+    case CQL_NODE_ST:
+        pr_n("<searchClause>\n", pr, client_data, level);
+        prefixes(cn->u.st.prefixes, pr, client_data, level+2);
+        if (cn->u.st.index)
+        {
+            pr_n("<index>", pr, client_data, level+2);
+            pr_cdata(cn->u.st.index, pr, client_data);
+            pr_n("</index>\n", pr, client_data, 0);
+        }
+        if (cn->u.st.relation)
+        {
+            struct cql_node *m = cn->u.st.modifiers;
+            pr_n("<relation>\n", pr, client_data, level+2);
+            pr_n("<value>", pr, client_data, level+4);
+            pr_cdata(cn->u.st.relation, pr, client_data);
+            pr_n("</value>\n", pr, client_data, 0);
+            if (m)
+            {
+                pr_n("<modifiers>\n", pr, client_data, level+4);
+                for (; m; m = m->u.mod.next)
+                {
+                    pr_n("<modifier><value>", pr, client_data, level+6);
+                    pr_cdata(m->u.mod.value, pr, client_data);
+                    pr_n("</value></modifier>\n", pr, client_data, 0);
+                }
+                pr_n("</modifiers>\n", pr, client_data, level+4);
+            }
+            pr_n("</relation>\n", pr, client_data, level+2);
+        }
+        if (cn->u.st.term)
+        {
+            pr_n("<term>", pr, client_data, level+2);
+            pr_cdata(cn->u.st.term, pr, client_data);
+            pr_n("</term>\n", pr, client_data, 0);
+        }
+        pr_n("</searchClause>\n", pr, client_data, level);
+        break;
+    case CQL_NODE_BOOL:
+        pr_n("<triple>\n", pr, client_data, level);
+        prefixes(cn->u.st.prefixes, pr, client_data, level+2);
+        if (cn->u.bool.value)
+        {
+            struct cql_node *m = cn->u.bool.modifiers;
+            pr_n("<boolean>\n", pr, client_data, level+2);
+
+            pr_n("<value>", pr, client_data, level+4);
+            pr_cdata(cn->u.bool.value, pr, client_data);
+            pr_n("</value>\n", pr, client_data, 0);
+
+            if (m)
+            {
+                pr_n("<modifiers>\n", pr, client_data, level+4);
+                for (; m; m = m->u.mod.next)
+                {
+                    pr_n("<modifier><type>", pr, client_data, level+6);
+                    pr_cdata(m->u.mod.name, pr, client_data);
+                    pr_n("</type>", pr, client_data, 0);
+                    if (m->u.mod.value)
+                    {
+                        pr_n("<value>", pr, client_data, 0);
+                        pr_cdata(m->u.mod.value, pr, client_data);
+                        pr_n("</value>", pr, client_data, 0);
+                    }
+                    pr_n("</modifier>\n", pr, client_data, 0);
+                }
+                pr_n("</modifiers>\n", pr, client_data, level+4);
+            }
+            pr_n("</boolean>\n", pr, client_data, level+2);
+        }
+        if (cn->u.bool.left)
+        {
+            printf ("%*s<leftOperand>\n", level+2, "");
+            cql_to_xml_r(cn->u.bool.left, pr, client_data, level+4);
+            printf ("%*s</leftOperand>\n", level+2, "");
+        }
+        if (cn->u.bool.right)
+        {
+            printf ("%*s<rightOperand>\n", level+2, "");
+            cql_to_xml_r(cn->u.bool.right, pr, client_data, level+4);
+            printf ("%*s</rightOperand>\n", level+2, "");
+        }
+        pr_n("</triple>\n", pr, client_data, level);
+    }
+}
+
+void cql_to_xml(struct cql_node *cn, 
+                void (*pr)(const char *buf, void *client_data),
+                void *client_data)
+{
+    cql_to_xml_r(cn, pr, client_data, 0);
+}
+
+void cql_to_xml_stdio(struct cql_node *cn, FILE *f)
+{
+    cql_to_xml(cn, cql_fputs, f);
+}
+
+void cql_buf_write_handler (const char *b, void *client_data)
+{
+    struct cql_buf_write_info *info = client_data;
+    int l = strlen(b);
+    if (info->off < 0 || (info->off + l >= info->max))
+    {
+        info->off = -1;
+        return;
+    }
+    memcpy (info->buf + info->off, b, l);
+    info->off += l;
+}
+
+int cql_to_xml_buf(struct cql_node *cn, char *out, int max)
+{
+    struct cql_buf_write_info info;
+    info.off = 0;
+    info.max = max;
+    info.buf = out;
+    cql_to_xml(cn, cql_buf_write_handler, &info);
+    if (info.off >= 0)
+        info.buf[info.off] = '\0';
+    return info.off;
+}
+
index 4370644..f33c5cc 100755 (executable)
@@ -12,7 +12,7 @@
 export DH_COMPAT=2
 
 YAZ_WITH_SSL?=1
-CONFIG_FLAGS=--enable-static --enable-shared --enable-tcpd --prefix=/usr
+CONFIG_FLAGS=--without-gsoap --enable-static --enable-shared --enable-tcpd --prefix=/usr
 
 # Enable parallel builds if CONCURRENCY_LEVEL is set
 ifdef CONCURRENCY_LEVEL
diff --git a/etc/MARC21slim2DC.xsl b/etc/MARC21slim2DC.xsl
new file mode 100644 (file)
index 0000000..75f92ab
--- /dev/null
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id: MARC21slim2DC.xsl,v 1.1 2003-01-06 08:20:27 adam Exp $ -->
+<xsl:stylesheet version="1.0"
+  xmlns:marc="http://www.loc.gov/MARC21/slim"
+  xmlns:dc="http://purl.org/dc/elements/1.1/"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  exclude-result-prefixes="marc">
+       <xsl:import href="MARC21slimUtils.xsl"/>
+       <xsl:output method="xml" indent="yes"/>
+       
+       <xsl:template match="/">
+                       <xsl:apply-templates/>
+       </xsl:template>
+
+       <xsl:template match="marc:record">
+               <xsl:variable name="leader" select="marc:leader"/>
+               <xsl:variable name="leader6" select="substring($leader,7,1)"/>
+               <xsl:variable name="leader7" select="substring($leader,8,1)"/>
+               <xsl:variable name="controlField008" select="marc:controlfield[@tag=008]"/>
+
+         <dc:dc>
+                       <xsl:for-each select="marc:datafield[@tag=245]">
+                               <dc:title>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abfghk</xsl:with-param>
+                                       </xsl:call-template>
+                               </dc:title>
+                       </xsl:for-each>
+
+       
+                       <xsl:for-each select="marc:datafield[@tag=100]|marc:datafield[@tag=110]|marc:datafield[@tag=111]|marc:datafield[@tag=700]|marc:datafield[@tag=710]|marc:datafield[@tag=711]|marc:datafield[@tag=720]">
+                               <dc:creator>
+                                       <xsl:value-of select="."/>
+                               </dc:creator>
+                       </xsl:for-each>
+
+                       <dc:type>               
+                               <xsl:if test="$leader7='c'">
+                                       <xsl:attribute name="collection">yes</xsl:attribute>
+                               </xsl:if>
+
+                               <xsl:if test="$leader6='d' or $leader6='f' or $leader6='p' or $leader6='t'">
+                                       <xsl:attribute name="manuscript">yes</xsl:attribute>
+                               </xsl:if>
+
+                               <xsl:choose>
+                                       <xsl:when test="$leader6='a' or $leader6='t'">text</xsl:when>
+                                       <xsl:when test="$leader6='e' or $leader6='f'">cartographic</xsl:when>
+                                       <xsl:when test="$leader6='c' or $leader6='d'">notated music</xsl:when>
+                                       <xsl:when test="$leader6='i' or $leader6='j'">sound recording</xsl:when>
+                                       <xsl:when test="$leader6='k'">still image</xsl:when>
+                                       <xsl:when test="$leader6='g'">moving image</xsl:when>
+                                       <xsl:when test="$leader6='r'">three dimensional object</xsl:when>
+                                       <xsl:when test="$leader6='m'">software, multimedia</xsl:when>
+                                       <xsl:when test="$leader6='p'">mixed material</xsl:when>
+                               </xsl:choose>
+                       </dc:type>
+
+                       <xsl:for-each select="marc:datafield[@tag=655]">
+                               <dc:type>
+                                       <xsl:value-of select="."/>
+                               </dc:type>
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=260]">
+                               <dc:publisher>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">ab</xsl:with-param>
+                                       </xsl:call-template>
+                               </dc:publisher>
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='c']">
+                               <dc:date>
+                                       <xsl:value-of select="."/>
+                               </dc:date>                              
+                       </xsl:for-each>
+
+                       <dc:language>
+                               <xsl:value-of select="substring($controlField008,36,3)"/>
+                       </dc:language>
+
+                       <xsl:for-each select="marc:datafield[@tag=856]/marc:subfield[@code='q']">
+                               <dc:format>
+                                       <xsl:value-of select="."/>
+                               </dc:format>
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=520]">
+                               <dc:description>
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>
+                               </dc:description>
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=521]">
+                               <dc:description>
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>
+                               </dc:description>
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[500&lt;@tag][@tag&lt;=599][not(@tag=506 or @tag=530 or @tag=540 or @tag=546)]">
+                               <dc:description>
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>
+                               </dc:description>
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=600]">
+                               <dc:subject>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abcdq</xsl:with-param>
+                                       </xsl:call-template>
+                               </dc:subject>
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=610]">
+                               <dc:subject>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abcdq</xsl:with-param>
+                                       </xsl:call-template>
+                               </dc:subject>
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=611]">
+                               <dc:subject>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abcdq</xsl:with-param>
+                                       </xsl:call-template>
+                               </dc:subject>
+                       </xsl:for-each>
+               
+                       <xsl:for-each select="marc:datafield[@tag=630]">
+                               <dc:subject>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abcdq</xsl:with-param>
+                                       </xsl:call-template>
+                               </dc:subject>
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=650]">
+                               <dc:subject>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abcdq</xsl:with-param>
+                                       </xsl:call-template>
+                               </dc:subject>
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=653]">
+                               <dc:subject>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abcdq</xsl:with-param>
+                                       </xsl:call-template>
+                               </dc:subject>
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=752]">
+                               <dc:coverage>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abcd</xsl:with-param>
+                                       </xsl:call-template>
+                               </dc:coverage>
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=530]">
+                               <dc:relation type="original">
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abcdu</xsl:with-param>
+                                       </xsl:call-template>
+                               </dc:relation>  
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=760]|marc:datafield[@tag=762]|marc:datafield[@tag=765]|marc:datafield[@tag=767]|marc:datafield[@tag=770]|marc:datafield[@tag=772]|marc:datafield[@tag=773]|marc:datafield[@tag=774]|marc:datafield[@tag=775]|marc:datafield[@tag=776]|marc:datafield[@tag=777]|marc:datafield[@tag=780]|marc:datafield[@tag=785]|marc:datafield[@tag=786]|marc:datafield[@tag=787]">
+                               <dc:relation>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">ot</xsl:with-param>
+                                       </xsl:call-template>
+                               </dc:relation>  
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=856]">
+                               <dc:identifier>
+                                       <xsl:value-of select="marc:subfield[@code='u']"/>
+                               </dc:identifier>
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=506]">
+                               <dc:rights>
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>
+                               </dc:rights>
+                       </xsl:for-each>
+
+                       <xsl:for-each select="marc:datafield[@tag=540]">
+                               <dc:rights>
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>
+                               </dc:rights>
+                       </xsl:for-each>
+               </dc:dc>
+       </xsl:template>
+</xsl:stylesheet>
diff --git a/etc/MARC21slim2MODS.xsl b/etc/MARC21slim2MODS.xsl
new file mode 100644 (file)
index 0000000..ff35524
--- /dev/null
@@ -0,0 +1,1873 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<xsl:stylesheet version="1.0" xmlns:xlink="http://www.w3.org/TR/xlink" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns="http://www.loc.gov/mods/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="marc">\r
+       <xsl:include href="MARC21slimUtils.xsl"/>\r
+       <xsl:output method="xml" indent="yes"/>\r
+       \r
+       <xsl:template match="/">\r
+               <collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/  http://www.loc.gov/standards/marcxml/schema/mods.xsd">\r
+                       <xsl:apply-templates/>\r
+               </collection>\r
+       </xsl:template>\r
+\r
+       <xsl:template match="marc:record">\r
+               <mods>\r
+                       <xsl:variable name="leader" select="marc:leader"/>\r
+                       <xsl:variable name="leader6" select="substring($leader,7,1)"/>\r
+                       <xsl:variable name="leader7" select="substring($leader,8,1)"/>\r
+                       <xsl:variable name="controlField008" select="marc:controlfield[@tag=008]"/>\r
+\r
+                       <xsl:variable name="typeOf008">\r
+                               <xsl:choose>\r
+                                       <xsl:when test="$leader6='a'">\r
+                                               <xsl:choose>\r
+                                                       <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when>\r
+                                                       <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">SE</xsl:when>                             \r
+                                               </xsl:choose>\r
+                                       </xsl:when>\r
+                                       <xsl:when test="$leader6='t'">BK</xsl:when>\r
+                                       <xsl:when test="$leader6='p'">MM</xsl:when>\r
+                                       <xsl:when test="$leader6='m'">CF</xsl:when>     \r
+                                       <xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when>     \r
+                                       <xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">VM</xsl:when>                             \r
+                                       <xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'">MU</xsl:when>                             \r
+                               </xsl:choose>\r
+                       </xsl:variable>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=245]">\r
+                               <titleInfo>\r
+                                       <xsl:variable name="title">\r
+                                               <xsl:call-template name="chopPunctuation">\r
+                                                       <xsl:with-param name="chopString">\r
+                                                               <xsl:call-template name="subfieldSelect">\r
+                                                                       <xsl:with-param name="codes">abfghk</xsl:with-param>\r
+                                                               </xsl:call-template>\r
+                                                       </xsl:with-param>\r
+                                               </xsl:call-template>\r
+                                       </xsl:variable>\r
+                                       <xsl:choose>\r
+                                               <xsl:when test="@ind2>0">\r
+                                                       <nonSort>\r
+                                                               <xsl:value-of select="substring($title,1,@ind2)"/>\r
+                                                       </nonSort>\r
+                                                       <title>\r
+                                                               <xsl:value-of select="substring($title,@ind2+1)"/>\r
+                                                       </title>\r
+                                               </xsl:when>\r
+                                               <xsl:otherwise>\r
+                                                       <title>\r
+                                                               <xsl:value-of select="$title"/>\r
+                                                       </title>\r
+                                               </xsl:otherwise>\r
+                                       </xsl:choose>\r
+                                       <xsl:call-template name="part"/>\r
+                               </titleInfo>\r
+                       </xsl:for-each>\r
+                       \r
+                       <xsl:for-each select="marc:datafield[@tag=210]">\r
+                               <titleInfo type="abbreviated">\r
+                                       <title>\r
+                                               <xsl:call-template name="subfieldSelect">\r
+                                                       <xsl:with-param name="codes">ab</xsl:with-param>\r
+                                               </xsl:call-template>\r
+                                       </title>\r
+                               </titleInfo>\r
+                       </xsl:for-each>\r
+                       \r
+                       <xsl:for-each select="marc:datafield[@tag=242]">\r
+                               <titleInfo type="translated">\r
+                                       <title>\r
+                                               <xsl:call-template name="subfieldSelect">\r
+                                                       <xsl:with-param name="codes">abh</xsl:with-param>\r
+                                               </xsl:call-template>\r
+                                       </title>\r
+                                       <xsl:call-template name="part"/>\r
+                               </titleInfo>\r
+                       </xsl:for-each>\r
+                       \r
+                       <xsl:for-each select="marc:datafield[@tag=246]">\r
+                               <titleInfo type="alternative">\r
+                                       <xsl:for-each select="marc:subfield[@code='i']">\r
+                                               <xsl:attribute name="displayLabel">\r
+                                                       <xsl:value-of select="text()"/>\r
+                                               </xsl:attribute>\r
+                                       </xsl:for-each>\r
+                                       <title>\r
+                                               <xsl:call-template name="subfieldSelect">\r
+                                                       <xsl:with-param name="codes">abfh</xsl:with-param>\r
+                                               </xsl:call-template>\r
+                                       </title>\r
+                                       <xsl:call-template name="part"/>                        \r
+                               </titleInfo>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">\r
+                               <titleInfo type="uniform">\r
+                                       <title>\r
+                                               <xsl:variable name="str">\r
+                                                       <xsl:for-each select="marc:subfield">\r
+                                                               <xsl:if test="(contains('adfhklmor',@code) and (not(../marc:subfield[@code='n' or @code='p']) or (following-sibling::marc:subfield[@code='n' or @code='p'])))">\r
+                                                                       <xsl:value-of select="text()"/><xsl:text> </xsl:text>\r
+                                                               </xsl:if>\r
+                                                       </xsl:for-each>\r
+                                               </xsl:variable>\r
+                                               <xsl:value-of select="substring($str,1,string-length($str)-1)"/>\r
+                                       </title>\r
+                                       <xsl:call-template name="part"/>                        \r
+                               </titleInfo>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=740][@ind2!=2]">\r
+                               <titleInfo type="alternative">\r
+                                       <title>\r
+                                               <xsl:call-template name="subfieldSelect">\r
+                                                       <xsl:with-param name="codes">ah</xsl:with-param>\r
+                                               </xsl:call-template>\r
+                                       </title>\r
+                                       <xsl:call-template name="part"/>                        \r
+                               </titleInfo>\r
+                       </xsl:for-each>\r
+                       \r
+                       <xsl:for-each select="marc:datafield[@tag=100]">\r
+                               <name type="personal">\r
+                                       <xsl:call-template name="nameABCDQ"/>\r
+                                       <xsl:call-template name="affiliation"/>\r
+                                       <role>creator</role>\r
+                                       <xsl:call-template name="role"/>\r
+                               </name>\r
+                       </xsl:for-each>\r
+\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=110]">\r
+                               <name type="corporate">\r
+                                       <xsl:call-template name="nameABCDN"/>\r
+                                       <role>creator</role>\r
+                                       <xsl:call-template name="role"/>\r
+                               </name>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=111]">\r
+                               <name type="conference">\r
+                                       <xsl:call-template name="nameACDEQ"/>\r
+                                       <role>creator</role>\r
+                                       <xsl:for-each select="marc:subfield[@code='4']">\r
+                                               <role><xsl:value-of select="."/></role>\r
+                                       </xsl:for-each>\r
+                               </name>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=700][not(marc:subfield[@code='t'])]">\r
+                               <name type="personal">\r
+                                       <xsl:call-template name="nameABCDQ"/>\r
+                                       <xsl:call-template name="affiliation"/>\r
+                                       <xsl:call-template name="role"/>\r
+                               </name>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=710][not(marc:subfield[@code='t'])]">\r
+                               <name type="corporate">\r
+                                       <xsl:call-template name="nameABCDN"/>\r
+                                       <xsl:call-template name="role"/>\r
+                               </name>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=711][not(marc:subfield[@code='t'])]">\r
+                               <name type="conference">\r
+                                       <xsl:call-template name="nameACDEQ"/>\r
+                                       <xsl:for-each select="marc:subfield[@code='4']">\r
+                                               <role><xsl:value-of select="."/></role>\r
+                                       </xsl:for-each>\r
+                               </name>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=720][not(marc:subfield[@code='t'])]">\r
+                               <name>\r
+                                       <xsl:if test="@ind1=1">\r
+                                               <xsl:attribute name="type">personal</xsl:attribute>\r
+                                       </xsl:if>\r
+                                       <namePart>\r
+                                               <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                                       </namePart>\r
+                                       <xsl:call-template name="role"/>\r
+                               </name>\r
+                       </xsl:for-each>\r
+\r
+                       <typeOfResource>                \r
+                               <xsl:if test="$leader7='c'">\r
+                                       <xsl:attribute name="collection">yes</xsl:attribute>\r
+                               </xsl:if>\r
+                               <xsl:if test="$leader6='d' or $leader6='f' or $leader6='p' or $leader6='t'">\r
+                                       <xsl:attribute name="manuscript">yes</xsl:attribute>\r
+                               </xsl:if>\r
+\r
+                               <xsl:choose>\r
+                                       <xsl:when test="$leader6='a' or $leader6='t'">text</xsl:when>\r
+                                       <xsl:when test="$leader6='e' or $leader6='f'">cartographic</xsl:when>\r
+                                       <xsl:when test="$leader6='c' or $leader6='d'">notated music</xsl:when>\r
+                                       <xsl:when test="$leader6='i' or $leader6='j'">sound recording</xsl:when>\r
+                                       <xsl:when test="$leader6='k'">still image</xsl:when>\r
+                                       <xsl:when test="$leader6='g'">moving image</xsl:when>\r
+                                       <xsl:when test="$leader6='r'">three dimensional object</xsl:when>\r
+                                       <xsl:when test="$leader6='m'">software, multimedia</xsl:when>\r
+                                       <xsl:when test="$leader6='p'">mixed material</xsl:when>\r
+                               </xsl:choose>\r
+                       </typeOfResource>\r
+\r
+                               <xsl:if test="substring($controlField008,26,1)='d'">\r
+                                       <genre authority="marc">globe</genre>\r
+                               </xsl:if>\r
+                       \r
+                               <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='r']">\r
+                                       <genre authority="marc">remote sensing image</genre>\r
+                               </xsl:if>\r
+\r
+                               <xsl:if test="$typeOf008='MP'">\r
+                                       <xsl:variable name="controlField008-25" select="substring($controlField008,26,1)"/>\r
+                                       <xsl:choose>\r
+                                               <xsl:when test="$controlField008-25='a' or $controlField008-25='b' or $controlField008-25='c' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='j']">\r
+                                                       <genre authority="marc">map</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-25='e' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">\r
+                                                       <genre authority="marc">atlas</genre>\r
+                                               </xsl:when>\r
+                                       </xsl:choose>\r
+                               </xsl:if>\r
+\r
+                               <xsl:if test="$typeOf008='SE'">\r
+                                       <xsl:variable name="controlField008-21" select="substring($controlField008,22,1)"/>\r
+                                       <xsl:choose>\r
+                                               <xsl:when test="$controlField008-21='d'">\r
+                                                       <genre authority="marc">database</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-21='l'">       \r
+                                                       <genre authority="marc">loose-leaf</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-21='m'">\r
+                                                       <genre authority="marc">series</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-21='n'">\r
+                                                       <genre authority="marc">newspaper</genre>       \r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-21='p'">\r
+                                                       <genre authority="marc">periodical</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-21='w'">\r
+                                                       <genre authority="marc">web site</genre>\r
+                                               </xsl:when>\r
+                                       </xsl:choose>\r
+                               </xsl:if>\r
+\r
+                               <xsl:if test="$typeOf008='BK' or $typeOf008='SE'">\r
+                                       <xsl:variable name="controlField008-24" select="substring($controlField008,25,4)"/>\r
+                                       <xsl:choose>\r
+                                               <xsl:when test="contains($controlField008-24,'a')">\r
+                                                       <genre authority="marc">abstract or summary</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'b')">\r
+                                                       <genre authority="marc">bibliography</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'c')">\r
+                                                       <genre authority="marc">catalog</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'d')">\r
+                                                       <genre authority="marc">dictionary</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'e')">\r
+                                                       <genre authority="marc">encyclopedia</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'f')">\r
+                                                       <genre authority="marc">handbook</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'g')">\r
+                                                       <genre authority="marc">legal article</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'i')">\r
+                                                       <genre authority="marc">index</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'k')">\r
+                                                       <genre authority="marc">discography</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'l')">\r
+                                                       <genre authority="marc">legislation</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'m')">\r
+                                                       <genre authority="marc">theses</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'n')">\r
+                                                       <genre authority="marc">survey of literature</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'o')">\r
+                                                       <genre authority="marc">review</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'p')">\r
+                                                       <genre authority="marc">programmed text</genre>\r
+                                               </xsl:when>                                     \r
+                                               <xsl:when test="contains($controlField008-24,'q')">\r
+                                                       <genre authority="marc">filmography</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'r')">\r
+                                                       <genre authority="marc">directory</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'s')">\r
+                                                       <genre authority="marc">statistics</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'t')">\r
+                                                       <genre authority="marc">technical report</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'v')">\r
+                                                       <genre authority="marc">legal case and case notes</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'w')">\r
+                                                       <genre authority="marc">law report or digest</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="contains($controlField008-24,'z')">\r
+                                                       <genre authority="marc">treaty</genre>\r
+                                               </xsl:when>      \r
+                                       </xsl:choose>\r
+                                       <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"/>\r
+                                       <xsl:choose>\r
+                                               <xsl:when test="$controlField008-29='1'">\r
+                                                       <genre authority="marc">conference publication</genre>\r
+                                               </xsl:when>\r
+                                       </xsl:choose>\r
+                               </xsl:if>\r
+\r
+                               <xsl:if test="$typeOf008='CF'">\r
+                                       <xsl:variable name="controlField008-26" select="substring($controlField008,27,1)"/>\r
+                                       <xsl:choose>\r
+                                               <xsl:when test="$controlField008-26='a'">\r
+                                                       <genre authority="marc">numeric data</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-26='e'">\r
+                                                       <genre authority="marc">database</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-26='f'">\r
+                                                       <genre authority="marc">font</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-26='g'">\r
+                                                       <genre authority="marc">game</genre>\r
+                                               </xsl:when>\r
+                                       </xsl:choose>\r
+                               </xsl:if>\r
+\r
+                               <xsl:if test="$typeOf008='BK'">\r
+                                       <xsl:if test="substring($controlField008,25,1)='j'">\r
+                                               <genre authority="marc">patent</genre>\r
+                                       </xsl:if>\r
+                                       <xsl:if test="substring($controlField008,31,1)='1'">\r
+                                               <genre authority="marc">festschrift</genre>\r
+                                       </xsl:if>\r
+\r
+                                       <xsl:variable name="controlField008-34" select="substring($controlField008,35,1)"/>\r
+                                       <xsl:if test="$controlField008-34='a' or $controlField008-34='b' or $controlField008-34='c' or $controlField008-34='d'">\r
+                                               <genre authority="marc">biography</genre>\r
+                                       </xsl:if>\r
+\r
+                                       <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"/>\r
+                                       <xsl:choose>\r
+                                               <xsl:when test="$controlField008-33='e'">\r
+                                                       <genre authority="marc">essay</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='d'">\r
+                                                       <genre authority="marc">drama</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='c'">\r
+                                                       <genre authority="marc">comic strip</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='l'">\r
+                                                       <genre authority="marc">fiction</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='h'">\r
+                                                       <genre authority="marc">humor, satire</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='i'">\r
+                                                       <genre authority="marc">letter</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='f'">\r
+                                                       <genre authority="marc">novel</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='j'">\r
+                                                       <genre authority="marc">short story</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='s'">\r
+                                                       <genre authority="marc">speech</genre>\r
+                                               </xsl:when>\r
+                                       </xsl:choose>\r
+                               </xsl:if>\r
+\r
+                               <xsl:if test="$typeOf008='MU'">\r
+                                       <xsl:variable name="controlField008-30-31" select="substring($controlField008,31,2)"/>\r
+                                       <xsl:if test="contains($controlField008-30-31,'b')">\r
+                                               <genre authority="marc">biography</genre>\r
+                                       </xsl:if>\r
+                                       <xsl:if test="contains($controlField008-30-31,'c')">\r
+                                               <genre authority="marc">conference publication</genre>\r
+                                       </xsl:if>\r
+                                       <xsl:if test="contains($controlField008-30-31,'d')">\r
+                                               <genre authority="marc">drama</genre>\r
+                                       </xsl:if>\r
+                                       <xsl:if test="contains($controlField008-30-31,'e')">\r
+                                               <genre authority="marc">essay</genre>\r
+                                       </xsl:if>\r
+                                       <xsl:if test="contains($controlField008-30-31,'f')">\r
+                                               <genre authority="marc">fiction</genre>\r
+                                       </xsl:if>\r
+                                       <xsl:if test="contains($controlField008-30-31,'o')">\r
+                                               <genre authority="marc">folktale</genre>\r
+                                       </xsl:if>\r
+                                       <xsl:if test="contains($controlField008-30-31,'h')">\r
+                                               <genre authority="marc">history</genre>\r
+                                       </xsl:if>\r
+                                       <xsl:if test="contains($controlField008-30-31,'k')">\r
+                                               <genre authority="marc">humor, satire</genre>\r
+                                       </xsl:if>\r
+                                       <xsl:if test="contains($controlField008-30-31,'m')">\r
+                                               <genre authority="marc">memoir</genre>\r
+                                       </xsl:if>\r
+                                       <xsl:if test="contains($controlField008-30-31,'p')">\r
+                                               <genre authority="marc">poetry</genre>\r
+                                       </xsl:if>\r
+                                       <xsl:if test="contains($controlField008-30-31,'r')">\r
+                                               <genre authority="marc">rehersal</genre>\r
+                                       </xsl:if>\r
+                                       <xsl:if test="contains($controlField008-30-31,'g')">\r
+                                               <genre authority="marc">reporting</genre>\r
+                                       </xsl:if>\r
+                                       <xsl:if test="contains($controlField008-30-31,'s')">\r
+                                               <genre authority="marc">sound</genre>\r
+                                       </xsl:if>\r
+                                       <xsl:if test="contains($controlField008-30-31,'l')">\r
+                                               <genre authority="marc">speech</genre>\r
+                                       </xsl:if>\r
+                               </xsl:if>\r
+\r
+                               <xsl:if test="$typeOf008='VM'">\r
+                                       <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"/>\r
+                                       <xsl:choose>\r
+                                               <xsl:when test="$controlField008-33='a'">\r
+                                                       <genre authority="marc">art original</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='b'">\r
+                                                       <genre authority="marc">kit</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='c'">\r
+                                                       <genre authority="marc">art reproduction</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='d'">\r
+                                                       <genre authority="marc">diorama</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='f'">\r
+                                                       <genre authority="marc">filmstrip</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='g'">\r
+                                                       <genre authority="marc">legal article</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='i'">\r
+                                                       <genre authority="marc">picture</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='k'">\r
+                                                       <genre authority="marc">graphic</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='l'">\r
+                                                       <genre authority="marc">technical drawing</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='m'">\r
+                                                       <genre authority="marc">motion picture</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='n'">\r
+                                                       <genre authority="marc">chart</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='o'">\r
+                                                       <genre authority="marc">flash card</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='p'">\r
+                                                       <genre authority="marc">microscope slide</genre>\r
+                                               </xsl:when>                                     \r
+                                               <xsl:when test="$controlField008-33='q' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">\r
+                                                       <genre authority="marc">model</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='r'">\r
+                                                       <genre authority="marc">realia</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='s'">\r
+                                                       <genre authority="marc">slide</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='t'">\r
+                                                       <genre authority="marc">transparency</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='v'">\r
+                                                       <genre authority="marc">videorecording</genre>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="$controlField008-33='w'">\r
+                                                       <genre authority="marc">toy</genre>\r
+                                               </xsl:when> \r
+                                       </xsl:choose>\r
+                               </xsl:if>\r
+\r
+                               <xsl:for-each select="marc:datafield[@tag=655]">\r
+                                       <genre authority="marc">\r
+                                               <xsl:attribute name="authority">\r
+                                                       <xsl:value-of select="marc:subfield[@code='2']"/>\r
+                                               </xsl:attribute>\r
+                                               <xsl:call-template name="subfieldSelect">\r
+                                                       <xsl:with-param name="codes">abvxyz</xsl:with-param>\r
+                                                       <xsl:with-param name="delimeter">-</xsl:with-param>\r
+                                               </xsl:call-template>\r
+                                       </genre>\r
+                               </xsl:for-each>\r
+\r
+                       <publicationInfo>\r
+                               <xsl:variable name="MARCpublicationCode" select="normalize-space(substring($controlField008,16,3))"/>\r
+                               \r
+                               <xsl:if test="translate($MARCpublicationCode,'|','')">\r
+                                       <placeCode authority="marc">\r
+                                               <xsl:value-of select="$MARCpublicationCode"/>\r
+                                       </placeCode>\r
+                               </xsl:if>\r
+                       \r
+                               <xsl:for-each select="marc:datafield[@tag=044]/marc:subfield[@code='c']">\r
+                                       <placeCode authority="iso3166">\r
+                                               <xsl:value-of select="."/>\r
+                                       </placeCode>\r
+                               </xsl:for-each>\r
+\r
+                               <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='a' or @code='b' or @code='c' or @code='g']">\r
+                                       <xsl:choose>\r
+                                               <xsl:when test="@code='a'">\r
+                                                       <place>\r
+                                                               <xsl:call-template name="chopPunctuation">\r
+                                                                       <xsl:with-param name="chopString" select="."/>\r
+                                                               </xsl:call-template>\r
+                                                       </place>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="@code='b'">\r
+                                                       <publisher>\r
+                                                               <xsl:call-template name="chopPunctuation">\r
+                                                                       <xsl:with-param name="chopString" select="."/>\r
+                                                               </xsl:call-template>\r
+                                                       </publisher>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="@code='c'">\r
+                                                       <dateIssued>\r
+                                                               <xsl:call-template name="chopPunctuation">\r
+                                                                       <xsl:with-param name="chopString" select="."/>\r
+                                                               </xsl:call-template>\r
+                                                       </dateIssued>\r
+                                               </xsl:when>\r
+                                               <xsl:when test="@code='g'">\r
+                                                       <dateCreated>\r
+                                                               <xsl:value-of select="."/>\r
+                                                       </dateCreated>                  \r
+                                               </xsl:when>\r
+                                       </xsl:choose>\r
+                               </xsl:for-each>\r
+\r
+                               <xsl:variable name="dataField260c">\r
+                                       <xsl:call-template name="chopPunctuation">\r
+                                               <xsl:with-param name="chopString" select="marc:datafield[@tag=260]/marc:subfield[@code='c']"/>\r
+                                       </xsl:call-template>\r
+                               </xsl:variable>\r
+\r
+                               <xsl:variable name="controlField008-7-10" select="normalize-space(substring($controlField008, 8, 4))"/>\r
+                               <xsl:variable name="controlField008-11-14" select="normalize-space(substring($controlField008, 12, 4))"/>\r
+                               <xsl:variable name="controlField008-6" select="normalize-space(substring($controlField008, 7, 1))"/>\r
+               \r
+                               <xsl:if test="$controlField008-6='e' or $controlField008-6='p' or $controlField008-6='r' or $controlField008-6='t' or $controlField008-6='s'">\r
+                                       <xsl:if test="$controlField008-7-10 and ($controlField008-7-10 != $dataField260c)">\r
+                                               <dateIssued encoding="marc">\r
+                                                       <xsl:value-of select="$controlField008-7-10"/>\r
+                                               </dateIssued>\r
+                                       </xsl:if>\r
+                               </xsl:if>\r
+               \r
+                               <xsl:if test="$controlField008-6='c' or $controlField008-6='d' or $controlField008-6='i' or $controlField008-6='k' or $controlField008-6='m' or $controlField008-6='q' or $controlField008-6='u'">\r
+                                       <xsl:if test="$controlField008-7-10">\r
+                                               <dateIssued encoding="marc" point="start">\r
+                                                       <xsl:value-of select="$controlField008-7-10"/>\r
+                                               </dateIssued>\r
+                                       </xsl:if>\r
+                               </xsl:if>\r
+\r
+                               <xsl:if test="$controlField008-6='c' or $controlField008-6='d' or $controlField008-6='i' or $controlField008-6='k' or $controlField008-6='m' or $controlField008-6='q' or $controlField008-6='u'">\r
+                                       <xsl:if test="$controlField008-11-14">\r
+                                               <dateIssued encoding="marc" point="end">\r
+                                                       <xsl:value-of select="$controlField008-11-14"/>\r
+                                               </dateIssued>\r
+                                       </xsl:if>\r
+                               </xsl:if>\r
+\r
+                               <xsl:for-each select="marc:datafield[@tag=033][@ind1=0 or @ind1=1]/marc:subfield[@code='a']">\r
+                                       <dateCaptured encoding="iso8601">\r
+                                               <xsl:value-of select="."/>\r
+                                       </dateCaptured>\r
+                               </xsl:for-each>\r
+\r
+                               <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][1]">\r
+                                       <dateCaptured encoding="iso8601" point="start">\r
+                                               <xsl:value-of select="."/>\r
+                                       </dateCaptured>\r
+                               </xsl:for-each>\r
+\r
+                               <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][2]">\r
+                                       <dateCaptured encoding="iso8601" point="end">\r
+                                               <xsl:value-of select="."/>\r
+                                       </dateCaptured>\r
+                               </xsl:for-each>\r
+\r
+                               <xsl:for-each select="marc:datafield[@tag=250]/marc:subfield[@code='a']">\r
+                                       <edition>\r
+                                               <xsl:value-of select="."/>\r
+                                       </edition>\r
+                               </xsl:for-each>\r
+\r
+                               <xsl:for-each select="marc:leader">\r
+                                       <issuance>\r
+                                               <xsl:choose>\r
+                                                       <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">monographic</xsl:when>\r
+                                                       <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">continuing</xsl:when>                                                     \r
+                                               </xsl:choose>\r
+                                       </issuance>\r
+                               </xsl:for-each>         \r
+                               \r
+                               <xsl:for-each select="marc:datafield[@tag=310]|marc:datafield[@tag=321]">\r
+                                       <frequency>\r
+                                               <xsl:call-template name="subfieldSelect">\r
+                                                       <xsl:with-param name="codes">ab</xsl:with-param>\r
+                                               </xsl:call-template>\r
+                                       </frequency>\r
+                               </xsl:for-each>                                                         \r
+                       </publicationInfo>\r
+\r
+\r
+                       <xsl:for-each select="marc:controlfield[@tag=041]">\r
+                               <xsl:for-each select="marc:subfield[@code='a' or @code='d' or @code='e']">\r
+                                       <language>\r
+                                               <xsl:choose>\r
+                                                       <xsl:when test="../marc:subfield[@code='2']">\r
+                                                               <xsl:attribute name="authority">rfc3066</xsl:attribute>\r
+                                                       </xsl:when>\r
+                                                       <xsl:otherwise>\r
+                                                               <xsl:attribute name="authority">iso639-2b</xsl:attribute>                                               \r
+                                                       </xsl:otherwise>\r
+                                               </xsl:choose>\r
+                                               <xsl:value-of select="text()"/>\r
+                                       </language>\r
+                               </xsl:for-each>\r
+                       </xsl:for-each>                 \r
+\r
+                       <xsl:variable name="controlField008-35-37" select="normalize-space(translate(substring($controlField008,36,3),'|#',''))"/>\r
+                       <xsl:if test="$controlField008-35-37">\r
+                               <language authority="iso639-2b">\r
+                                       <xsl:value-of select="substring($controlField008,36,3)"/>\r
+                               </language>\r
+                       </xsl:if>\r
+\r
+                       <xsl:variable name="physicalDescription">\r
+                               <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='a' or substring(.,12,1)='b']">\r
+                                       <digitalOrigin>reformatted digital</digitalOrigin>\r
+                               </xsl:if>\r
+\r
+                               <xsl:variable name="controlField008-23" select="substring($controlField008,24,1)"/>\r
+                               <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"/>\r
+\r
+                               <xsl:variable name="check008-23">\r
+                                       <xsl:if test="$typeOf008='BK' or $typeOf008='MU' or $typeOf008='SE' or $typeOf008='MM'">\r
+                                               <xsl:value-of select="true()"/>\r
+                                       </xsl:if>\r
+                               </xsl:variable>\r
+\r
+                               <xsl:variable name="check008-29">\r
+                                       <xsl:if test="$typeOf008='MP' or $typeOf008='VM'">\r
+                                               <xsl:value-of select="true()"/>\r
+                                       </xsl:if>\r
+                               </xsl:variable>\r
+\r
+                               <xsl:choose>\r
+                                       <xsl:when test="($check008-23 and $controlField008-23='f') or ($check008-29 and $controlField008-29='f')">\r
+                                               <form><controlled>braille</controlled></form>\r
+                                       </xsl:when>\r
+                                       <xsl:when test="$leader6 = 'm' or ($check008-23 and $controlField008-23='s') or ($check008-29 and $controlField008-29='s')">\r
+                                               <form><controlled>electronic</controlled></form>\r
+                                       </xsl:when>\r
+                                       <xsl:when test="($check008-23 and $controlField008-23='b') or ($check008-29 and $controlField008-29='b')">\r
+                                               <form><controlled>microfiche</controlled></form>\r
+                                       </xsl:when>\r
+                                       <xsl:when test="($check008-23 and $controlField008-23='a') or ($check008-29 and $controlField008-29='a')">\r
+                                               <form><controlled>microfilm</controlled></form>\r
+                                       </xsl:when>\r
+                               </xsl:choose>\r
+\r
+                               <xsl:for-each select="marc:datafield[@tag=856]/marc:subfield[@code='q'][string-length(.)>1]">\r
+                                       <internetMediaType>\r
+                                               <xsl:value-of select="."/>\r
+                                       </internetMediaType>\r
+                               </xsl:for-each>\r
+\r
+                               <xsl:for-each select="marc:datafield[@tag=256]/marc:subfield[@code='a']">\r
+                                       <form>\r
+                                               <unControlled>\r
+                                                       <xsl:value-of select="."/>\r
+                                               </unControlled>\r
+                                       </form>\r
+                               </xsl:for-each>\r
+\r
+                               <xsl:for-each select="marc:datafield[@tag=300]">\r
+                                       <extent>\r
+                                               <xsl:call-template name="subfieldSelect">\r
+                                                       <xsl:with-param name="codes">abce</xsl:with-param>\r
+                                               </xsl:call-template>\r
+                                       </extent>\r
+                               </xsl:for-each>\r
+                       </xsl:variable>\r
+\r
+                       <xsl:if test="string-length(normalize-space($physicalDescription))">\r
+                               <physicalDescription>\r
+                                       <xsl:copy-of select="$physicalDescription"/>\r
+                               </physicalDescription>\r
+                       </xsl:if>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=520]">\r
+                               <abstract>\r
+                                       <xsl:call-template name="uri"/>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">ab</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </abstract>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=505]">\r
+                               <tableOfContents>\r
+                                       <xsl:call-template name="uri"/>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">agrt</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </tableOfContents>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=521]">\r
+                               <targetAudience>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">ab</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </targetAudience>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:if test="$typeOf008='BK' or $typeOf008='CF' or $typeOf008='MU' or $typeOf008='VM'">\r
+                               <xsl:variable name="controlField008-22" select="substring($controlField008,23,1)"/>\r
+                               <xsl:choose>\r
+                                       <xsl:when test="$controlField008-22='d'">\r
+                                               <targetAudience>adolescent</targetAudience>\r
+                                       </xsl:when>\r
+                                       <xsl:when test="$controlField008-22='e'">\r
+                                               <targetAudience>adult</targetAudience>\r
+                                       </xsl:when>\r
+                                       <xsl:when test="$controlField008-22='g'">\r
+                                               <targetAudience>general</targetAudience>\r
+                                       </xsl:when>\r
+                                       <xsl:when test="$controlField008-22='b' or $controlField008-22='c' or $controlField008-22='j'">\r
+                                               <targetAudience>juvenile</targetAudience>\r
+                                       </xsl:when>\r
+                                       <xsl:when test="$controlField008-22='a'">\r
+                                               <targetAudience>preschool</targetAudience>\r
+                                       </xsl:when>\r
+                                       <xsl:when test="$controlField008-22='f'">\r
+                                               <targetAudience>specialized</targetAudience>\r
+                                       </xsl:when>\r
+                               </xsl:choose>\r
+                       </xsl:if>\r
+\r
+                       <!-- Not in mapping but in conversion -->\r
+                       <xsl:for-each select="marc:datafield[@tag=245]/marc:subfield[@code='c']">\r
+                               <note type="statement of responsibility">\r
+                                       <xsl:value-of select="."/>\r
+                               </note>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=500]">\r
+                               <note>\r
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                                       <xsl:call-template name="uri"/>\r
+                               </note>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=511]">\r
+                               <note type="performers">\r
+                                       <xsl:call-template name="uri"/>\r
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                               </note>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=518]">\r
+                               <note type="venue">\r
+                                       <xsl:call-template name="uri"/>\r
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                               </note>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=501 or @tag=502 or @tag=504 or @tag=506 or @tag=507 or @tag=508 or @tag=510 or @tag=513 or @tag=514 or @tag=515 or @tag=516 or @tag=522 or @tag=524 or @tag=525 or @tag=526 or @tag=530 or @tag=533 or @tag=534 or @tag=535 or @tag=536 or @tag=538 or @tag=540 or @tag=541 or @tag=544 or @tag=545 or @tag=546 or @tag=547 or @tag=550 or @tag=552 or @tag=555 or @tag=556 or @tag=561 or @tag=562 or @tag=565 or @tag=567 or @tag=580 or @tag=581 or @tag=583 or @tag=584 or @tag=585 or @tag=586]">\r
+                               <note>\r
+                                       <xsl:call-template name="uri"/>\r
+                                       <xsl:variable name="str">\r
+                                               <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">\r
+                                                       <xsl:value-of select="."/><xsl:text> </xsl:text>\r
+                                               </xsl:for-each>\r
+                                       </xsl:variable>\r
+                                       <xsl:value-of select="substring($str,1,string-length($str)-1)"/>\r
+                               </note>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=034][marc:subfield[@code='d' or @code='e' or @code='f' or @code='g']]">\r
+                               <cartographics>\r
+                                       <coordinates>\r
+                                               <xsl:call-template name="subfieldSelect">\r
+                                                       <xsl:with-param name="codes">defg</xsl:with-param>\r
+                                               </xsl:call-template>\r
+                                       </coordinates>\r
+                               </cartographics>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=255]">\r
+                               <cartographics>\r
+                                       <xsl:for-each select="marc:subfield[@code='c']">\r
+                                               <coordinates>\r
+                                                       <xsl:value-of select="."/>\r
+                                               </coordinates>\r
+                                       </xsl:for-each>\r
+                                       <xsl:for-each select="marc:subfield[@code='a']">\r
+                                               <scale>\r
+                                                       <xsl:value-of select="."/>\r
+                                               </scale>\r
+                                       </xsl:for-each>\r
+                                       <xsl:for-each select="marc:subfield[@code='b']">\r
+                                               <projection>\r
+                                                       <xsl:value-of select="."/>\r
+                                               </projection>   \r
+                                       </xsl:for-each>\r
+                               </cartographics>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:apply-templates select="marc:datafield[653 >= @tag and @tag >= 600]"/>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=752]">\r
+                               <subject>\r
+                                       <hierarchicalGeographic>\r
+                                               <xsl:for-each select="marc:subfield[@code='a']">\r
+                                                       <country>\r
+                                                               <xsl:value-of select="."/>\r
+                                                       </country>\r
+                                               </xsl:for-each>         \r
+                                               <xsl:for-each select="marc:subfield[@code='b']">\r
+                                                       <state>\r
+                                                               <xsl:value-of select="."/>\r
+                                                       </state>\r
+                                               </xsl:for-each>         \r
+                                               <xsl:for-each select="marc:subfield[@code='c']">\r
+                                                       <county>\r
+                                                               <xsl:value-of select="."/>\r
+                                                       </county>\r
+                                               </xsl:for-each>         \r
+                                               <xsl:for-each select="marc:subfield[@code='d']">\r
+                                                       <city>\r
+                                                               <xsl:value-of select="."/>\r
+                                                       </city>\r
+                                               </xsl:for-each>         \r
+                                       </hierarchicalGeographic>\r
+                               </subject>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=050]">\r
+                               <xsl:for-each select="marc:subfield[@code='b']">\r
+                                       <classification authority="lcc">\r
+                                               <xsl:value-of select="preceding-sibling::marc:subfield[@code='a'][1]"/>\r
+                                               <xsl:text> </xsl:text>\r
+                                               <xsl:value-of select="text()"/>\r
+                                       </classification>\r
+                               </xsl:for-each>\r
+                               <xsl:for-each select="marc:subfield[@code='a'][not(following-sibling::marc:subfield[@code='b'])]">\r
+                                       <classification authority="lcc">\r
+                                               <xsl:value-of select="text()"/>\r
+                                       </classification>\r
+                               </xsl:for-each>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=082]">\r
+                               <classification authority="ddc">\r
+                                       <xsl:if test="marc:subfield[@code='2']">\r
+                                               <xsl:attribute name="edition">\r
+                                                       <xsl:value-of select="marc:subfield[@code='2']"/>\r
+                                               </xsl:attribute>\r
+                                       </xsl:if>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">ab</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </classification>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=080]">\r
+                               <classification authority="udc">\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abx</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </classification>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=060]">\r
+                               <classification authority="nlm">\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">ab</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </classification>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=086][@ind1=0]">\r
+                               <classification authority="sudocs">\r
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                               </classification>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=086][@ind1=1]">\r
+                               <classification authority="candoc">\r
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                               </classification>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=086]">\r
+                               <classification>\r
+                                       <xsl:attribute name="authority">\r
+                                               <xsl:value-of select="marc:subfield[@code='2']"/>\r
+                                       </xsl:attribute>                                                \r
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                               </classification>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=084]">\r
+                               <classification>\r
+                                       <xsl:attribute name="authority">\r
+                                               <xsl:value-of select="marc:subfield[@code='2']"/>\r
+                                       </xsl:attribute>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">ab</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </classification>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=440]">\r
+                               <relatedItem type="series">\r
+                                       <titleInfo>\r
+                                               <title>\r
+                                                       <xsl:call-template name="subfieldSelect">\r
+                                                               <xsl:with-param name="codes">av</xsl:with-param>\r
+                                                       </xsl:call-template>\r
+                                                       <xsl:call-template name="part"/>\r
+                                               </title>\r
+                                       </titleInfo>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">\r
+                               <relatedItem type="series">\r
+                                       <titleInfo>\r
+                                               <title>\r
+                                                       <xsl:call-template name="subfieldSelect">\r
+                                                               <xsl:with-param name="codes">av</xsl:with-param>\r
+                                                       </xsl:call-template>\r
+                                                       <xsl:call-template name="part"/>\r
+                                               </title>\r
+                                       </titleInfo>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=534]">\r
+                               <relatedItem type="original">\r
+                                       <xsl:call-template name="relatedTitle"/>\r
+                                       <xsl:call-template name="relatedName"/>\r
+                                       <xsl:call-template name="relatedIdentifierISSN"/>\r
+                                       <xsl:for-each select="marc:subfield[@code='z']">\r
+                                               <identifier type="isbn">\r
+                                                       <xsl:value-of select="."/>\r
+                                               </identifier>\r
+                                       </xsl:for-each>\r
+                                       <xsl:call-template name="relatedNote"/>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=700][marc:subfield[@code='t']]">\r
+                               <relatedItem>\r
+                                       <xsl:call-template name="constituentOrRelatedType"/>\r
+                                       <titleInfo>\r
+                                               <title>\r
+                                                       <xsl:call-template name="specialSubfieldSelect">\r
+                                                               <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>\r
+                                                               <xsl:with-param name="axis">t</xsl:with-param>\r
+                                                               <xsl:with-param name="afterCodes">g</xsl:with-param>\r
+                                                       </xsl:call-template>\r
+                                               </title>\r
+                                               <xsl:call-template name="part"/>\r
+                                       </titleInfo>\r
+                                       <name type="personal">\r
+                                               <namePart>\r
+                                                       <xsl:call-template name="specialSubfieldSelect">\r
+                                                               <xsl:with-param name="anyCodes">abcq</xsl:with-param>\r
+                                                               <xsl:with-param name="axis">t</xsl:with-param>\r
+                                                               <xsl:with-param name="beforeCodes">g</xsl:with-param>\r
+                                                       </xsl:call-template>                                                    \r
+                                               </namePart>\r
+                                               <xsl:call-template name="nameDate"/>\r
+                                               <xsl:for-each select="marc:subfield[@code='e']">\r
+                                                       <role>\r
+                                                               <xsl:value-of select="."/>\r
+                                                       </role>\r
+                                               </xsl:for-each>\r
+                                       </name>\r
+                                       <xsl:call-template name="relatedForm"/>\r
+                                       <xsl:call-template name="relatedIdentifierISSN"/>\r
+                               </relatedItem>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=710][marc:subfield[@code='t']]">\r
+                               <relatedItem>\r
+                                       <xsl:call-template name="constituentOrRelatedType"/>\r
+                                       <titleInfo>\r
+                                               <title>\r
+                                                       <xsl:call-template name="specialSubfieldSelect">\r
+                                                               <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>\r
+                                                               <xsl:with-param name="axis">t</xsl:with-param>\r
+                                                               <xsl:with-param name="afterCodes">dg</xsl:with-param>\r
+                                                       </xsl:call-template>\r
+                                               </title>\r
+                                               <xsl:call-template name="relatedPart"/>\r
+                                       </titleInfo>\r
+                                       <name type="corporate">\r
+                                               <xsl:for-each select="marc:subfield[@code='a']">\r
+                                                       <namePart>\r
+                                                               <xsl:value-of select="."/>\r
+                                                       </namePart>\r
+                                               </xsl:for-each>\r
+                                               <xsl:for-each select="marc:subfield[@code='b']">\r
+                                                       <namePart>\r
+                                                               <xsl:value-of select="."/>\r
+                                                       </namePart>\r
+                                               </xsl:for-each>\r
+                                               <xsl:variable name="tempNamePart">\r
+                                                       <xsl:call-template name="specialSubfieldSelect">\r
+                                                               <xsl:with-param name="anyCodes">c</xsl:with-param>\r
+                                                               <xsl:with-param name="axis">t</xsl:with-param>\r
+                                                               <xsl:with-param name="beforeCodes">dgn</xsl:with-param>\r
+                                                       </xsl:call-template>                                                    \r
+                                               </xsl:variable>\r
+                                               <xsl:if test="normalize-space($tempNamePart)">\r
+                                                       <namePart>\r
+                                                               <xsl:value-of select="$tempNamePart"/>\r
+                                                       </namePart>\r
+                                               </xsl:if>\r
+                                               <xsl:for-each select="marc:subfield[@code='e']">\r
+                                                       <role>\r
+                                                               <xsl:value-of select="."/>\r
+                                                       </role>\r
+                                               </xsl:for-each>\r
+                                       </name>\r
+                                       <xsl:call-template name="relatedForm"/>\r
+                                       <xsl:call-template name="relatedIdentifierISSN"/>\r
+                               </relatedItem>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=711][marc:subfield[@code='t']]">\r
+                               <relatedItem>\r
+                                       <xsl:call-template name="constituentOrRelatedType"/>\r
+                                       <titleInfo>\r
+                                               <title>\r
+                                                       <xsl:call-template name="specialSubfieldSelect">\r
+                                                               <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>\r
+                                                               <xsl:with-param name="axis">t</xsl:with-param>\r
+                                                               <xsl:with-param name="afterCodes">g</xsl:with-param>\r
+                                                       </xsl:call-template>\r
+                                               </title>\r
+                                               <xsl:call-template name="relatedPart"/>\r
+                                       </titleInfo>\r
+                                       <name type="conference">\r
+                                               <namePart>\r
+                                                       <xsl:call-template name="specialSubfieldSelect">\r
+                                                               <xsl:with-param name="anyCodes">aqdc</xsl:with-param>\r
+                                                               <xsl:with-param name="axis">t</xsl:with-param>\r
+                                                               <xsl:with-param name="beforeCodes">gn</xsl:with-param>\r
+                                                       </xsl:call-template>                                                    \r
+                                               </namePart>\r
+                                       </name>\r
+                                       <xsl:call-template name="relatedForm"/>\r
+                                       <xsl:call-template name="relatedIdentifierISSN"/>\r
+                               </relatedItem>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=730][@ind2=2]">\r
+                               <relatedItem>\r
+                                       <xsl:call-template name="constituentOrRelatedType"/>\r
+                                       <titleInfo>\r
+                                               <title>\r
+                                                       <xsl:call-template name="subfieldSelect">\r
+                                                               <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>\r
+                                                       </xsl:call-template>\r
+                                               </title>\r
+                                               <xsl:call-template name="part"/>\r
+                                       </titleInfo>\r
+                                       <xsl:call-template name="relatedForm"/>\r
+                                       <xsl:call-template name="relatedIdentifierISSN"/>\r
+                               </relatedItem>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=740][@ind2=2]">\r
+                               <relatedItem>\r
+                                       <xsl:call-template name="constituentOrRelatedType"/>\r
+                                       <titleInfo>\r
+                                               <title>                                 \r
+                                                       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                                               </title>\r
+                                               <xsl:call-template name="part"/>\r
+                                       </titleInfo>\r
+                                       <xsl:call-template name="relatedForm"/>\r
+                               </relatedItem>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=760]|marc:datafield[@tag=762]">\r
+                               <relatedItem type="series">\r
+                                       <xsl:call-template name="relatedItem76X-78X"/>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=765]|marc:datafield[@tag=767]|marc:datafield[@tag=775]|marc:datafield[@tag=777]|marc:datafield[@tag=787]">\r
+                               <relatedItem type="related">\r
+                                       <xsl:call-template name="relatedItem76X-78X"/>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=770]|marc:datafield[@tag=774]">\r
+                               <relatedItem type="constituent">\r
+                                       <xsl:call-template name="relatedItem76X-78X"/>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=772]|marc:datafield[@tag=773]">\r
+                               <relatedItem type="host">\r
+                                       <xsl:call-template name="relatedItem76X-78X"/>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=776]">\r
+                               <relatedItem type="reproduction">\r
+                                       <xsl:call-template name="relatedItem76X-78X"/>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=780]">\r
+                               <relatedItem type="preceding">\r
+                                       <xsl:call-template name="relatedItem76X-78X"/>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=785]">\r
+                               <relatedItem type="succeeding">\r
+                                       <xsl:call-template name="relatedItem76X-78X"/>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=786]">\r
+                               <relatedItem type="original">\r
+                                       <xsl:call-template name="relatedItem76X-78X"/>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=800]">\r
+                               <relatedItem type="series">\r
+                                       <titleInfo>\r
+                                               <title>\r
+                                                       <xsl:call-template name="specialSubfieldSelect">\r
+                                                               <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>\r
+                                                               <xsl:with-param name="axis">t</xsl:with-param>\r
+                                                               <xsl:with-param name="afterCodes">g</xsl:with-param>\r
+                                                       </xsl:call-template>\r
+                                               </title>\r
+                                               <xsl:call-template name="part"/>\r
+                                       </titleInfo>\r
+                                       <name type="personal">\r
+                                               <namePart>\r
+                                                       <xsl:call-template name="chopPunctuation">\r
+                                                               <xsl:with-param name="chopString">\r
+                                                                       <xsl:call-template name="specialSubfieldSelect">\r
+                                                                               <xsl:with-param name="anyCodes">abcq</xsl:with-param>\r
+                                                                               <xsl:with-param name="axis">t</xsl:with-param>\r
+                                                                               <xsl:with-param name="beforeCodes">g</xsl:with-param>\r
+                                                                       </xsl:call-template>\r
+                                                               </xsl:with-param>\r
+                                                       </xsl:call-template>\r
+                                               </namePart>\r
+                                               <xsl:call-template name="nameDate"/>\r
+                                               <xsl:for-each select="marc:subfield[@code='e']">\r
+                                                       <role>\r
+                                                               <xsl:value-of select="."/>\r
+                                                       </role>\r
+                                               </xsl:for-each>\r
+                                       </name>\r
+                                       <xsl:call-template name="relatedForm"/>\r
+                               </relatedItem>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=810]">\r
+                               <relatedItem type="series">\r
+                                       <titleInfo>\r
+                                               <title>\r
+                                                       <xsl:call-template name="specialSubfieldSelect">\r
+                                                               <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>\r
+                                                               <xsl:with-param name="axis">t</xsl:with-param>\r
+                                                               <xsl:with-param name="afterCodes">dg</xsl:with-param>\r
+                                                       </xsl:call-template>\r
+                                               </title>\r
+                                               <xsl:call-template name="relatedPart"/>\r
+                                       </titleInfo>\r
+                                       <name type="corporate">\r
+                                               <xsl:for-each select="marc:subfield[@code='a']">\r
+                                                       <namePart>\r
+                                                               <xsl:value-of select="."/>\r
+                                                       </namePart>\r
+                                               </xsl:for-each>\r
+                                               <xsl:for-each select="marc:subfield[@code='b']">\r
+                                                       <namePart>\r
+                                                               <xsl:value-of select="."/>\r
+                                                       </namePart>\r
+                                               </xsl:for-each>\r
+                                               <namePart>\r
+                                                       <xsl:call-template name="specialSubfieldSelect">\r
+                                                               <xsl:with-param name="anyCodes">c</xsl:with-param>\r
+                                                               <xsl:with-param name="axis">t</xsl:with-param>\r
+                                                               <xsl:with-param name="beforeCodes">dgn</xsl:with-param>\r
+                                                       </xsl:call-template>                                                    \r
+                                               </namePart>\r
+                                               <xsl:for-each select="marc:subfield[@code='e']">\r
+                                                       <role>\r
+                                                               <xsl:value-of select="."/>\r
+                                                       </role>\r
+                                               </xsl:for-each>\r
+                                       </name>\r
+                                       <xsl:call-template name="relatedForm"/>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=811]">\r
+                               <relatedItem type="series">\r
+                                       <titleInfo>\r
+                                               <title>\r
+                                                       <xsl:call-template name="specialSubfieldSelect">\r
+                                                               <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>\r
+                                                               <xsl:with-param name="axis">t</xsl:with-param>\r
+                                                               <xsl:with-param name="afterCodes">g</xsl:with-param>\r
+                                                       </xsl:call-template>\r
+                                               </title>\r
+                                               <xsl:call-template name="relatedPart"/>\r
+                                       </titleInfo>\r
+                                       <name type="conference">\r
+                                               <namePart>\r
+                                                       <xsl:call-template name="specialSubfieldSelect">\r
+                                                               <xsl:with-param name="anyCodes">aqdc</xsl:with-param>\r
+                                                               <xsl:with-param name="axis">t</xsl:with-param>\r
+                                                               <xsl:with-param name="beforeCodes">gn</xsl:with-param>\r
+                                                       </xsl:call-template>                                                    \r
+                                               </namePart>\r
+                                       </name>\r
+                                       <xsl:call-template name="relatedForm"/>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=830]">\r
+                               <relatedItem type="series">\r
+                                       <titleInfo>\r
+                                               <title>\r
+                                                       <xsl:call-template name="subfieldSelect">\r
+                                                               <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>\r
+                                                       </xsl:call-template>\r
+                                               </title>\r
+                                               <xsl:call-template name="part"/>\r
+                                       </titleInfo>\r
+                                       <xsl:call-template name="relatedForm"/>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=856][@ind2=2]/marc:subfield[@code='q']">\r
+                               <relatedItem>\r
+                                       <internetMediaType>\r
+                                               <xsl:value-of select="."/>\r
+                                       </internetMediaType>\r
+                               </relatedItem>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=020]/marc:subfield[@code='a']">\r
+                               <identifier type="isbn">\r
+                                       <xsl:value-of select="."/>\r
+                               </identifier>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=024][@ind1=0]/marc:subfield[@code='a']">\r
+                               <identifier type="isrc">\r
+                                       <xsl:value-of select="."/>\r
+                               </identifier>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=024][@ind1=2]/marc:subfield[@code='a']">\r
+                               <identifier type="ismn">\r
+                                       <xsl:value-of select="."/>\r
+                               </identifier>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=022]/marc:subfield[@code='a']">\r
+                               <identifier type="issn">\r
+                                       <xsl:value-of select="."/>\r
+                               </identifier>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=010]/marc:subfield[@code='a']">\r
+                               <identifier type="lccn">\r
+                                       <xsl:value-of select="normalize-space(text())"/>\r
+                               </identifier>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=028]">\r
+                               <identifier>\r
+                                       <xsl:attribute name="type">\r
+                                               <xsl:choose>\r
+                                                       <xsl:when test="@ind1=0">issue number</xsl:when>\r
+                                                       <xsl:when test="@ind1=1">matrix number</xsl:when>\r
+                                                       <xsl:when test="@ind1=2">music plate</xsl:when>\r
+                                                       <xsl:when test="@ind1=3">music publisher</xsl:when>\r
+                                                       <xsl:when test="@ind1=4">videorecording identifier</xsl:when>\r
+                                               </xsl:choose>\r
+                                       </xsl:attribute>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">ab</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </identifier>\r
+                       </xsl:for-each>\r
+               \r
+                       <xsl:for-each select="marc:datafield[@tag=024][@ind1=4]">\r
+                               <identifier type="sici">\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">ab</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </identifier>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=856]/marc:subfield[@code='u']">\r
+                               <identifier>\r
+                                       <xsl:attribute name="type">\r
+                                               <xsl:choose>\r
+                                                       <xsl:when test="starts-with(.,'urn:doi') or starts-with(.,'doi:')">doi</xsl:when>\r
+                                                       <xsl:otherwise>uri</xsl:otherwise>\r
+                                               </xsl:choose>\r
+                                       </xsl:attribute>\r
+                                       <xsl:value-of select="."/>\r
+                               </identifier>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=024][@ind1=1]/marc:subfield[@code='a']">\r
+                               <identifier type="upc">\r
+                                       <xsl:value-of select="."/>\r
+                               </identifier>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=852]">\r
+                               <location>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abj</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </location>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=506]">\r
+                               <accessCondition type="restrictionOnAccess">\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abcd35</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </accessCondition>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=540]">\r
+                               <accessCondition type="useAndReproduction">\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abcde35</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </accessCondition>\r
+                       </xsl:for-each>\r
+\r
+                       <recordInfo>\r
+                               <xsl:for-each select="marc:datafield[@tag=040]">\r
+                                       <recordContentSource>\r
+                                               <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                                       </recordContentSource>\r
+                               </xsl:for-each>\r
+\r
+                               <xsl:for-each select="marc:controlfield[@tag=008]">\r
+                                       <recordCreationDate encoding="marc">\r
+                                               <xsl:value-of select="substring(.,1,6)"/>\r
+                                       </recordCreationDate>\r
+                               </xsl:for-each>         \r
+                       \r
+                               <xsl:for-each select="marc:controlfield[@tag=005]">\r
+                                       <recordChangeDate encoding="iso8601">\r
+                                               <xsl:value-of select="."/>\r
+                                       </recordChangeDate>\r
+                               </xsl:for-each>\r
+\r
+                               <xsl:for-each select="marc:controlfield[@tag=001]">\r
+                                       <recordIdentifier>\r
+                                               <xsl:if test="../marc:controlfield[@tag=003]">\r
+                                                       <xsl:attribute name="source">\r
+                                                               <xsl:value-of select="../marc:controlfield[@tag=003]"/>\r
+                                                       </xsl:attribute>\r
+                                               </xsl:if>\r
+                                               <xsl:value-of select="."/>\r
+                                       </recordIdentifier>\r
+                               </xsl:for-each>\r
+                       </recordInfo>\r
+               </mods>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="displayForm">\r
+               <xsl:for-each select="marc:subfield[@code='c']">\r
+                       <displayForm>\r
+                               <xsl:value-of select="."/>\r
+                       </displayForm>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="affiliation">\r
+               <xsl:for-each select="marc:subfield[@code='u']">\r
+                       <affiliation>\r
+                               <xsl:value-of select="."/>\r
+                       </affiliation>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="uri">\r
+               <xsl:for-each select="marc:subfield[@code='u']">\r
+                       <xsl:attribute name="xlink:href">\r
+                               <xsl:value-of select="."/>\r
+                       </xsl:attribute>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="role">\r
+               <xsl:choose>\r
+                       <xsl:when test="marc:subfield[@code='e']">\r
+                               <role><xsl:value-of select="marc:subfield[@code='e']"/></role>\r
+                       </xsl:when>\r
+                       <xsl:when test="marc:subfield[@code='4']">\r
+                               <xsl:for-each select="marc:subfield[@code='4']">\r
+                                       <role><xsl:value-of select="text()"/></role>\r
+                               </xsl:for-each>\r
+                       </xsl:when>\r
+               </xsl:choose>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="part">\r
+               <xsl:variable name="partNumber">\r
+                       <xsl:call-template name="specialSubfieldSelect">\r
+                               <xsl:with-param name="axis">n</xsl:with-param>\r
+                               <xsl:with-param name="anyCodes">n</xsl:with-param>\r
+                               <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>\r
+                       </xsl:call-template>\r
+               </xsl:variable>\r
+               <xsl:variable name="partName">\r
+                       <xsl:call-template name="specialSubfieldSelect">\r
+                               <xsl:with-param name="axis">p</xsl:with-param>\r
+                               <xsl:with-param name="anyCodes">p</xsl:with-param>\r
+                               <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>\r
+                       </xsl:call-template>\r
+               </xsl:variable>\r
+               <xsl:if test="string-length(normalize-space($partNumber))">\r
+                       <partNumber>\r
+                               <xsl:value-of select="$partNumber"/>\r
+                       </partNumber>\r
+               </xsl:if>\r
+               <xsl:if test="string-length(normalize-space($partName))">\r
+                       <partName>\r
+                               <xsl:value-of select="$partName"/>\r
+                       </partName>\r
+               </xsl:if>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="relatedPart">\r
+               <xsl:for-each select="marc:subfield[@code='n'][preceding-sibling::marc:subfield[@code='t']]">\r
+                       <partNumber>\r
+                               <xsl:value-of select="."/>\r
+                       </partNumber>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:subfield[@code='p']">\r
+                       <partName>\r
+                               <xsl:value-of select="."/>\r
+                       </partName>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="relatedName">\r
+               <xsl:for-each select="marc:subfield[@code='a']">\r
+                       <name>\r
+                               <namePart>\r
+                                       <xsl:value-of select="."/>\r
+                               </namePart>\r
+                       </name>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="relatedForm">\r
+               <xsl:for-each select="marc:subfield[@code='h']">\r
+                       <physicalDescription>\r
+                               <form>\r
+                                       <unControlled>\r
+                                               <xsl:value-of select="."/>\r
+                                       </unControlled>\r
+                               </form>\r
+                       </physicalDescription>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="relatedExtent">\r
+               <xsl:for-each select="marc:subfield[@code='h']">\r
+                       <physicalDescription>\r
+                               <extent>\r
+                                       <xsl:value-of select="."/>\r
+                               </extent>\r
+                       </physicalDescription>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="relatedNote">\r
+               <xsl:for-each select="marc:subfield[@code='n']">\r
+                       <note>\r
+                               <xsl:value-of select="."/>\r
+                       </note>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="relatedIdentifierISSN">\r
+               <xsl:for-each select="marc:subfield[@code='x']">\r
+                       <identifier type="issn">\r
+                               <xsl:value-of select="."/>\r
+                       </identifier>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="relatedIdentifierLocal">\r
+               <xsl:for-each select="marc:subfield[@code='w']">\r
+                       <identifier type="local">\r
+                               <xsl:value-of select="."/>\r
+                       </identifier>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="relatedIdentifier">\r
+               <xsl:for-each select="marc:subfield[@code='o']">\r
+                       <identifier>\r
+                               <xsl:value-of select="."/>\r
+                       </identifier>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="relatedItem76X-78X">\r
+               <xsl:call-template name="relatedTitle76X-78X"/>\r
+               <xsl:call-template name="relatedName"/>\r
+               <xsl:call-template name="relatedExtent"/>\r
+               <xsl:call-template name="relatedIdentifier"/>\r
+               <xsl:call-template name="relatedIdentifierISSN"/>\r
+               <xsl:call-template name="relatedIdentifierLocal"/>\r
+               <xsl:call-template name="relatedNote"/>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="subjectGeographicZ">\r
+               <geographic>\r
+                       <xsl:value-of select="."/>\r
+               </geographic>                   \r
+       </xsl:template>\r
+\r
+       <xsl:template name="subjectTemporalY">\r
+               <temporal>\r
+                       <xsl:value-of select="."/>\r
+               </temporal>                     \r
+       </xsl:template>\r
+\r
+       <xsl:template name="subjectTopic">\r
+               <topic>\r
+                       <xsl:call-template name="chopPunctuation">\r
+                               <xsl:with-param name="chopString" select="."/>\r
+                       </xsl:call-template>\r
+               </topic>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="nameABCDN">\r
+               <xsl:for-each select="marc:subfield[@code='a']">\r
+                       <namePart>\r
+                               <xsl:call-template name="chopPunctuation">\r
+                                       <xsl:with-param name="chopString" select="."/>\r
+                               </xsl:call-template>\r
+                       </namePart>                                     \r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:subfield[@code='b']">\r
+                       <namePart>\r
+                               <xsl:value-of select="."/>\r
+                       </namePart>                                     \r
+               </xsl:for-each>\r
+               <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">\r
+                       <namePart>\r
+                               <xsl:call-template name="subfieldSelect">\r
+                                       <xsl:with-param name="codes">cdn</xsl:with-param>\r
+                               </xsl:call-template>\r
+                       </namePart>\r
+               </xsl:if>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="nameABCDQ">\r
+               <namePart>\r
+                       <xsl:call-template name="chopPunctuation">\r
+                               <xsl:with-param name="chopString">\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abcq</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </xsl:with-param>\r
+                       </xsl:call-template>\r
+               </namePart>\r
+               <xsl:call-template name="nameDate"/>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="nameACDEQ">\r
+               <namePart>\r
+                       <xsl:call-template name="subfieldSelect">\r
+                               <xsl:with-param name="codes">acdeq</xsl:with-param>\r
+                       </xsl:call-template>\r
+               </namePart>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="constituentOrRelatedType">\r
+               <xsl:attribute name="type">\r
+                       <xsl:choose>\r
+                               <xsl:when test="@ind2=2">constituent</xsl:when>\r
+                               <xsl:otherwise>related</xsl:otherwise>\r
+                       </xsl:choose>\r
+               </xsl:attribute>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="relatedTitle">\r
+               <xsl:for-each select="marc:subfield[@code='t']">\r
+                       <titleInfo>\r
+                               <title>\r
+                                       <xsl:value-of select="."/>\r
+                               </title>\r
+                       </titleInfo>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="relatedTitle76X-78X">\r
+               <titleInfo>\r
+                       <xsl:for-each select="marc:subfield[@code='t']">\r
+                               <title>\r
+                                       <xsl:value-of select="."/>\r
+                               </title>\r
+                       </xsl:for-each>\r
+                       <xsl:for-each select="marc:subfield[@code='g']">\r
+                               <partNumber>\r
+                                       <xsl:value-of select="."/>\r
+                               </partNumber>\r
+                       </xsl:for-each>\r
+               </titleInfo>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="nameDate">\r
+               <xsl:for-each select="marc:subfield[@code='d']">\r
+                       <namePart type="date">\r
+                               <xsl:call-template name="chopPunctuation">\r
+                                       <xsl:with-param name="chopString" select="."/>\r
+                               </xsl:call-template>\r
+                       </namePart>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="subjectAuthority">\r
+               <xsl:attribute name="authority">\r
+                       <xsl:choose>\r
+                       <xsl:when test="@ind2=0">lcsh</xsl:when>\r
+                       <xsl:when test="@ind2=1">lcshac</xsl:when>\r
+                       <xsl:when test="@ind2=2">mesh</xsl:when>\r
+                       <xsl:when test="@ind2=3">csh</xsl:when>\r
+                       <xsl:when test="@ind2=5">nal</xsl:when>\r
+                       <xsl:when test="@ind2=6">rvm</xsl:when>\r
+                       <xsl:when test="@ind2=7"><xsl:value-of select="marc:subfield[@code='2']"/></xsl:when>\r
+                       </xsl:choose>\r
+               </xsl:attribute>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="subjectAnyOrder">\r
+               <xsl:for-each select="marc:subfield[@code='v' or @code='x' or @code='y' or @code='z']">\r
+                       <xsl:choose>\r
+                               <xsl:when test="@code='v'">\r
+                                       <xsl:call-template name="subjectTopic"/>\r
+                               </xsl:when>\r
+                               <xsl:when test="@code='x'">\r
+                                       <xsl:call-template name="subjectTopic"/>\r
+                               </xsl:when>\r
+                               <xsl:when test="@code='y'">\r
+                                       <xsl:call-template name="subjectTemporalY"/>\r
+                               </xsl:when>\r
+                               <xsl:when test="@code='z'">\r
+                                       <xsl:call-template name="subjectGeographicZ"/>\r
+                               </xsl:when>\r
+                       </xsl:choose>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+\r
+<!--   <xsl:template name="subfieldSelect">\r
+               <xsl:param name="codes"/>\r
+               <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>\r
+               <xsl:variable name="str">\r
+                       <xsl:for-each select="marc:subfield">\r
+                               <xsl:if test="contains($codes, @code)">\r
+                                       <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>\r
+                               </xsl:if>\r
+                       </xsl:for-each>\r
+               </xsl:variable>\r
+               <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>\r
+       </xsl:template>\r
+-->\r
+\r
+       <xsl:template name="specialSubfieldSelect">\r
+               <xsl:param name="anyCodes"/>\r
+               <xsl:param name="axis"/>\r
+               <xsl:param name="beforeCodes"/>\r
+               <xsl:param name="afterCodes"/>\r
+               <xsl:variable name="str">\r
+                       <xsl:for-each select="marc:subfield">\r
+                               <xsl:if test="contains($anyCodes, @code) or (contains($beforeCodes,@code) and following-sibling::marc:subfield[@code=$axis]) or (contains($afterCodes,@code) and preceding-sibling::marc:subfield[@code=$axis])">\r
+                                       <xsl:value-of select="text()"/><xsl:text> </xsl:text>\r
+                               </xsl:if>\r
+                       </xsl:for-each>\r
+               </xsl:variable>\r
+               <xsl:value-of select="substring($str,1,string-length($str)-1)"/>\r
+       </xsl:template>\r
+\r
+       <xsl:template match="marc:datafield[@tag=600]">\r
+               <subject>\r
+                       <xsl:call-template name="subjectAuthority"/>\r
+                       <name type="personal">\r
+                               <namePart>\r
+                                       <xsl:call-template name="chopPunctuation">\r
+                                               <xsl:with-param name="chopString">\r
+                                                       <xsl:call-template name="subfieldSelect">\r
+                                                               <xsl:with-param name="codes">abcq</xsl:with-param>\r
+                                                       </xsl:call-template>\r
+                                               </xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </namePart>\r
+                               <xsl:call-template name="nameDate"/>\r
+                               <xsl:call-template name="affiliation"/>\r
+                               <xsl:call-template name="role"/>\r
+                       </name>\r
+                       <xsl:call-template name="subjectAnyOrder"/>\r
+               </subject>\r
+       </xsl:template>\r
+\r
+       <xsl:template match="marc:datafield[@tag=610]">\r
+               <subject>\r
+                       <xsl:call-template name="subjectAuthority"/>\r
+                       <name type="corporate">\r
+                               <xsl:for-each select="marc:subfield[@code='a']">\r
+                                       <namePart>\r
+                                               <xsl:value-of select="."/>\r
+                                       </namePart>\r
+                               </xsl:for-each>\r
+                               <xsl:for-each select="marc:subfield[@code='b']">\r
+                                       <namePart>\r
+                                               <xsl:value-of select="."/>\r
+                                       </namePart>\r
+                               </xsl:for-each>\r
+                               <xsl:if test="marc:subfield[@code='c' or @code='d' or @code='n' or @code='p']">\r
+                                       <namePart>\r
+                                               <xsl:call-template name="subfieldSelect">\r
+                                                       <xsl:with-param name="codes">cdnp</xsl:with-param>\r
+                                               </xsl:call-template>\r
+                                       </namePart>\r
+                               </xsl:if>\r
+                               <xsl:call-template name="role"/>\r
+                       </name>\r
+                       <xsl:call-template name="subjectAnyOrder"/>\r
+               </subject>\r
+       </xsl:template>\r
+\r
+       <xsl:template match="marc:datafield[@tag=611]">\r
+               <subject>\r
+                       <xsl:call-template name="subjectAuthority"/>\r
+                       <name type="conference">\r
+                               <namePart>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abcdeqnp</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </namePart>\r
+                               <xsl:for-each select="marc:subfield[@code='4']">\r
+                                       <role>\r
+                                               <xsl:value-of select="."/>\r
+                                       </role>\r
+                               </xsl:for-each>\r
+                       </name>\r
+                       <xsl:call-template name="subjectAnyOrder"/>\r
+               </subject>\r
+       </xsl:template>\r
+\r
+       <xsl:template match="marc:datafield[@tag=630]">\r
+               <subject>\r
+                       <xsl:call-template name="subjectAuthority"/>\r
+                       <titleInfo>\r
+                               <title>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">adfhklor</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                                       <xsl:call-template name="part"/>                        \r
+                               </title>\r
+                       </titleInfo>\r
+                       <xsl:call-template name="subjectAnyOrder"/>\r
+               </subject>\r
+       </xsl:template>\r
+\r
+       <xsl:template match="marc:datafield[@tag=650]">\r
+               <subject>\r
+                       <xsl:call-template name="subjectAuthority"/>\r
+                       <topic>\r
+                               <xsl:call-template name="chopPunctuation">\r
+                                       <xsl:with-param name="chopString">\r
+                                               <xsl:call-template name="subfieldSelect">\r
+                                                       <xsl:with-param name="codes">abcd</xsl:with-param>\r
+                                               </xsl:call-template>\r
+                                       </xsl:with-param>\r
+                               </xsl:call-template>\r
+                       </topic>\r
+                       <xsl:call-template name="subjectAnyOrder"/>\r
+               </subject>\r
+       </xsl:template>\r
+\r
+\r
+       <xsl:template match="marc:datafield[@tag=651]">\r
+               <subject>\r
+                       <xsl:call-template name="subjectAuthority"/>\r
+                       <xsl:for-each select="marc:subfield[@code='a']">\r
+                               <geographic>\r
+                                       <xsl:value-of select="."/>\r
+                               </geographic>                   \r
+                       </xsl:for-each>\r
+                       <xsl:call-template name="subjectAnyOrder"/>\r
+               </subject>\r
+       </xsl:template>\r
+\r
+       <xsl:template match="marc:datafield[@tag=653]">\r
+               <subject>\r
+                       <xsl:for-each select="marc:subfield[@code='a']">\r
+                               <topic>\r
+                                       <xsl:value-of select="."/>\r
+                               </topic>                        \r
+                       </xsl:for-each>\r
+               </subject>\r
+       </xsl:template>\r
+</xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.\r
+<metaInformation>\r
+<scenarios ><scenario default="yes" name="modstst2" userelativepaths="yes" externalpreview="no" url="..\..\..\..\..\..\marcxml\modstst2.xml" htmlbaseurl="" outputurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/><scenario default="no" name="modstest" userelativepaths="yes" externalpreview="no" url="..\..\..\..\..\..\marcxml\modstest.xml" htmlbaseurl="" outputurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/><scenario default="no" name="Scenario1" userelativepaths="yes" externalpreview="no" url="..\..\..\..\..\..\marcxml\t.xml" htmlbaseurl="" outputurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/></scenarios><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>\r
+</metaInformation>\r
+-->
\ No newline at end of file
diff --git a/etc/MARC21slim2RDFDC.xsl b/etc/MARC21slim2RDFDC.xsl
new file mode 100644 (file)
index 0000000..2e81677
--- /dev/null
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="marc">\r
+       <xsl:import href="MARC21slimUtils.xsl"/>\r
+       <xsl:output method="xml" indent="yes"/>\r
+       \r
+       <xsl:template match="/">\r
+                       <xsl:apply-templates/>\r
+       </xsl:template>\r
+\r
+       <xsl:template match="marc:record">\r
+               <xsl:variable name="leader" select="marc:leader"/>\r
+               <xsl:variable name="leader6" select="substring($leader,7,1)"/>\r
+               <xsl:variable name="leader7" select="substring($leader,8,1)"/>\r
+               <xsl:variable name="controlField008" select="marc:controlfield[@tag=008]"/>\r
+\r
+         <rdf:Description>\r
+                       <xsl:for-each select="marc:datafield[@tag=245]">\r
+                               <dc:title>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abfghk</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </dc:title>\r
+                       </xsl:for-each>\r
+\r
+       \r
+                       <xsl:for-each select="marc:datafield[@tag=100]|marc:datafield[@tag=110]|marc:datafield[@tag=111]|marc:datafield[@tag=700]|marc:datafield[@tag=710]|marc:datafield[@tag=711]|marc:datafield[@tag=720]">\r
+                               <dc:creator>\r
+                                       <xsl:value-of select="."/>\r
+                               </dc:creator>\r
+                       </xsl:for-each>\r
+\r
+                       <dc:type>               \r
+                               <xsl:if test="$leader7='c'">\r
+                                       <xsl:attribute name="collection">yes</xsl:attribute>\r
+                               </xsl:if>\r
+\r
+                               <xsl:if test="$leader6='d' or $leader6='f' or $leader6='p' or $leader6='t'">\r
+                                       <xsl:attribute name="manuscript">yes</xsl:attribute>\r
+                               </xsl:if>\r
+\r
+                               <xsl:choose>\r
+                                       <xsl:when test="$leader6='a' or $leader6='t'">text</xsl:when>\r
+                                       <xsl:when test="$leader6='e' or $leader6='f'">cartographic</xsl:when>\r
+                                       <xsl:when test="$leader6='c' or $leader6='d'">notated music</xsl:when>\r
+                                       <xsl:when test="$leader6='i' or $leader6='j'">sound recording</xsl:when>\r
+                                       <xsl:when test="$leader6='k'">still image</xsl:when>\r
+                                       <xsl:when test="$leader6='g'">moving image</xsl:when>\r
+                                       <xsl:when test="$leader6='r'">three dimensional object</xsl:when>\r
+                                       <xsl:when test="$leader6='m'">software, multimedia</xsl:when>\r
+                                       <xsl:when test="$leader6='p'">mixed material</xsl:when>\r
+                               </xsl:choose>\r
+                       </dc:type>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=655]">\r
+                               <dc:type>\r
+                                       <xsl:value-of select="."/>\r
+                               </dc:type>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=260]">\r
+                               <dc:publisher>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">ab</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </dc:publisher>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='c']">\r
+                               <dc:date>\r
+                                       <xsl:value-of select="."/>\r
+                               </dc:date>                              \r
+                       </xsl:for-each>\r
+\r
+                       <dc:language>\r
+                               <xsl:value-of select="substring($controlField008,36,3)"/>\r
+                       </dc:language>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=856]/marc:subfield[@code='q']">\r
+                               <dc:format>\r
+                                       <xsl:value-of select="."/>\r
+                               </dc:format>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=520]">\r
+                               <dc:description>\r
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                               </dc:description>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=521]">\r
+                               <dc:description>\r
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                               </dc:description>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[500&lt;@tag][@tag&lt;=599][not(@tag=506 or @tag=530 or @tag=540 or @tag=546)]">\r
+                               <dc:description>\r
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                               </dc:description>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=600]">\r
+                               <dc:subject>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abcdq</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </dc:subject>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=610]">\r
+                               <dc:subject>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abcdq</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </dc:subject>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=611]">\r
+                               <dc:subject>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abcdq</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </dc:subject>\r
+                       </xsl:for-each>\r
+               \r
+                       <xsl:for-each select="marc:datafield[@tag=630]">\r
+                               <dc:subject>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abcdq</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </dc:subject>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=650]">\r
+                               <dc:subject>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abcdq</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </dc:subject>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=653]">\r
+                               <dc:subject>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abcdq</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </dc:subject>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=752]">\r
+                               <dc:coverage>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abcd</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </dc:coverage>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=530]">\r
+                               <dc:relation type="original">\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">abcdu</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </dc:relation>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=760]|marc:datafield[@tag=762]|marc:datafield[@tag=765]|marc:datafield[@tag=767]|marc:datafield[@tag=770]|marc:datafield[@tag=772]|marc:datafield[@tag=773]|marc:datafield[@tag=774]|marc:datafield[@tag=775]|marc:datafield[@tag=776]|marc:datafield[@tag=777]|marc:datafield[@tag=780]|marc:datafield[@tag=785]|marc:datafield[@tag=786]|marc:datafield[@tag=787]">\r
+                               <dc:relation>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">ot</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </dc:relation>  \r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=856]">\r
+                               <dc:identifier>\r
+                                       <xsl:value-of select="marc:subfield[@code='u']"/>\r
+                               </dc:identifier>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=506]">\r
+                               <dc:rights>\r
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                               </dc:rights>\r
+                       </xsl:for-each>\r
+\r
+                       <xsl:for-each select="marc:datafield[@tag=540]">\r
+                               <dc:rights>\r
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                               </dc:rights>\r
+                       </xsl:for-each>\r
+               </rdf:Description>\r
+       </xsl:template>\r
+</xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.\r
+<metaInformation>\r
+<scenarios ><scenario default="no" name="MODS Website Samples" userelativepaths="yes" externalpreview="no" url="..\xml\MARC21slim\modswebsitesamples.xml" htmlbaseurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/><scenario default="no" name="Ray Charles" userelativepaths="yes" externalpreview="no" url="..\xml\MARC21slim\raycharles.xml" htmlbaseurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/><scenario default="yes" name="s6" userelativepaths="yes" externalpreview="no" url="..\ifla\sally6.xml" htmlbaseurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/><scenario default="no" name="s7" userelativepaths="yes" externalpreview="no" url="..\ifla\sally7.xml" htmlbaseurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/><scenario default="no" name="s12" userelativepaths="yes" externalpreview="no" url="..\ifla\sally12.xml" htmlbaseurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/></scenarios><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>\r
+</metaInformation>\r
+-->
\ No newline at end of file
diff --git a/etc/MARC21slimUtils.xsl b/etc/MARC21slimUtils.xsl
new file mode 100644 (file)
index 0000000..acfe598
--- /dev/null
@@ -0,0 +1,65 @@
+<?xml version='1.0'?>\r
+<xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
+       <xsl:template name="datafield">\r
+               <xsl:param name="tag"/>\r
+               <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>\r
+               <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>\r
+               <xsl:param name="subfields"/>\r
+               <xsl:element name="datafield">\r
+                       <xsl:attribute name="tag">\r
+                               <xsl:value-of select="$tag"/>\r
+                       </xsl:attribute>\r
+                       <xsl:attribute name="ind1">\r
+                               <xsl:value-of select="$ind1"/>\r
+                       </xsl:attribute>\r
+                       <xsl:attribute name="ind2">\r
+                               <xsl:value-of select="$ind2"/>\r
+                       </xsl:attribute>\r
+                       <xsl:copy-of select="$subfields"/>\r
+               </xsl:element>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="subfieldSelect">\r
+               <xsl:param name="codes"/>\r
+               <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>\r
+               <xsl:variable name="str">\r
+                       <xsl:for-each select="marc:subfield">\r
+                               <xsl:if test="contains($codes, @code)">\r
+                                       <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>\r
+                               </xsl:if>\r
+                       </xsl:for-each>\r
+               </xsl:variable>\r
+               <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="buildSpaces">\r
+               <xsl:param name="spaces"/>\r
+               <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>\r
+               <xsl:if test="$spaces>0">\r
+                       <xsl:value-of select="$char"/>\r
+                       <xsl:call-template name="buildSpaces">\r
+                               <xsl:with-param name="spaces" select="$spaces - 1"/>\r
+                               <xsl:with-param name="char" select="$char"/>\r
+                       </xsl:call-template>\r
+               </xsl:if>\r
+       </xsl:template>\r
+\r
+       <xsl:template name="chopPunctuation">\r
+               <xsl:param name="chopString"/>\r
+               <xsl:variable name="length" select="string-length($chopString)"/>\r
+               <xsl:choose>\r
+                       <xsl:when test="$length=0"/>\r
+                       <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">\r
+                               <xsl:call-template name="chopPunctuation">\r
+                                       <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>\r
+                               </xsl:call-template>\r
+                       </xsl:when>\r
+                       <xsl:when test="not($chopString)"/>\r
+                       <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>\r
+               </xsl:choose>\r
+       </xsl:template>\r
+</xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.\r
+<metaInformation>\r
+<scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>\r
+</metaInformation>\r
+-->
\ No newline at end of file
diff --git a/etc/Makefile.am b/etc/Makefile.am
new file mode 100644 (file)
index 0000000..fa4b417
--- /dev/null
@@ -0,0 +1,9 @@
+# $Id: Makefile.am,v 1.1 2003-01-06 08:20:27 adam Exp $
+
+EXTRA_DIST=maps.xml \
+ MARC21slim2DC.xsl \
+ MARC21slim2MODS.xsl \
+ MARC21slim2RDFDC.xsl \
+ MARC21slimUtils.xsl \
+ pqf.properties
+
diff --git a/etc/maps.xml b/etc/maps.xml
new file mode 100644 (file)
index 0000000..72c7227
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!-- 
+  $Id: maps.xml,v 1.1 2003-01-06 08:20:27 adam Exp $
+  XSLT for each schema conversion.
+-->
+<schema-mappings xmlns="http://indexdata.dk/srw/schema-mappings/v1.0/">
+ <map>
+   <schema source="MARC21"/>
+   <schema target="http://www.loc.gov/marcxml/"/>
+ </map>
+ <map>
+   <schema source="MARC21"/>
+   <schema target="http://www.loc.gov/MARC21/slim"/>
+ </map>
+ <map>
+   <schema source="MARC21"/>
+   <schema target="http://www.loc.gov/zing/srw/dcschema/v1.0/"/>
+   <schema alias="dc"/>
+   <schema alias="DC"/>
+   <stylesheet filename="MARC21slim2DC.xsl"/>
+ </map>
+ <map>
+   <schema source="MARC21"/>
+   <schema target="rdfdc"/>
+   <schema alias="RDFDC"/>
+   <stylesheet filename="MARC21slim2RDFDC.xsl"/>
+ </map>
+ <map>
+   <schema source="MARC21"/>
+   <schema target="http://www.loc.gov/mods/"/>
+   <schema alias="mods"/>
+   <schema alias="MODS"/>
+   <stylesheet filename="MARC21slim2MODS.xsl"/>
+ </map>
+</schema-mappings>
diff --git a/etc/pqf.properties b/etc/pqf.properties
new file mode 100644 (file)
index 0000000..76f046b
--- /dev/null
@@ -0,0 +1,111 @@
+# $Id: pqf.properties,v 1.1 2003-01-06 08:20:27 adam Exp $
+#
+# Propeties file to drive org.z3950.zing.cql.CQLNode's toPQF()
+# back-end.  This specifies the interpretation of various CQL
+# qualifiers, relations, etc. in terms of Type-1 query attributes.
+#
+# See http://www.loc.gov/z3950/agency/zing/cql/dc-indexes.html
+# for the Maintenance Agency's work-in-progress mapping of Dublic Core
+# qualifiers to Attribute Architecture (util, XD and BIB-2)
+# attributes.
+
+# Identifiers for prefixes used in this file. (qualifier.*)
+set.srw                = http://www.loc.gov/zing/cql/srw-indexes/v1.0/
+set.dc         = http://www.loc.gov/zing/cql/dc-indexes/v1.0/
+# default set (in query)
+set             = http://www.loc.gov/zing/cql/dc-indexes/v1.0/
+
+# The default access point and result-set references
+qualifier.srw.serverChoice             = 1=1016
+       # "any"
+
+qualifier.dc.title                     = 1=4
+qualifier.dc.subject                   = 1=21
+qualifier.dc.creator                   = 1=1003
+qualifier.dc.author                    = 1=1003
+       ### Unofficial synonym for "creator"
+qualifier.dc.editor                    = 1=1020
+qualifier.dc.publisher                 = 1=1018
+qualifier.dc.description               = 1=62
+       # "abstract"
+qualifier.dc.date                      = 1=30
+qualifier.dc.resourceType              = 1=1031
+       # guesswork: "Material-type"
+qualifier.dc.format                    = 1=1034
+       # guesswork: "Content-type"
+qualifier.dc.resourceIdentifier                = 1=12
+       # "Local number"
+qualifier.dc.source                    = 1=1019
+       # "Record-source"
+qualifier.dc.language                  = 1=54
+       # "Code--language"
+qualifier.dc.relation                  = 1=?
+       ### No idea how to represent this
+qualifier.dc.coverage                  = 1=?
+       ### No idea how to represent this
+qualifier.dc.rights                    = 1=?
+       ### No idea how to represent this
+
+### These aren't right: I've just put them here for the Generator
+qualifier.bath.subject                 = 1=21
+qualifier.bath.author                  = 1=1003
+qualifier.foo>bar                      = 1=2000
+
+# Relation attributes are selected according to the CQL relation by
+# looking up the "relation.<relation>" property:
+#
+relation.<                             = 2=1
+relation.le                            = 2=2
+relation.eq                            = 2=3
+relation.exact                         = 2=3
+relation.ge                            = 2=4
+relation.>                             = 2=5
+relation.<>                            = 2=6
+
+### These two are not really right:
+relation.all                           = 2=3
+relation.any                           = 2=3
+
+# BIB-1 doesn't have a server choice relation, so we just make the
+# choice here, and use equality (which is clearly correct).
+relation.scr                           = 2=3
+
+# Relation modifiers.
+#
+relationModifier.relevant              = 2=102
+relationModifier.fuzzy                 = 2=100
+       ### 100 is "phonetic", which is not quite the same thing
+relationModifier.stem                  = 2=101
+relationModifier.phonetic              = 2=100
+
+# Position attributes may be specified for anchored terms (those
+# beginning with "^", which is stripped) and unanchored (those not
+# beginning with "^").  This may change when we get a BIB-1 truncation
+# attribute that says "do what CQL does".
+#
+position.first                         = 3=1 6=1
+       # "first in field"
+position.any                           = 3=3 6=1
+       # "any position in field"
+position.last                          = 3=4 6=1
+       # not a standard BIB-1 attribute
+position.firstAndLast                  = 3=3 6=3
+       # search term is anchored to be complete field
+
+# Structure attributes may be specified for individual relations; a
+# default structure attribute my be specified by the pseudo-relation
+# "*", to be used whenever a relation not listed here occurs.
+#
+structure.exact                                = 4=108
+       # string
+structure.all                          = 4=2
+structure.any                          = 4=2
+structure.*                            = 4=1
+       # phrase
+
+# Finally, any additional attributes that should always be included
+# with each term can be specified in the "always" property.
+#
+always                                 = 5=105 6=1
+# 5=105: the not-yet-standarised CQL-like trunction attribute
+# 6=1: completeness = incomplete subfield
index 275489a..5bf7713 100644 (file)
@@ -1,8 +1,8 @@
-## $Id: Makefile.am,v 1.18 2002-12-16 13:13:53 adam Exp $
+## $Id: Makefile.am,v 1.19 2003-01-06 08:20:27 adam Exp $
 
-pkginclude_HEADERS= backend.h ccl.h comstack.h \
+pkginclude_HEADERS= backend.h ccl.h cql.h comstack.h \
  diagbib1.h sortspec.h log.h logrpn.h marcdisp.h nmem.h odr.h oid.h \
- options.h otherinfo.h pquery.h prt-ext.h readconf.h statserv.h \
+ options.h otherinfo.h pquery.h prt-ext.h readconf.h srw-util.h statserv.h \
  tcpip.h unix.h tpath.h wrbuf.h xmalloc.h \
  yaz-ccl.h yaz-iconv.h yaz-util.h yaz-version.h yconfig.h proto.h \
  \
index 866b468..27343c2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995-2002, Index Data.
+ * Copyright (c) 1995-2003, Index Data.
  *
  * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation, in whole or in part, for any purpose, is hereby granted,
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: backend.h,v 1.16 2002-09-16 10:48:06 adam Exp $
+ * $Id: backend.h,v 1.17 2003-01-06 08:20:27 adam Exp $
  */
 
 #ifndef BACKEND_H
diff --git a/include/yaz/cql.h b/include/yaz/cql.h
new file mode 100644 (file)
index 0000000..9ae7b6b
--- /dev/null
@@ -0,0 +1,199 @@
+/* $Id: cql.h,v 1.1 2003-01-06 08:20:27 adam Exp $
+   Copyright (C) 2002-2003
+   Index Data Aps
+
+This file is part of the YAZ toolkit.
+
+See the file LICENSE.
+*/
+
+#ifndef CQL_H_INCLUDED
+#define CQL_H_INCLUDED
+#include <stdio.h>
+
+typedef struct cql_parser *CQL_parser;
+
+/**
+ * cql_parser_create:
+ *
+ * creates a CQL parser.
+ *
+ * Returns CQL parser or NULL if parser could not be created.
+ */
+CQL_parser cql_parser_create(void);
+
+/**
+ * cql_parser_destroy:
+ * @cp:  A CQL parser
+ *
+ * Destroy CQL parser. This function does nothing if
+ * NULL pointer is received.
+ */
+void cql_parser_destroy(CQL_parser cp);
+
+/**
+ * cql_parser_string:
+ * @cp:  A CQL parser.
+ * @str:  A query string to be parsed.
+ *
+ * Parses a CQL query string.
+ *
+ * Returns 0 if parsing was succesful; non-zero (error code) if
+ * unsuccesful.
+ */
+int cql_parser_string(CQL_parser cp, const char *str);
+
+/**
+ * cql_parser_stream:
+ * @cp:  A CQL parser.
+ * @getbyte:  Handler to read one character (for parsing).
+ * @ungetbyte: Handler to unread one byte (for parsing).
+ * @client_data:  User data associated with getbyte/ungetbyte handlers.
+ *
+ * Parses a CQL query from a user defined stream.
+ *
+ * Returns 0 if parsing was succesful; non-zero (error code) if
+ * unsuccesful.
+ */
+int cql_parser_stream(CQL_parser cp,
+                      int (*getbyte)(void *client_data),
+                      void (*ungetbyte)(int b, void *client_data),
+                      void *client_data);
+
+/**
+ * cql_parser_stdio:
+ * @cp:  A CQL parser.
+ * @f: FILE handler in read mode.
+ *
+ * Parses a CQL query from a file.
+ *
+ * Returns 0 if parsing was succesful; non-zero (error code) if
+ * unsuccesful.
+ */
+int cql_parser_stdio(CQL_parser cp, FILE *f);
+
+#define CQL_NODE_ST 1
+#define CQL_NODE_BOOL 2
+#define CQL_NODE_MOD 3
+struct cql_node {
+    int which;
+    union {
+        struct {
+            char *index;
+            char *term;
+            char *relation;
+            struct cql_node *modifiers;
+            struct cql_node *prefixes;
+        } st;
+        struct {
+            char *value;
+            struct cql_node *left;
+            struct cql_node *right;
+            struct cql_node *modifiers;
+            struct cql_node *prefixes;
+        } bool;
+        struct {
+            char *name;
+            char *value;
+            struct cql_node *next;
+        } mod;
+    } u;
+};
+
+struct cql_properties;
+
+struct cql_buf_write_info {
+    int max;
+    int off;
+    char *buf;
+};
+
+void cql_buf_write_handler (const char *b, void *client_data);
+
+void cql_node_print(struct cql_node *cn);
+struct cql_node *cql_node_mk_sc(const char *index,
+                                const char *relation,
+                                const char *term);
+struct cql_node *cql_node_mk_boolean(const char *op);
+void cql_node_destroy(struct cql_node *cn);
+struct cql_node *cql_node_prefix(struct cql_node *n, const char *prefix,
+                                 const char *uri);
+struct cql_node *cql_node_mk_mod(const char *name,
+                                 const char *value);
+
+struct cql_node *cql_node_dup (struct cql_node *cp);
+struct cql_node *cql_parser_result(CQL_parser cp);
+
+void cql_to_xml(struct cql_node *cn, 
+                void (*pr)(const char *buf, void *client_data),
+                void *client_data);
+void cql_to_xml_stdio(struct cql_node *cn, FILE *f);
+int cql_to_xml_buf(struct cql_node *cn, char *out, int max);
+
+struct cql_node *cql_node_mk_proxargs(const char *relation,
+                                      const char *distance,
+                                      const char *unit,
+                                      const char *ordering);
+
+
+void cql_fputs(const char *buf, void *client_data);
+
+typedef struct cql_transform_t_ *cql_transform_t;
+
+cql_transform_t cql_transform_open_FILE (FILE *f);
+cql_transform_t cql_transform_open_fname(const char *fname);
+void cql_transform_close(cql_transform_t ct);
+
+void cql_transform_pr(cql_transform_t ct,
+                      struct cql_node *cn,
+                      void (*pr)(const char *buf, void *client_data),
+                      void *client_data);
+
+int cql_transform_FILE(cql_transform_t ct,
+                       struct cql_node *cn, FILE *f);
+
+int cql_transform_buf(cql_transform_t ct,
+                      struct cql_node *cn, char *out, int max);
+int cql_transform_error(cql_transform_t ct, const char **addinfo);
+
+/*
+10 Illegal query
+11 Unsupported query type (XCQL vs CQL)
+12 Too many characters in query
+13 Unbalanced or illegal use of parentheses
+14 Unbalanced or illegal use of quotes
+15 Illegal or unsupported index set
+16 Illegal or unsupported index
+17 Illegal or unsupported combination of index and index set
+18 Illegal or unsupported combination of indexes
+19 Illegal or unsupported relation
+20 Illegal or unsupported relation modifier
+21 Illegal or unsupported combination of relation modifers
+22 Illegal or unsupported combination of relation and index
+23 Too many characters in term
+24 Illegal combination of relation and term
+25 Special characters not quoted in term
+26 Non special character escaped in term
+27 Empty term unsupported
+28 Masking character not supported
+29 Masked words too short
+30 Too many masking characters in term
+31 Anchoring character not supported
+32 Anchoring character in illegal or unsupported position
+33 Combination of proximity/adjacency and masking characters not supported
+34 Combination of proximity/adjacency and anchoring characters not supported
+35 Terms only exclusion (stop) words
+36 Term in invalid format for index or relation
+37 Illegal or unsupported boolean operator
+38 Too many boolean operators in query
+39 Proximity not supported
+40 Illegal or unsupported proximity relation
+41 Illegal or unsupported proximity distance
+42 Illegal or unsupported proximity unit
+43 Illegal or unsupported proximity ordering
+44 Illegal or unsupported combination of proximity modifiers
+45 Index set name (prefix) assigned to multiple identifiers
+*/
+
+#endif
+/* CQL_H_INCLUDED */
index 6b41af3..6925d78 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995-2002, Index Data.
+ * Copyright (c) 1995-2003, Index Data.
  *
  * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation, in whole or in part, for any purpose, is hereby granted,
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: log.h,v 1.7 2002-08-29 09:58:42 adam Exp $
+ * $Id: log.h,v 1.8 2003-01-06 08:20:27 adam Exp $
  */
 
 #ifndef LOG_H
index e5e7552..d1f4c07 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: logrpn.h,v $
- * Revision 1.2  2000-02-28 11:20:06  adam
+ * Revision 1.3  2003-01-06 08:20:27  adam
+ * SRW, CQL, 2003
+ *
+ * Revision 1.2  2000/02/28 11:20:06  adam
  * Using autoconf. New definitions: YAZ_BEGIN_CDECL/YAZ_END_CDECL.
  *
  * Revision 1.1  1999/11/30 13:47:11  adam
@@ -26,6 +29,7 @@ YAZ_BEGIN_CDECL
 
 YAZ_EXPORT void log_rpn_query (Z_RPNQuery *rpn);
 YAZ_EXPORT void log_scan_term (Z_AttributesPlusTerm *zapt, oid_value ast);
+YAZ_EXPORT void yaz_log_zquery (Z_Query *q);
 
 YAZ_END_CDECL
 
index 3760a2f..afbe121 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995-2002, Index Data.
+ * Copyright (c) 1995-2003, Index Data.
  *
  * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation, in whole or in part, for any purpose, is hereby granted,
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: marcdisp.h,v 1.7 2002-12-16 13:13:53 adam Exp $
+ * $Id: marcdisp.h,v 1.8 2003-01-06 08:20:27 adam Exp $
  */
 
 #ifndef MARCDISP_H
index 1a0a260..2a11b2b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995-2002, Index Data.
+ * Copyright (c) 1995-2003, Index Data.
  *
  * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation, in whole or in part, for any purpose, is hereby granted,
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: nmem.h,v 1.9 2002-12-05 12:19:23 adam Exp $
+ * $Id: nmem.h,v 1.10 2003-01-06 08:20:27 adam Exp $
  */
 
 #ifndef NMEM_H
index 895d635..629b7f6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995-2002, Index Data.
+ * Copyright (c) 1995-2003, Index Data.
  *
  * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation, in whole or in part, for any purpose, is hereby granted,
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: odr.h,v 1.6 2002-07-25 12:51:08 adam Exp $
+ * $Id: odr.h,v 1.7 2003-01-06 08:20:27 adam Exp $
  */
 
 #ifndef ODR_H
index e418f6c..d9f18df 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: oid.h,v 1.12 2002-08-30 15:39:40 mike Exp $
+ * $Id: oid.h,v 1.13 2003-01-06 08:20:27 adam Exp $
  */
 
 #ifndef OID_H
@@ -209,6 +209,7 @@ typedef enum oid_value
     VAL_IDXPATH,
     VAL_BIB2,
     VAL_ZEEREX,
+    VAL_CQL,
 
 /* VAL_DYNAMIC must have highest value */
     VAL_DYNAMIC,
diff --git