Schema conversion. Use libxml2 and lots of other updates
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 5 Jan 2004 09:31:08 +0000 (09:31 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 5 Jan 2004 09:31:08 +0000 (09:31 +0000)
12 files changed:
TODO
configure.in
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/config.xml
etc/voyager.xml
include/yaz++/proxy.h
src/Makefile.am
src/yaz-proxy-config.cpp
src/yaz-proxy.cpp

diff --git a/TODO b/TODO
index e6f713c..42735b4 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,11 +1,17 @@
 
 Control the various optimizations with config..
 
-Handle invalidate sessions (-1 hit, control-number search).
-
 Live status (via search, present).
 
-SRW/SRU.
-
 Possible threading.
 
+Throw proper diagnostic for bad schema (Z39.50/SRW).
+
+Deal with Z39.50 options properly.
+
+Deal with Z39.50 messages sizes properly.
+
+For SRW/SRU, set schema for each returned record.
+
+Fork to ensure that crashes are catched.
+
index 5ead126..9682cf1 100644 (file)
@@ -11,27 +11,27 @@ AM_PROG_LIBTOOL
 YAZ_INIT(threads)
 
 dnl
-dnl ----- libXML2
-AC_SUBST(XML2_LIBS)
-AC_SUBST(XML2_CFLAGS)
-xml2dir=yes
-AC_ARG_WITH(xml2, [  --with-xml2[=PREFIX]    use libxml2 in PREFIX],[xml2dir=$withval])
-if test "$xml2dir" = "yes"; then
+dnl ----- libXSLT
+AC_SUBST(XSLT_LIBS)
+AC_SUBST(XSLT_CFLAGS)
+xsltdir=yes
+AC_ARG_WITH(xslt, [  --with-xslt[=PREFIX]    use libxslt in PREFIX],[xsltdir=$withval])
+if test "$xsltdir" = "yes"; then
        for d in /usr /usr/local; do
-               if test -x $d/bin/xml2-config; then
-                       xml2dir=$d
+               if test -x $d/bin/xslt-config; then
+                       xsltdir=$d
                fi
        done
 fi
-if test "$xml2dir" != "no"; then
-       AC_MSG_CHECKING(for libXML2)
-       if test -x $xml2dir/bin/xml2-config; then
-               XML2_LIBS=`$xml2dir/bin/xml2-config --libs`
-               LIBS="$XML2_LIBS $LIBS"
-               XML2_CFLAGS=`$xml2dir/bin/xml2-config --cflags`
-               XML2_VER=`$xml2dir/bin/xml2-config --version`
-               AC_MSG_RESULT($XML2_VER)
-               AC_DEFINE(HAVE_XML2)
+if test "$xsltdir" != "no"; then
+       AC_MSG_CHECKING(for libXSLT)
+       if test -x $xsltdir/bin/xslt-config; then
+               XSLT_LIBS=`$xsltdir/bin/xslt-config --libs`
+               LIBS="$XSLT_LIBS $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
diff --git a/etc/MARC21slim2DC.xsl b/etc/MARC21slim2DC.xsl
new file mode 100644 (file)
index 0000000..ec48de0
--- /dev/null
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id: MARC21slim2DC.xsl,v 1.1 2004-01-05 09:31:09 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
index 7c8d1ef..c03b41f 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<!-- $Id: config.xml,v 1.4 2003-12-22 15:16:23 adam Exp $ -->
+<!-- $Id: config.xml,v 1.5 2004-01-05 09:31:09 adam Exp $ -->
 <proxy>
   <target name="bagel">
     <url>indexdata.dk</url>
   </target>
   <target default="1" name="localhost">
     <url>localhost:9999</url>
-    <url>localhost:9998</url>
     <target-timeout>300</target-timeout>
     <client-timeout>180</client-timeout>
     <keepalive/> <!-- keepalive enabled -->
     <limit><!-- limits .. -->
       <bandwidth>50000</bandwidth>
       <pdu>60</pdu>
-      <retrieve>10</retrieve>
+      <retrieve>50</retrieve>
     </limit>
     <attribute type="1" value="1-1023"/>
     <attribute type="1" value="*" error="114"/>
     <syntax type="usmarc"/>
     <syntax type="grs1"/>
-    <syntax type="xml" marcxml="1"/>
+    <syntax type="xml" marcxml="1" stylesheet="MARC21slim2DC.xsl">
+      dc
+      http://www.loc.gov/zing/srw/dcschema/v1.0/
+    </syntax>
+    <syntax type="xml" marcxml="1">
+      marcxml
+      http://www.loc.gov/marcxml/
+    </syntax>
+    <syntax type="xml" marcxml="1" stylesheet="MARC21slim2MODS.xsl">
+      mods
+      http://www.loc.gov/mods/v3
+    </syntax>
     <syntax type="none"/>
     <syntax type="*" error="238"/>
     <preinit>2</preinit>
     <cql2rpn>pqf.properties</cql2rpn>
     <explain>
       <serverInfo>
-       <host>myhost</host>
+       <host>indexdata.dk</host>
+       <port>9000</port>
       </serverInfo>
     </explain>
-    <zeerex>zeerex.xml</zeerex>
   </target>
   <target name="*">
     <!-- everything else -->
index 0cf0f32..b604cb7 100644 (file)
@@ -1,11 +1,10 @@
 <?xml version="1.0"?>
-<!-- $Id: voyager.xml,v 1.1 2003-10-24 10:21:23 adam Exp $ -->
+<!-- $Id: voyager.xml,v 1.2 2004-01-05 09:31:09 adam Exp $ -->
 <proxy>
   <!-- define default target and name it voyager -->
   <target default="1" name="voyager">
     <!-- all backend addresses as seen from this proxy .. -->
     <url>z3950.loc.gov:7090</url>
-    <url>z3950.loc.gov:7094</url>
 
     <!-- set session timeout between proxy and backend target -->
     <target-timeout>300</target-timeout>
@@ -25,7 +24,7 @@
     <limit>
       <bandwidth>200000</bandwidth>
       <pdu>31</pdu>
-      <retrieve>20</retrieve>
+      <retrieve>50</retrieve>
     </limit>
 
     <!-- use attributes -->
     <!-- other types -->
     <attribute type="*" value="*" error="113"/>
 
-    <!-- list allowed record syntaxes; reject all others at the end -->
+    <!-- list allowed record syntaxes and possible schemas (if any);
+    reject all others at the end -->
     <syntax type="opac"/>
     <syntax type="usmarc"/>
     <syntax type="none"/>
-    <syntax type="xml" marcxml="1"/>
+
+    <syntax type="xml" marcxml="1" stylesheet="MARC21slim2DC.xsl">
+      dc
+      http://www.loc.gov/zing/srw/dcschema/v1.0/
+    </syntax>
+    <syntax type="xml" marcxml="1">
+      marcxml
+      http://www.loc.gov/marcxml/
+    </syntax>
+    <syntax type="xml" marcxml="1" stylesheet="MARC21slim2MODS.xsl">
+      mods
+      http://www.loc.gov/mods/v3
+    </syntax>
+
     <syntax type="*" error="238"/>
 
     <!-- keep this number of spare sessions for future sessions -->
     <preinit>2</preinit>
+
+    <explain>
+      <serverInfo>
+       <host>indexdata.dk</host>
+       <port>9000</port>
+      </serverInfo>
+    </explain>
   </target>
 
   <!-- maximum number of client sessions. Remember to allow for
index 657b7ef..8ed5473 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1998-2003, Index Data.
  * See the file LICENSE for details.
  * 
- * $Id: proxy.h,v 1.24 2003-12-22 15:16:23 adam Exp $
+ * $Id: proxy.h,v 1.25 2004-01-05 09:31:09 adam Exp $
  */
 
 #include <sys/time.h>
@@ -10,7 +10,7 @@
 #include <yaz++/z-query.h>
 #include <yaz++/z-databases.h>
 #include <yaz/cql.h>
-#if HAVE_XML2
+#if HAVE_XSLT
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 #endif
@@ -58,13 +58,15 @@ public:
 
     int check_query(ODR odr, const char *name, Z_Query *query, char **addinfo);
     int check_syntax(ODR odr, const char *name,
-                    Odr_oid *syntax, char **addinfo);
+                    Odr_oid *syntax, Z_RecordComposition *comp,
+                    char **addinfo, char **stylesheet);
     char *get_explain(ODR odr, const char *name, const char *db,
                      int *len);
 private:
     void operator=(const Yaz_ProxyConfig &conf);
     int mycmp(const char *hay, const char *item, size_t len);
-#if HAVE_XML2
+#if HAVE_XSLT
+    int check_esn(xmlNodePtr ptr, Z_RecordComposition *comp);
     xmlDocPtr m_docPtr;
     xmlNodePtr m_proxyPtr;
     void return_target_info(xmlNodePtr ptr, const char **url,
@@ -234,7 +236,9 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc {
     int m_request_no;
     int m_invalid_session;
     int m_marcxml_flag;
+    char *m_stylesheet;
     void convert_to_marcxml(Z_NamePlusRecordList *p);
+    void convert_xsl(Z_NamePlusRecordList *p);
     Z_APDU *m_initRequest_apdu;
     NMEM m_initRequest_mem;
     Z_APDU *m_apdu_invalid_session;
@@ -261,6 +265,7 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc {
     Yaz_cql2rpn m_cql2rpn;
     struct timeval m_time_tv;
     void logtime();
+    Z_ElementSetNames *mk_esn_from_schema(ODR o, const char *schema);
  public:
     Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable,
              Yaz_Proxy *parent = 0);
index 67f1bed..3c59ed8 100644 (file)
@@ -1,6 +1,6 @@
-## $Id: Makefile.am,v 1.20 2003-12-16 14:17:01 adam Exp $
+## $Id: Makefile.am,v 1.21 2004-01-05 09:31:09 adam Exp $
 
-AM_CXXFLAGS = $(YAZINC) -I$(srcdir)/../include $(XML2_CFLAGS)
+AM_CXXFLAGS = $(YAZINC) -I$(srcdir)/../include $(XSLT_CFLAGS)
 
 noinst_LTLIBRARIES = libyazcpp.la
 
@@ -20,4 +20,4 @@ yaz_my_server_SOURCES=yaz-my-server.cpp yaz-marc-sample.cpp
 
 yaz_proxy_SOURCES=yaz-proxy-main.cpp
 
-LDADD=libyazcpp.la $(YAZLALIB)
+LDADD=libyazcpp.la $(YAZLALIB) $(XSLT_LIBS)
index 96695fc..fbcc88d 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1998-2003, Index Data.
  * See the file LICENSE for details.
  * 
- * $Id: yaz-proxy-config.cpp,v 1.17 2003-12-22 15:16:23 adam Exp $
+ * $Id: yaz-proxy-config.cpp,v 1.18 2004-01-05 09:31:09 adam Exp $
  */
 
 #include <ctype.h>
@@ -12,7 +12,7 @@
 Yaz_ProxyConfig::Yaz_ProxyConfig()
 {
     m_copy = 0;
-#if HAVE_XML2
+#if HAVE_XSLT
     m_docPtr = 0;
     m_proxyPtr = 0;
 #endif
@@ -20,7 +20,7 @@ Yaz_ProxyConfig::Yaz_ProxyConfig()
 
 Yaz_ProxyConfig::~Yaz_ProxyConfig()
 {
-#if HAVE_XML2
+#if HAVE_XSLT
     if (!m_copy && m_docPtr)
        xmlFreeDoc(m_docPtr);
 #endif
@@ -28,7 +28,7 @@ Yaz_ProxyConfig::~Yaz_ProxyConfig()
 
 int Yaz_ProxyConfig::read_xml(const char *fname)
 {
-#if HAVE_XML2
+#if HAVE_XSLT
     xmlDocPtr ndoc = xmlParseFile(fname);
 
     if (!ndoc)
@@ -56,7 +56,7 @@ int Yaz_ProxyConfig::read_xml(const char *fname)
 #endif
 }
 
-#if HAVE_XML2
+#if HAVE_XSLT
 const char *Yaz_ProxyConfig::get_text(xmlNodePtr ptr)
 {
     for(ptr = ptr->children; ptr; ptr = ptr->next)
@@ -74,7 +74,7 @@ const char *Yaz_ProxyConfig::get_text(xmlNodePtr ptr)
 }
 #endif
 
-#if HAVE_XML2
+#if HAVE_XSLT
 void Yaz_ProxyConfig::return_limit(xmlNodePtr ptr,
                                   int *limit_bw,
                                   int *limit_pdu,
@@ -107,7 +107,7 @@ void Yaz_ProxyConfig::return_limit(xmlNodePtr ptr,
 }
 #endif
 
-#if HAVE_XML2
+#if HAVE_XSLT
 void Yaz_ProxyConfig::return_target_info(xmlNodePtr ptr,
                                         const char **url,
                                         int *limit_bw,
@@ -220,7 +220,7 @@ int Yaz_ProxyConfig::match_list(int v, const char *m)
   return 0;
 }
 
-#if HAVE_XML2
+#if HAVE_XSLT
 int Yaz_ProxyConfig::check_type_1_attributes(ODR odr, xmlNodePtr ptrl,
                                             Z_AttributeList *attrs,
                                             char **addinfo)
@@ -293,7 +293,7 @@ int Yaz_ProxyConfig::check_type_1_attributes(ODR odr, xmlNodePtr ptrl,
 }
 #endif
 
-#if HAVE_XML2
+#if HAVE_XSLT
 int Yaz_ProxyConfig::check_type_1_structure(ODR odr, xmlNodePtr ptr,
                                            Z_RPNStructure *q,
                                            char **addinfo)
@@ -319,7 +319,7 @@ int Yaz_ProxyConfig::check_type_1_structure(ODR odr, xmlNodePtr ptr,
 }
 #endif
 
-#if HAVE_XML2
+#if HAVE_XSLT
 int Yaz_ProxyConfig::check_type_1(ODR odr, xmlNodePtr ptr, Z_RPNQuery *query,
                                  char **addinfo)
 {
@@ -331,7 +331,7 @@ int Yaz_ProxyConfig::check_type_1(ODR odr, xmlNodePtr ptr, Z_RPNQuery *query,
 int Yaz_ProxyConfig::check_query(ODR odr, const char *name, Z_Query *query,
                                 char **addinfo)
 {
-#if HAVE_XML2
+#if HAVE_XSLT
     xmlNodePtr ptr;
     
     ptr = find_target_node(name, 0);
@@ -344,10 +344,58 @@ int Yaz_ProxyConfig::check_query(ODR odr, const char *name, Z_Query *query,
     return 0;
 }
 
+#if HAVE_XSLT
+int Yaz_ProxyConfig::check_esn(xmlNodePtr ptr, Z_RecordComposition *comp)
+{
+    char *esn = 0;
+    int default_match = 1;
+    if (comp && comp->which == Z_RecordComp_simple &&
+       comp->u.simple && comp->u.simple->which == Z_ElementSetNames_generic)
+    {
+       esn = comp->u.simple->u.generic;
+    }
+    if (!esn)
+       return 1;
+    for (; ptr; ptr = ptr->next)
+    {
+       if (ptr->type == XML_TEXT_NODE)
+       {
+           default_match = 0;
+           xmlChar *t = ptr->content;
+           while (*t)
+           {
+               while (*t && isspace(*t))
+                   t++;
+               xmlChar *s = t;
+               int i = 0;
+               while (esn[i] && esn[i] == *s)
+               {
+                   i++;
+                   s++;
+               }
+               if (!esn[i] &&  (!*s || isspace(*s)))
+                   return 1;
+               while (*s && !isspace(*s))
+                   s++;
+               t = s;
+           }
+       }
+    }
+    return default_match;
+}
+#endif
+
 int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
-                                 Odr_oid *syntax, char **addinfo)
+                                 Odr_oid *syntax, Z_RecordComposition *comp,
+                                 char **addinfo,
+                                 char **stylesheet)
 {
-#if HAVE_XML2
+    if (stylesheet)
+    {
+       xfree (*stylesheet);
+       *stylesheet = 0;
+    }
+#if HAVE_XSLT
     xmlNodePtr ptr;
     
     ptr = find_target_node(name, 0);
@@ -362,6 +410,7 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
            const char *match_type = 0;
            const char *match_error = 0;
            const char *match_marcxml = 0;
+           const char *match_stylesheet = 0;
            struct _xmlAttr *attr;
            for (attr = ptr->properties; attr; attr = attr->next)
            {
@@ -374,6 +423,9 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
                if (!strcmp((const char *) attr->name, "marcxml") &&
                    attr->children && attr->children->type == XML_TEXT_NODE)
                    match_marcxml = (const char *) attr->children->content;
+               if (!strcmp((const char *) attr->name, "stylesheet") &&
+                   attr->children && attr->children->type == XML_TEXT_NODE)
+                   match_stylesheet = (const char *) attr->children->content;
            }
            if (match_type)
            {
@@ -393,7 +445,15 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
                }
            }
            if (match)
+               match = check_esn(ptr->children, comp);
+
+           if (match)
            {
+               if (stylesheet && match_stylesheet)
+               {
+                   xfree(*stylesheet);
+                   *stylesheet = xstrdup(match_stylesheet);
+               }
                if (match_marcxml)
                {
                    return -1;
@@ -416,7 +476,7 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
     return 0;
 }
 
-#if HAVE_XML2
+#if HAVE_XSLT
 xmlNodePtr Yaz_ProxyConfig::find_target_db(xmlNodePtr ptr, const char *db)
 {
     xmlNodePtr dptr;
@@ -509,7 +569,7 @@ int Yaz_ProxyConfig::get_target_no(int no,
                                   int *pre_init,
                                   const char **cql2rpn)
 {
-#if HAVE_XML2
+#if HAVE_XSLT
     xmlNodePtr ptr;
     if (!m_proxyPtr)
        return 0;
@@ -551,7 +611,7 @@ int Yaz_ProxyConfig::mycmp(const char *hay, const char *item, size_t len)
 void Yaz_ProxyConfig::get_generic_info(int *log_mask,
                                       int *max_clients)
 {
-#if HAVE_XML2
+#if HAVE_XSLT
     xmlNodePtr ptr;
     if (!m_proxyPtr)
        return;
@@ -603,7 +663,7 @@ void Yaz_ProxyConfig::get_generic_info(int *log_mask,
 char *Yaz_ProxyConfig::get_explain(ODR odr, const char *name, const char *db,
                                   int *len)
 {
-#if HAVE_XML2
+#if HAVE_XSLT
     xmlNodePtr ptr = find_target_node(name, db);
     if (ptr)
     {
@@ -650,7 +710,7 @@ void Yaz_ProxyConfig::get_target_info(const char *name,
                                      int *pre_init,
                                      const char **cql2rpn)
 {
-#if HAVE_XML2
+#if HAVE_XSLT
     xmlNodePtr ptr;
     if (!m_proxyPtr)
     {
index a4257a3..4e97876 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1998-2003, Index Data.
  * See the file LICENSE for details.
  * 
- * $Id: yaz-proxy.cpp,v 1.74 2003-12-22 19:01:34 adam Exp $
+ * $Id: yaz-proxy.cpp,v 1.75 2004-01-05 09:31:09 adam Exp $
  */
 
 #include <assert.h>
 #include <yaz++/proxy.h>
 #include <yaz/pquery.h>
 
+#if HAVE_XSLT
+#include <libxslt/xsltutils.h>
+#include <libxslt/transform.h>
+#endif
+
 static const char *apdu_name(Z_APDU *apdu)
 {
     switch (apdu->which)
@@ -101,6 +106,7 @@ Yaz_Proxy::Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable,
     m_invalid_session = 0;
     m_config = 0;
     m_marcxml_flag = 0;
+    m_stylesheet = 0;
     m_initRequest_apdu = 0;
     m_initRequest_mem = 0;
     m_apdu_invalid_session = 0;
@@ -128,6 +134,7 @@ Yaz_Proxy::~Yaz_Proxy()
     xfree (m_default_target);
     xfree (m_proxy_authentication);
     xfree (m_optimize);
+    xfree (m_stylesheet);
     if (m_s2z_odr_init)
        odr_destroy(m_s2z_odr_init);
     if (m_s2z_odr_search)
@@ -572,6 +579,44 @@ void Yaz_Proxy::display_diagrecs(Z_DiagRec **pp, int num)
     }
 }
 
+void Yaz_Proxy::convert_xsl(Z_NamePlusRecordList *p)
+{
+    if (!m_stylesheet)
+       return;
+    xmlDocPtr xslt_doc = xmlParseFile(m_stylesheet);
+    xsltStylesheetPtr xsp;
+
+    xsp = xsltParseStylesheetDoc(xslt_doc);
+
+    int i;
+    for (i = 0; i < p->num_records; i++)
+    {
+       Z_NamePlusRecord *npr = p->records[i];
+       if (npr->which == Z_NamePlusRecord_databaseRecord)
+       {
+           Z_External *r = npr->u.databaseRecord;
+           if (r->which == Z_External_octet)
+           {
+               xmlDocPtr res, doc = xmlParseMemory(
+                   (char*) r->u.octet_aligned->buf,
+                   r->u.octet_aligned->len);
+               
+               res = xsltApplyStylesheet(xsp, doc, 0);
+               
+               xmlChar *out_buf;
+               int out_len;
+               xmlDocDumpMemory (res, &out_buf, &out_len);
+               p->records[i]->u.databaseRecord = 
+                   z_ext_record(odr_encode(), VAL_TEXT_XML,
+                                (char*) out_buf, out_len);
+               xmlFreeDoc(doc);
+               xmlFreeDoc(res);
+           }
+       }
+    }
+    xsltFreeStylesheet(xsp);
+}
+
 void Yaz_Proxy::convert_to_marcxml(Z_NamePlusRecordList *p)
 {
     int i;
@@ -682,7 +727,7 @@ int Yaz_Proxy::send_srw_response(Z_SRW_PDU *srw_pdu)
         z_HTTP_header_add(o, &hres->headers, "Connection", "Keep-Alive");
 
     static Z_SOAP_Handler soap_handlers[2] = {
-#if HAVE_XML2
+#if HAVE_XSLT
        {"http://www.loc.gov/zing/srw/", 0,
         (Z_SOAP_fun) yaz_srw_codec},
 #endif
@@ -900,8 +945,12 @@ int Yaz_Proxy::send_to_client(Z_APDU *apdu)
        }
        else
        {
-           if (m_marcxml_flag && p && p->which == Z_Records_DBOSD)
-               convert_to_marcxml(p->u.databaseOrSurDiagnostics);
+           if (p && p->which == Z_Records_DBOSD)
+           {
+               if (m_marcxml_flag)
+                   convert_to_marcxml(p->u.databaseOrSurDiagnostics);
+               convert_xsl(p->u.databaseOrSurDiagnostics);
+           }
            if (sr->resultCount)
            {
                yaz_log(LOG_LOG, "%s%d hits", m_session_str,
@@ -932,8 +981,12 @@ int Yaz_Proxy::send_to_client(Z_APDU *apdu)
                *sr->presentStatus = Z_PresentStatus_failure;
            display_diagrecs(&dr_p, 1);
        }
-       if (m_marcxml_flag && p && p->which == Z_Records_DBOSD)
-           convert_to_marcxml(p->u.databaseOrSurDiagnostics);
+       if (p && p->which == Z_Records_DBOSD)
+       {
+           if (m_marcxml_flag)
+               convert_to_marcxml(p->u.databaseOrSurDiagnostics);
+           convert_xsl(p->u.databaseOrSurDiagnostics);
+       }
     }
     int r = send_PDU_convert(apdu, &len);
     if (r)
@@ -1365,17 +1418,24 @@ Z_APDU *Yaz_Proxy::handle_syntax_validation(Z_APDU *apdu)
        int err = 0;
        char *addinfo = 0;
        Yaz_ProxyConfig *cfg = check_reconfigure();
-       
+
+       Z_RecordComposition rc_temp, *rc = 0;
+       if (sr->smallSetElementSetNames)
+       {
+           rc_temp.which = Z_RecordComp_simple;
+           rc_temp.u.simple = sr->smallSetElementSetNames;
+           rc = &rc_temp;
+       }
+           
        if (cfg)
            err = cfg->check_syntax(odr_encode(),
                                    m_default_target,
-                                   sr->preferredRecordSyntax,
-                                   &addinfo);
+                                   sr->preferredRecordSyntax, rc,
+                                   &addinfo, &m_stylesheet);
        if (err == -1)
        {
            sr->preferredRecordSyntax =
-               yaz_oidval_to_z3950oid(odr_decode(), CLASS_RECSYN,
-                                      VAL_USMARC);
+               yaz_oidval_to_z3950oid(odr_encode(), CLASS_RECSYN, VAL_USMARC);
            m_marcxml_flag = 1;
        }
        else if (err)
@@ -1402,12 +1462,12 @@ Z_APDU *Yaz_Proxy::handle_syntax_validation(Z_APDU *apdu)
        if (cfg)
            err = cfg->check_syntax(odr_encode(), m_default_target,
                                    pr->preferredRecordSyntax,
-                                   &addinfo);
+                                   pr->recordComposition,
+                                   &addinfo, &m_stylesheet);
        if (err == -1)
        {
            pr->preferredRecordSyntax =
-               yaz_oidval_to_z3950oid(odr_decode(), CLASS_RECSYN,
-                                      VAL_USMARC);
+               yaz_oidval_to_z3950oid(odr_decode(), CLASS_RECSYN, VAL_USMARC);
            m_marcxml_flag = 1;
        }
        else if (err)
@@ -1428,10 +1488,20 @@ Z_APDU *Yaz_Proxy::handle_syntax_validation(Z_APDU *apdu)
     return apdu;
 }
 
+Z_ElementSetNames *Yaz_Proxy::mk_esn_from_schema(ODR o, const char *schema)
+{
+    if (!schema)
+       return 0;
+    Z_ElementSetNames *esn = (Z_ElementSetNames *)
+       odr_malloc(o, sizeof(Z_ElementSetNames));
+    esn->which = Z_ElementSetNames_generic;
+    esn->u.generic = odr_strdup(o, schema);
+    return esn;
+}
+
 void Yaz_Proxy::handle_incoming_HTTP(Z_HTTP_Request *hreq)
 {
-    Z_SRW_PDU *srw_pdu = 0;
-    char *soap_ns = 0;
+
     if (m_s2z_odr_init)
     {
        odr_destroy(m_s2z_odr_init);
@@ -1464,12 +1534,17 @@ void Yaz_Proxy::handle_incoming_HTTP(Z_HTTP_Request *hreq)
         m_http_version = "1.1";
     }
 
-    if (yaz_check_for_srw(hreq, &srw_pdu, &soap_ns, odr_decode()) == 0
-       || yaz_check_for_sru(hreq, &srw_pdu, &soap_ns, odr_decode()) == 0)
+    Z_SRW_PDU *srw_pdu = 0;
+    Z_SOAP *soap_package = 0;
+    char *charset = 0;
+    if (yaz_srw_decode(hreq, &srw_pdu, &soap_package, odr_decode(),
+                      &charset) == 0
+       || yaz_sru_decode(hreq, &srw_pdu, &soap_package, odr_decode(),
+                         &charset) == 0)
     {
        m_s2z_odr_init = odr_createmem(ODR_ENCODE);
        m_s2z_odr_search = odr_createmem(ODR_ENCODE);
-       m_soap_ns = odr_strdup(m_s2z_odr_search, soap_ns);
+       m_soap_ns = odr_strdup(m_s2z_odr_search, soap_package->ns);
        m_s2z_init_apdu = 0;
        m_s2z_search_apdu = 0;
        m_s2z_present_apdu = 0;
@@ -1561,9 +1636,17 @@ void Yaz_Proxy::handle_incoming_HTTP(Z_HTTP_Request *hreq)
                    *z_searchRequest->smallSetUpperBound = max;
                    *z_searchRequest->mediumSetPresentNumber = max;
                    *z_searchRequest->largeSetLowerBound = 2000000000; // 2e9
+
                    z_searchRequest->preferredRecordSyntax =
                        yaz_oidval_to_z3950oid(m_s2z_odr_search, CLASS_RECSYN,
                                               VAL_TEXT_XML);
+                   if (srw_req->recordSchema)
+                   {
+                       z_searchRequest->smallSetElementSetNames =
+                           z_searchRequest->mediumSetElementSetNames =
+                           mk_esn_from_schema(m_s2z_odr_search,
+                                              srw_req->recordSchema);
+                   }
                }
                else   // Z39.50 present
                {
@@ -1576,6 +1659,18 @@ void Yaz_Proxy::handle_incoming_HTTP(Z_HTTP_Request *hreq)
                    z_presentRequest->preferredRecordSyntax =
                        yaz_oidval_to_z3950oid(m_s2z_odr_search, CLASS_RECSYN,
                                               VAL_TEXT_XML);
+                   z_presentRequest->recordComposition =
+                       (Z_RecordComposition *)
+                       odr_malloc(m_s2z_odr_search,
+                                  sizeof(Z_RecordComposition));
+                   if (srw_req->recordSchema)
+                   {
+                       z_presentRequest->recordComposition->which = 
+                           Z_RecordComp_simple;                    
+                       z_presentRequest->recordComposition->u.simple =
+                           mk_esn_from_schema(m_s2z_odr_search,
+                                              srw_req->recordSchema);
+                   }
                }
            }
            if (!m_client)