added xml ressources - most notably the LOC marc21-toXYZ stylesheets
authorMarc Cromme <marc@indexdata.dk>
Wed, 4 Oct 2006 11:21:47 +0000 (11:21 +0000)
committerMarc Cromme <marc@indexdata.dk>
Wed, 4 Oct 2006 11:21:47 +0000 (11:21 +0000)
added correct reading of filter_record_transform XML config files
still need to program record conversion in filter_record_transform

12 files changed:
etc/config-record-transform.xml [new file with mode: 0644]
src/filter_record_transform.cpp
src/gduutil.cpp
src/test_filter_record_transform.cpp
xml/schema/MARC21slim.xsd [new file with mode: 0644]
xml/xslt/MARC21slim2DC.xsl [new file with mode: 0644]
xml/xslt/MARC21slim2MADS.xsl [new file with mode: 0644]
xml/xslt/MARC21slim2MODS.xsl [new file with mode: 0644]
xml/xslt/MARC21slim2MODS3-1.xsl [new file with mode: 0644]
xml/xslt/MARC21slim2RDFDC.xsl [new file with mode: 0644]
xml/xslt/MARC21slim2SRWDC.xsl [new file with mode: 0644]
xml/xslt/MARC21slimUtils.xsl [new file with mode: 0644]

diff --git a/etc/config-record-transform.xml b/etc/config-record-transform.xml
new file mode 100644 (file)
index 0000000..b3e775d
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<!-- $Id: config-record-transform.xml,v 1.1 2006-10-04 11:21:47 marc Exp $ -->
+<yp2 xmlns="http://indexdata.dk/yp2/config/1">
+  <start route="start"/>
+  <filters>
+    <filter id="frontend" type="frontend_net">
+      <threads>10</threads>
+      <port>@:9000</port>
+    </filter>
+    <filter id="backend" type="z3950_client">
+     <timeout>30</timeout>
+    </filter>
+  </filters>
+  <routes>  
+    <route id="start">
+      <filter refid="frontend"/>
+      <filter type="log">
+        <message>Front</message>
+      </filter>
+      <filter type="record_transform">
+        <retrievalinfo>
+          <retrieval syntax="grs-1"/>
+          <retrieval syntax="usmarc" name="F"/>
+          <retrieval syntax="usmarc" name="B"/>
+          <retrieval syntax="xml" name="marcxml"
+                     identifier="info:srw/schema/1/marcxml-v1.1"
+                     backendsyntax="usmarc" backendname="F">
+            <convert>
+              <marc inputformat="marc" outputformat="marcxml"
+                    inputcharset="marc-8"/>
+            </convert>
+          </retrieval>
+          <retrieval syntax="xml" name="danmarc"
+                     backendsyntax="usmarc" backendname="F">
+            <convert>
+              <marc inputformat="marc" outputformat="marcxchange"
+                    inputcharset="marc-8"/>
+            </convert>
+          </retrieval>
+          <retrieval syntax="xml" name="dc"
+                     identifier="info:srw/schema/1/dc-v1.1"
+                     backendsyntax="usmarc" backendname="F">
+            <convert>
+              <marc inputformat="marc" outputformat="marcxml"
+                    inputcharset="marc-8"/>
+              <xslt stylesheet="xml/xslt/MARC21slim2DC.xsl"/>
+            </convert>
+          </retrieval>
+        </retrievalinfo>
+      </filter>
+      <filter type="log">
+        <message>Back</message>
+      </filter>
+      <filter refid="backend"/>
+      <filter type="bounce"/>
+    </route>
+  </routes>
+</yp2>
+
index 0fe086d..6201697 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: filter_record_transform.cpp,v 1.1 2006-10-03 14:04:22 marc Exp $
+/* $Id: filter_record_transform.cpp,v 1.2 2006-10-04 11:21:47 marc Exp $
    Copyright (c) 2005-2006, Index Data.
 
    See the LICENSE file for details
 #include "package.hpp"
 #include "util.hpp"
 #include "gduutil.hpp"
+#include "xmlutil.hpp"
 
 #include <yaz/zgdu.h>
+#include <yaz/retrieval.h>
 
 //#include <boost/thread/mutex.hpp>
 
@@ -29,7 +31,7 @@ namespace metaproxy_1 {
             void process(metaproxy_1::Package & package) const;
             void configure(const xmlNode * xml_node);
         private:
-
+            yaz_retrieval_t m_retrieval;
         };
     }
 }
@@ -59,110 +61,109 @@ void yf::RecordTransform::process(mp::Package &package) const
 
 
 
-yf::RecordTransform::Impl::Impl()
+yf::RecordTransform::Impl::Impl() 
 {
+    m_retrieval = yaz_retrieval_create();
+    assert(m_retrieval);
 }
 
 yf::RecordTransform::Impl::~Impl()
 { 
+    if (m_retrieval)
+        yaz_retrieval_destroy(m_retrieval);
 }
 
 void yf::RecordTransform::Impl::configure(const xmlNode *xml_node)
 {
-//    for (xml_node = xml_node->children; xml_node; xml_node = xml_node->next)
-//     {
-//         if (xml_node->type != XML_ELEMENT_NODE)
-//             continue;
-//         if (!strcmp((const char *) xml_node->name, "target"))
-//         {
-//             std::string route = mp::xml::get_route(xml_node);
-//             std::string target = mp::xml::get_text(xml_node);
-//             std::cout << "route=" << route << " target=" << target << "\n";
-//             m_p->m_target_route[target] = route;
-//         }
-//         else if (!strcmp((const char *) xml_node->name, "hideunavailable"))
-//         {
-//             m_p->m_hide_unavailable = true;
-//         }
-//         else
-//         {
-//             throw mp::filter::FilterException
-//                 ("Bad element " 
-//                  + std::string((const char *) xml_node->name)
-//                  + " in virt_db filter");
-//         }
-//     }
+    //const char *srcdir = getenv("srcdir");
+    //if (srcdir)
+    //    yaz_retrieval_set_path(m_retrieval, srcdir);
+
+    if (!xml_node)
+        throw mp::XMLError("RecordTransform filter config: empty XML DOM");
+
+    // parsing down to retrieval node, which can be any of the children nodes
+    xmlNode *retrieval_node;
+    for (retrieval_node = xml_node->children; 
+         retrieval_node; 
+         retrieval_node = retrieval_node->next)
+    {
+        if (retrieval_node->type != XML_ELEMENT_NODE)
+            continue;
+        if (0 == strcmp((const char *) retrieval_node->name, "retrievalinfo"))
+            break;
+    }
+    
+    // read configuration
+    if ( 0 != yaz_retrieval_configure(m_retrieval, retrieval_node)){
+        std::string msg("RecordTransform filter config: ");
+        msg += yaz_retrieval_get_error(m_retrieval);
+        throw mp::XMLError(msg);
+    }
 }
 
 void yf::RecordTransform::Impl::process(mp::Package &package) const
 {
 
-    Z_GDU *gdu = package.request().get();
+    Z_GDU *gdu_req = package.request().get();
     
     // only working on z3950 present packages
-    if (!gdu 
-        || !(gdu->which == Z_GDU_Z3950) 
-        || !(gdu->u.z3950->which == Z_APDU_presentRequest))
+    if (!gdu_req 
+        || !(gdu_req->which == Z_GDU_Z3950) 
+        || !(gdu_req->u.z3950->which == Z_APDU_presentRequest))
     {
         package.move();
         return;
     }
     
     // getting original present request
-    Z_PresentRequest *front_pr = gdu->u.z3950->u.presentRequest;
+    Z_PresentRequest *pr = gdu_req->u.z3950->u.presentRequest;
 
     // setting up ODR's for memory during encoding/decoding
-    mp::odr odr_de(ODR_DECODE);  
+    //mp::odr odr_de(ODR_DECODE);  
     mp::odr odr_en(ODR_ENCODE);
 
-    // now packaging the z3950 backend present request
-    Package back_package(package.session(), package.origin());
-    back_package.copy_filter(package);
-    Z_APDU *apdu = zget_APDU(odr_en, Z_APDU_presentRequest);
-
-    assert(apdu->u.presentRequest);
-
-    // z3950'fy start record position
-    //if ()
-    //    *(apdu->u.presentRequest->resultSetStartPoint) 
-    //        =
-    
-    // z3950'fy number of records requested 
-    //if ()
-    //    *(apdu->u.presentRequest->numberOfRecordsRequested) 
+    // now re-insructing the z3950 backend present request
      
     // z3950'fy record syntax
-    //if()
-    //(apdu->u.presentRequest->preferredRecordSyntax)
-    //    = yaz_oidval_to_z3950oid (odr_en, CLASS_RECSYN, VAL_TEXT_XML);
+    //Odr_oid odr_oid;
+    if(pr->preferredRecordSyntax){
+        (pr->preferredRecordSyntax)
+            = yaz_str_to_z3950oid(odr_en, CLASS_RECSYN, "xml");
+        
+        // = yaz_oidval_to_z3950oid (odr_en, CLASS_RECSYN, VAL_TEXT_XML);
+    }
+    // Odr_oid *yaz_str_to_z3950oid (ODR o, int oid_class,
+    //                                         const char *str);
+    // const char *yaz_z3950oid_to_str (Odr_oid *oid, int *oid_class);
+
 
     // z3950'fy record schema
     //if ()
     // {
-    //     apdu->u.presentRequest->recordComposition 
+    //     pr->recordComposition 
     //         = (Z_RecordComposition *) 
     //           odr_malloc(odr_en, sizeof(Z_RecordComposition));
-    //     apdu->u.presentRequest->recordComposition->which 
+    //     pr->recordComposition->which 
     //         = Z_RecordComp_simple;
-    //     apdu->u.presentRequest->recordComposition->u.simple 
+    //     pr->recordComposition->u.simple 
     //         = build_esn_from_schema(odr_en, 
     //                                 (const char *) sr_req->recordSchema); 
     // }
 
     // attaching Z3950 package to filter chain
-    back_package.request() = apdu;
+    package.request() = gdu_req;
 
     // std::cout << "z3950_present_request " << *apdu << "\n";   
 
-    // sending backend package
-    back_package.move();
+    // sending package
+    package.move();
 
    //check successful Z3950 present response
-    Z_GDU *back_gdu = back_package.response().get();
-    if (!back_gdu || back_gdu->which != Z_GDU_Z3950 
-        || back_gdu->u.z3950->which != Z_APDU_presentResponse
-        || !back_gdu->u.z3950->u.presentResponse)
+    Z_GDU *gdu_res = package.response().get();
+    if (!gdu_res || gdu_res->which != Z_GDU_Z3950 
+        || gdu_res->u.z3950->which != Z_APDU_presentResponse
+        || !gdu_res->u.z3950->u.presentResponse)
 
     {
         std::cout << "record-transform: error back present\n";
@@ -173,7 +174,7 @@ void yf::RecordTransform::Impl::process(mp::Package &package) const
 
     // everything fine, continuing
     // std::cout << "z3950_present_request OK\n";
-    // std::cout << "back z3950 " << *back_gdu << "\n";
+    // std::cout << "back z3950 " << *gdu_res << "\n";
 
 
     return;
index 373918f..c154b67 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: gduutil.cpp,v 1.13 2006-09-26 13:15:33 marc Exp $
+/* $Id: gduutil.cpp,v 1.14 2006-10-04 11:21:47 marc Exp $
    Copyright (c) 2005-2006, Index Data.
 
    See the LICENSE file for details
@@ -229,10 +229,11 @@ std::ostream& std::operator<<(std::ostream& os,  Z_APDU& zapdu)
                 os << " " << *(pr->numberOfRecordsRequested);
             else
                 os << " -";
-            //if (pr->preferredRecordSyntax)
-            //    os << " " << *(pr->preferredRecordSyntax);
-            //else
-            //    os << " -";
+            if (pr->preferredRecordSyntax)
+                //os << " " << pr->preferredRecordSyntax;
+                os << " " <<(oid_getentbyoid(pr->preferredRecordSyntax))->desc;
+            else
+                os << " -";
             //elements
             //if (pr->)
             //    os << " " << *(pr->);
index cf54ff4..8ca06f7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: test_filter_record_transform.cpp,v 1.1 2006-10-03 14:04:22 marc Exp $
+/* $Id: test_filter_record_transform.cpp,v 1.2 2006-10-04 11:21:47 marc Exp $
    Copyright (c) 2005-2006, Index Data.
 
    See the LICENSE file for details
@@ -18,6 +18,9 @@
 #define BOOST_AUTO_TEST_MAIN
 #include <boost/test/auto_unit_test.hpp>
 
+#include <iostream>
+
+
 using namespace boost::unit_test;
 
 namespace mp = metaproxy_1;
@@ -58,56 +61,67 @@ BOOST_AUTO_UNIT_TEST( test_filter_record_transform_2 )
 }
 
 
-// BOOST_AUTO_UNIT_TEST( test_filter_record_transform_3 )
-// {
+BOOST_AUTO_UNIT_TEST( test_filter_record_transform_3 )
+{
     
 
-//     try 
-//     {
-//         mp::RouterChain router;
+    try 
+    {
+        mp::RouterChain router;
         
 
-//         std::string xmlconf = 
-//             "<?xml version='1.0'?>\n"
-//             "<filter xmlns='http://indexdata.dk/yp2/config/1'\n"
-//             "        id='qrw1' type='sru_to_z3950'>\n"
-//             "</filter>\n"
-//             ;
+        std::string xmlconf = 
+            "<?xml version='1.0'?>\n"
+            "<filter xmlns='http://indexdata.dk/yp2/config/1'\n"
+            "        id='rec_trans_1' type='record_transform'>\n"
+            "<retrievalinfo>"
+            "<retrieval" 
+            " syntax=\"usmarc\""
+            " name=\"marcxml\""
+            " backendsyntax=\"usmarc\""
+            " backendname=\"marcxml\""
+            " identifier=\"info:srw/schema/1/marcxml-v1.1\""
+            ">"
+            "<convert/>"
+            "</retrieval>"
+            "</retrievalinfo>"
+            "</filter>\n"
+            ;
          
-//         //std::cout << xmlconf  << std::endl;
+        //std::cout << xmlconf  << std::endl;
 
-//         // reading and parsing XML conf
-//         xmlDocPtr doc = xmlParseMemory(xmlconf.c_str(), xmlconf.size());
-//         BOOST_CHECK(doc);
-//         xmlNode *root_element = xmlDocGetRootElement(doc);
+        // reading and parsing XML conf
+        xmlDocPtr doc = xmlParseMemory(xmlconf.c_str(), xmlconf.size());
+        BOOST_CHECK(doc);
+        xmlNode *root_element = xmlDocGetRootElement(doc);
 
-//         // creating and configuring filter
-//         mp::filter::RecordTransform f_rec_trans;
-//         f_rec_trans.configure(root_element);
+        // creating and configuring filter
+        mp::filter::RecordTransform f_rec_trans;
+        f_rec_trans.configure(root_element);
         
-//         // remeber to free XML DOM
-//         xmlFreeDoc(doc);
+        // remeber to free XML DOM
+        xmlFreeDoc(doc);
         
-//         // add only filter to router
-//         router.append(f_rec_trans);
-
-//         // start testing
-//         check_sru_to_z3950_init(router);
-//         check_sru_to_z3950_search(router, 
-//                                    "@attrset Bib-1 @attr 1=4 the", 
-//                                    "@attrset Bib-1 @attr 1=4 the");
-
-//     }
-
-//     catch (std::exception &e) {
-//         std::cout << e.what() << "\n";
-//         BOOST_CHECK (false);
-//     }
-
-//     catch ( ... ) {
-//         BOOST_CHECK (false);
-//     }
-// }
+        // add only filter to router
+        router.append(f_rec_trans);
+
+        // start testing
+        //check_sru_to_z3950_init(router);
+        //check_sru_to_z3950_search(router, 
+        //                           "@attrset Bib-1 @attr 1=4 the", 
+        //                           "@attrset Bib-1 @attr 1=4 the");
+
+    }
+
+    catch (std::exception &e) {
+        std::cout << e.what() << "\n";
+        BOOST_CHECK (false);
+    }
+
+    catch ( ... ) {
+        BOOST_CHECK (false);
+    }
+}
 
 /*
  * Local variables:
diff --git a/xml/schema/MARC21slim.xsd b/xml/schema/MARC21slim.xsd
new file mode 100644 (file)
index 0000000..06b4551
--- /dev/null
@@ -0,0 +1,137 @@
+<?xml version="1.0"?>\r
+<xsd:schema targetNamespace="http://www.loc.gov/MARC21/slim" xmlns="http://www.loc.gov/MARC21/slim" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.1" xml:lang="en">\r
+  <xsd:annotation>\r
+    <xsd:documentation>\r
+                       MARCXML: The MARC 21 XML Schema\r
+                       Prepared by Corey Keith\r
+\r
+                    August 4, 2003 - Version 1.1 - Removed import of xml namespace and the use of xml:space="preserve" attributes on the leader and controlfields. \r
+                    Whitespace preservation in these subfields is accomplished by the use of xsd:whiteSpace value="preserve"\r
+\r
+                       May 21, 2002 - Version 1.0  - Initial Release\r
+\r
+                       This schema supports XML markup of MARC21 records as specified in the MARC documentation (see www.loc.gov).  It allows tags with\r
+                       alphabetics and subfield codes that are symbols, neither of which are as yet used in  the MARC 21 communications formats, but are \r
+                       allowed by MARC 21 for local data.  The schema accommodates all types of MARC 21 records: bibliographic, holdings, bibliographic \r
+                       with embedded holdings, authority, classification, and community information.\r
+               </xsd:documentation>\r
+  </xsd:annotation>\r
+  <xsd:element name="record" type="recordType" nillable="true" id="record.e">\r
+    <xsd:annotation>\r
+      <xsd:documentation>record is a top level container element for all of the field elements which compose the record</xsd:documentation>\r
+    </xsd:annotation>\r
+  </xsd:element>\r
+  <xsd:element name="collection" type="collectionType" nillable="true" id="collection.e">\r
+    <xsd:annotation>\r
+      <xsd:documentation>collection is a top level container element for 0 or many records</xsd:documentation>\r
+    </xsd:annotation>\r
+  </xsd:element>\r
+  <xsd:complexType name="collectionType" id="collection.ct">\r
+    <xsd:sequence minOccurs="0" maxOccurs="unbounded">\r
+      <xsd:element ref="record"/>\r
+    </xsd:sequence>\r
+    <xsd:attribute name="id" type="idDataType" use="optional"/>\r
+  </xsd:complexType>\r
+  <xsd:complexType name="recordType" id="record.ct">\r
+    <xsd:sequence minOccurs="0">\r
+      <xsd:element name="leader" type="leaderFieldType"/>\r
+      <xsd:element name="controlfield" type="controlFieldType" minOccurs="0" maxOccurs="unbounded"/>\r
+      <xsd:element name="datafield" type="dataFieldType" minOccurs="0" maxOccurs="unbounded"/>\r
+    </xsd:sequence>\r
+    <xsd:attribute name="type" type="recordTypeType" use="optional"/>\r
+    <xsd:attribute name="id" type="idDataType" use="optional"/>\r
+  </xsd:complexType>\r
+  <xsd:simpleType name="recordTypeType" id="type.st">\r
+    <xsd:restriction base="xsd:NMTOKEN">\r
+      <xsd:enumeration value="Bibliographic"/>\r
+      <xsd:enumeration value="Authority"/>\r
+      <xsd:enumeration value="Holdings"/>\r
+      <xsd:enumeration value="Classification"/>\r
+      <xsd:enumeration value="Community"/>\r
+    </xsd:restriction>\r
+  </xsd:simpleType>\r
+  <xsd:complexType name="leaderFieldType" id="leader.ct">\r
+    <xsd:annotation>\r
+      <xsd:documentation>MARC21 Leader, 24 bytes</xsd:documentation>\r
+    </xsd:annotation>\r
+    <xsd:simpleContent>\r
+      <xsd:extension base="leaderDataType">\r
+        <xsd:attribute name="id" type="idDataType" use="optional"/>\r
+      </xsd:extension>\r
+    </xsd:simpleContent>\r
+  </xsd:complexType>\r
+  <xsd:simpleType name="leaderDataType" id="leader.st">\r
+    <xsd:restriction base="xsd:string">\r
+      <xsd:whiteSpace value="preserve"/>\r
+      <xsd:pattern value="[\d ]{5}[\dA-Za-z ]{1}[\dA-Za-z]{1}[\dA-Za-z ]{3}(2| )(2| )[\d ]{5}[\dA-Za-z ]{3}(4500|    )"/>\r
+    </xsd:restriction>\r
+  </xsd:simpleType>\r
+  <xsd:complexType name="controlFieldType" id="controlfield.ct">\r
+    <xsd:annotation>\r
+      <xsd:documentation>MARC21 Fields 001-009</xsd:documentation>\r
+    </xsd:annotation>\r
+    <xsd:simpleContent>\r
+      <xsd:extension base="controlDataType">\r
+        <xsd:attribute name="id" type="idDataType" use="optional"/>\r
+        <xsd:attribute name="tag" type="controltagDataType" use="required"/>\r
+      </xsd:extension>\r
+    </xsd:simpleContent>\r
+  </xsd:complexType>\r
+  <xsd:simpleType name="controlDataType" id="controlfield.st">\r
+    <xsd:restriction base="xsd:string">\r
+      <xsd:whiteSpace value="preserve"/>\r
+    </xsd:restriction>\r
+  </xsd:simpleType>\r
+  <xsd:simpleType name="controltagDataType" id="controltag.st">\r
+    <xsd:restriction base="xsd:string">\r
+      <xsd:whiteSpace value="preserve"/>\r
+      <xsd:pattern value="00[1-9A-Za-z]{1}"/>\r
+    </xsd:restriction>\r
+  </xsd:simpleType>\r
+  <xsd:complexType name="dataFieldType" id="datafield.ct">\r
+    <xsd:annotation>\r
+      <xsd:documentation>MARC21 Variable Data Fields 010-999</xsd:documentation>\r
+    </xsd:annotation>\r
+    <xsd:sequence maxOccurs="unbounded">\r
+      <xsd:element name="subfield" type="subfieldatafieldType"/>\r
+    </xsd:sequence>\r
+    <xsd:attribute name="id" type="idDataType" use="optional"/>\r
+    <xsd:attribute name="tag" type="tagDataType" use="required"/>\r
+    <xsd:attribute name="ind1" type="indicatorDataType" use="required"/>\r
+    <xsd:attribute name="ind2" type="indicatorDataType" use="required"/>\r
+  </xsd:complexType>\r
+  <xsd:simpleType name="tagDataType" id="tag.st">\r
+    <xsd:restriction base="xsd:string">\r
+      <xsd:whiteSpace value="preserve"/>\r
+      <xsd:pattern value="(0([1-9A-Z][0-9A-Z])|0([1-9a-z][0-9a-z]))|(([1-9A-Z][0-9A-Z]{2})|([1-9a-z][0-9a-z]{2}))"/>\r
+    </xsd:restriction>\r
+  </xsd:simpleType>\r
+  <xsd:simpleType name="indicatorDataType" id="ind.st">\r
+    <xsd:restriction base="xsd:string">\r
+      <xsd:whiteSpace value="preserve"/>\r
+      <xsd:pattern value="[\da-z ]{1}"/>\r
+    </xsd:restriction>\r
+  </xsd:simpleType>\r
+  <xsd:complexType name="subfieldatafieldType" id="subfield.ct">\r
+    <xsd:simpleContent>\r
+      <xsd:extension base="subfieldDataType">\r
+        <xsd:attribute name="id" type="idDataType" use="optional"/>\r
+        <xsd:attribute name="code" type="subfieldcodeDataType" use="required"/>\r
+      </xsd:extension>\r
+    </xsd:simpleContent>\r
+  </xsd:complexType>\r
+  <xsd:simpleType name="subfieldDataType" id="subfield.st">\r
+    <xsd:restriction base="xsd:string">\r
+      <xsd:whiteSpace value="preserve"/>\r
+    </xsd:restriction>\r
+  </xsd:simpleType>\r
+  <xsd:simpleType name="subfieldcodeDataType" id="code.st">\r
+    <xsd:restriction base="xsd:string">\r
+      <xsd:whiteSpace value="preserve"/>\r
+      <xsd:pattern value="[\da-z!&quot;#$%&amp;'()*+,-./:;&lt;=&gt;?{}_^`~\[\]\\]{1}"/>\r
+    </xsd:restriction>\r
+  </xsd:simpleType>\r
+  <xsd:simpleType name="idDataType" id="id.st">\r
+    <xsd:restriction base="xsd:ID"/>\r
+  </xsd:simpleType>\r
+</xsd:schema>\r
diff --git a/xml/xslt/MARC21slim2DC.xsl b/xml/xslt/MARC21slim2DC.xsl
new file mode 100644 (file)
index 0000000..8c9572d
--- /dev/null
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id: MARC21slim2DC.xsl,v 1.1 2006-10-04 11:21:48 marc 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/xml/xslt/MARC21slim2MADS.xsl b/xml/xslt/MARC21slim2MADS.xsl
new file mode 100644 (file)
index 0000000..e89f586
--- /dev/null
@@ -0,0 +1,1048 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<xsl:stylesheet version="1.0" xmlns="http://www.loc.gov/mods/v3" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="marc">\r
+  \r
+  <xsl:include href="http://www.loc.gov/marcxml/xslt/MARC21slimUtils.xsl"/>\r
+  <xsl:output method="xml" indent="yes" encoding="UTF-8"/>\r
+\r
+  <!--\r
+      adapted from MARC21Slim2MODS3.xsl ntra 7/6/05\r
+      revised rsg/jer 11/29/05\r
+  -->\r
+\r
+  <!-- authority attribute defaults to 'naf' if not set using this authority parameter, for <authority> descriptors: name, titleInfo, geographic -->\r
+  <xsl:param name="authority"/>\r
+  <xsl:variable name="auth">\r
+    <xsl:choose>\r
+      <xsl:when test="$authority">\r
+       <xsl:value-of select="$authority"/>\r
+      </xsl:when>\r
+      <xsl:otherwise>naf</xsl:otherwise>\r
+    </xsl:choose>\r
+  </xsl:variable>\r
+  <xsl:variable name="controlField008-11" select="substring(descendant-or-self::marc:controlfield[@tag=008],12,1)"/>\r
+  <xsl:variable name="controlField008-14" select="substring(descendant-or-self::marc:controlfield[@tag=008],15,1)"/>\r
+  <xsl:template match="/">\r
+    <xsl:choose>\r
+      <xsl:when test="descendant-or-self::marc:collection">\r
+       <madsCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mads http://www.loc.gov/standards/mads/mads.xsd">\r
+         <xsl:for-each select="descendant-or-self::marc:collection/marc:record">\r
+           <mads version="beta">\r
+             <xsl:call-template name="marcRecord"/>\r
+           </mads>\r
+         </xsl:for-each>\r
+       </madsCollection>\r
+      </xsl:when>\r
+      <xsl:otherwise>\r
+       <mads version="beta" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mads http://www.loc.gov/standards/mads/mads.xsd">\r
+         <xsl:for-each select="descendant-or-self::marc:record">\r
+           <xsl:call-template name="marcRecord"/>\r
+         </xsl:for-each>\r
+       </mads>\r
+      </xsl:otherwise>\r
+    </xsl:choose>\r
+  </xsl:template>\r
+\r
+  <xsl:template name="marcRecord">             \r
+    <xsl:if test="contains(marc:datafield[@tag='035'],'tea2003000479')">\r
+\r
+    </xsl:if>          \r
+    <authority>\r
+      <xsl:apply-templates select="marc:datafield[100 &lt;= @tag  and @tag &lt; 200]"/>\r
+    </authority>\r
+    <!-- related -->\r
+    <xsl:apply-templates select="marc:datafield[500 &lt;= @tag and @tag &lt;= 585]|marc:datafield[700 &lt;= @tag and @tag &lt;= 785]"/>\r
+\r
+    <!-- variant -->\r
+    <xsl:apply-templates select="marc:datafield[400 &lt;= @tag and @tag &lt;= 485]"/>\r
+    <!-- notes -->\r
+    <xsl:apply-templates select="marc:datafield[667 &lt;= @tag and @tag &lt;= 688]"/>\r
+    <!-- url -->\r
+    <xsl:apply-templates select="marc:datafield[@tag=856]"/>\r
+    <recordInfo>\r
+      <xsl:apply-templates select="marc:datafield[@tag=010]"/>\r
+      <xsl:apply-templates select="marc:datafield[@tag=024]"/>\r
+      <xsl:apply-templates select="marc:datafield[@tag=040]/marc:subfield[@code='a']"/>\r
+      <xsl:apply-templates select="marc:controlfield[@tag=008]"/>\r
+      <xsl:apply-templates select="marc:controlfield[@tag=005]"/>\r
+      <xsl:apply-templates select="marc:controlfield[@tag=001]"/>\r
+      <xsl:apply-templates select="marc:datafield[@tag=040]/marc:subfield[@code='b']"/>\r
+    </recordInfo>\r
+  </xsl:template>\r
+\r
+  <!-- start of secondary templates -->\r
+\r
+  <!-- ======== xlink ======== -->\r
+\r
+   <!-- <xsl:template name="uri"> \r
+    <xsl:for-each select="marc:subfield[@code='0']">\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 match="marc:subfield[@code='i']">\r
+    <xsl:attribute name="type">\r
+      <xsl:value-of select="."/>\r
+    </xsl:attribute>\r
+  </xsl:template>\r
+\r
+  <xsl:template name="role">\r
+    <xsl:for-each select="marc:subfield[@code='e']">\r
+      <role>\r
+       <roleTerm type="text">\r
+         <xsl:value-of select="."/>\r
+       </roleTerm>\r
+      </role>\r
+    </xsl:for-each>\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:call-template name="chopPunctuation">\r
+         <xsl:with-param name="chopString" select="$partNumber"/>\r
+       </xsl:call-template>\r
+      </partNumber>\r
+    </xsl:if>\r
+    <xsl:if test="string-length(normalize-space($partName))">\r
+      <partName>\r
+       <xsl:call-template name="chopPunctuation">\r
+         <xsl:with-param name="chopString" select="$partName"/>\r
+       </xsl:call-template>\r
+      </partName>\r
+    </xsl:if>\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">aq</xsl:with-param>\r
+         </xsl:call-template>\r
+       </xsl:with-param>\r
+      </xsl:call-template>\r
+    </namePart>\r
+    <xsl:call-template name="termsOfAddress"/>\r
+    <xsl:call-template name="nameDate"/>\r
+  </xsl:template>\r
+\r
+  <xsl:template name="nameACDENQ">\r
+    <namePart>\r
+      <xsl:call-template name="subfieldSelect">\r
+       <xsl:with-param name="codes">acdenq</xsl:with-param>\r
+      </xsl:call-template>\r
+    </namePart>\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="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()"/>\r
+         <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 name="termsOfAddress">\r
+    <xsl:if test="marc:subfield[@code='b' or @code='c']">\r
+      <namePart type="termsOfAddress">\r
+       <xsl:call-template name="chopPunctuation">\r
+         <xsl:with-param name="chopString">\r
+           <xsl:call-template name="subfieldSelect">\r
+             <xsl:with-param name="codes">bc</xsl:with-param>\r
+           </xsl:call-template>\r
+         </xsl:with-param>\r
+       </xsl:call-template>\r
+      </namePart>\r
+    </xsl:if>\r
+  </xsl:template>\r
+\r
+  <xsl:template name="displayLabel">\r
+    <xsl:if test="marc:subfield[@code='z']">\r
+      <xsl:attribute name="displayLabel">\r
+       <xsl:value-of select="marc:subfield[@code='z']"/>\r
+      </xsl:attribute>\r
+    </xsl:if>\r
+    <xsl:if test="marc:subfield[@code='3']">\r
+      <xsl:attribute name="displayLabel">\r
+       <xsl:value-of select="marc:subfield[@code='3']"/>\r
+      </xsl:attribute>\r
+    </xsl:if>\r
+  </xsl:template>\r
+\r
+  <xsl:template name="isInvalid">\r
+    <xsl:if test="marc:subfield[@code='z']">\r
+      <xsl:attribute name="invalid">yes</xsl:attribute>\r
+    </xsl:if>\r
+  </xsl:template>\r
+\r
+  <xsl:template name="sub2Attribute">\r
+    <!-- 024 -->\r
+    <xsl:if test="marc:subfield[@code='2']">\r
+      <xsl:attribute name="type">\r
+       <xsl:value-of select="marc:subfield[@code='2']"/>\r
+      </xsl:attribute>\r
+    </xsl:if>\r
+  </xsl:template>\r
+  <xsl:template match="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:template>\r
+\r
+  <xsl:template match="marc:controlfield[@tag=005]">\r
+    <recordChangeDate encoding="iso8601">\r
+      <xsl:value-of select="."/>\r
+    </recordChangeDate>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:controlfield[@tag=008]">\r
+    <recordCreationDate encoding="marc">\r
+      <xsl:value-of select="substring(.,1,6)"/>\r
+    </recordCreationDate>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=010]">\r
+    <identifier>\r
+      <xsl:call-template name="isInvalid"/>\r
+      <xsl:call-template name="sub2Attribute"/>\r
+      <xsl:value-of select="marc:subfield[@code='a']"/>\r
+    </identifier>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=024]">\r
+    <identifier>\r
+      <xsl:call-template name="isInvalid"/>\r
+      <xsl:call-template name="sub2Attribute"/>\r
+      <xsl:value-of select="marc:subfield[@code='a']"/>\r
+    </identifier>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=040]/marc:subfield[@code='a']">\r
+    <recordContentSource authority="marcorg">\r
+      <xsl:value-of select="."/>\r
+    </recordContentSource>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=040]/marc:subfield[@code='b']">\r
+    <languageOfCataloging>\r
+      <languageTerm authority="iso639-2b" type="code">\r
+       <xsl:value-of select="."/>\r
+      </languageTerm>\r
+    </languageOfCataloging>\r
+  </xsl:template>\r
+  \r
+  <!-- ========== names  ========== -->\r
+  <xsl:template match="marc:datafield[@tag=100]">\r
+    <name type="personal">                     \r
+      <xsl:call-template name="setAuthority"/>\r
+      <xsl:call-template name="nameABCDQ"/>\r
+      <xsl:call-template name="role"/>         \r
+    </name>\r
+    <xsl:apply-templates select="*[marc:subfield[not(contains('abcdeq',@code))]]"/>\r
+    <xsl:call-template name="title"/>\r
+    <xsl:apply-templates/>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=110]">\r
+    <name type="corporate">\r
+      <xsl:call-template name="setAuthority"/>\r
+      <xsl:call-template name="nameABCDN"/>\r
+      <xsl:call-template name="role"/>\r
+    </name>\r
+    <xsl:apply-templates/>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=111]">\r
+    <name type="conference">\r
+      <xsl:call-template name="setAuthority"/>                 \r
+      <xsl:call-template name="nameACDENQ"/>\r
+    </name>\r
+    <xsl:apply-templates/>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=400]">\r
+    <variant>\r
+      <xsl:call-template name="variantTypeAttribute"/>\r
+      <name type="personal">\r
+       <xsl:call-template name="nameABCDQ"/>\r
+       <xsl:call-template name="role"/>\r
+      </name>\r
+      <xsl:apply-templates/>\r
+      <xsl:call-template name="title"/>\r
+    </variant>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=410]">\r
+    <variant>\r
+      <xsl:call-template name="variantTypeAttribute"/>\r
+      <name type="corporate">\r
+       <xsl:call-template name="nameABCDN"/>\r
+       <xsl:call-template name="role"/>                                \r
+      </name>\r
+      <xsl:apply-templates/>\r
+    </variant>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=411]">\r
+    <variant>\r
+      <xsl:call-template name="variantTypeAttribute"/>\r
+      <name type="conference">\r
+       <xsl:call-template name="nameACDENQ"/>\r
+      </name>\r
+      <xsl:apply-templates/>\r
+    </variant>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=500]|marc:datafield[@tag=700]">\r
+    <related>\r
+      <xsl:call-template name="relatedTypeAttribute"/>\r
+      <!-- <xsl:call-template name="uri"/> -->         \r
+      <name type="personal">\r
+       <xsl:call-template name="setAuthority"/>                                                                \r
+       <xsl:call-template name="nameABCDQ"/>\r
+       <xsl:call-template name="role"/>                                \r
+      </name>\r
+      <xsl:call-template name="title"/>\r
+      <xsl:apply-templates/>\r
+    </related>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=510]|marc:datafield[@tag=710]">\r
+    <related>\r
+      <xsl:call-template name="relatedTypeAttribute"/>\r
+      <!-- <xsl:call-template name="uri"/> -->\r
+      <name type="corporate">\r
+       <xsl:call-template name="setAuthority"/>\r
+       <xsl:call-template name="nameABCDN"/>\r
+       <xsl:call-template name="role"/>\r
+      </name>\r
+      <xsl:apply-templates/>\r
+    </related>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=511]|marc:datafield[@tag=711]">\r
+    <related>\r
+      <xsl:call-template name="relatedTypeAttribute"/>\r
+      <!-- <xsl:call-template name="uri"/> -->\r
+      <name type="conference">\r
+       <xsl:call-template name="setAuthority"/>\r
+       <xsl:call-template name="nameACDENQ"/>\r
+      </name>\r
+      <xsl:apply-templates/>\r
+    </related>\r
+  </xsl:template>\r
+\r
+  <!-- ========== titles  ========== -->\r
+  <xsl:template match="marc:datafield[@tag=130]">\r
+    <xsl:call-template name="uniform-title"/>\r
+    <xsl:apply-templates/>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=430]">\r
+    <variant>\r
+      <xsl:call-template name="variantTypeAttribute"/>\r
+      <xsl:call-template name="uniform-title"/>\r
+      <xsl:apply-templates/>\r
+    </variant>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=530]|marc:datafield[@tag=730]">\r
+    <related>\r
+      <xsl:call-template name="relatedTypeAttribute"/>                 \r
+      <xsl:call-template name="uniform-title"/>\r
+      <xsl:apply-templates/>\r
+    </related>\r
+  </xsl:template>\r
+\r
+  <xsl:template name="title">\r
+    <titleInfo>\r
+      <xsl:call-template name="setAuthority"/>\r
+      <title>\r
+       <xsl:variable name="str">\r
+         <xsl:for-each select="marc:subfield">\r
+           <xsl:if test="(contains('tfghklmors',@code) )">\r
+             <xsl:value-of select="text()"/>\r
+             <xsl:text> </xsl:text>\r
+           </xsl:if>\r
+         </xsl:for-each>\r
+       </xsl:variable>\r
+\r
+       <xsl:call-template name="chopPunctuation">\r
+         <xsl:with-param name="chopString">\r
+           <xsl:value-of select="substring($str,1,string-length($str)-1)"/>\r
+         </xsl:with-param>\r
+       </xsl:call-template>\r
+      </title>\r
+      <xsl:call-template name="part"/>\r
+      <!-- <xsl:call-template name="uri"/> -->\r
+    </titleInfo>\r
+  </xsl:template>\r
+\r
+  <xsl:template name="uniform-title">\r
+    <titleInfo>\r
+      <xsl:call-template name="setAuthority"/>\r
+      <title>\r
+       <xsl:variable name="str">\r
+         <xsl:for-each select="marc:subfield">\r
+           <xsl:if test="(contains('adfghklmors',@code) )">\r
+             <xsl:value-of select="text()"/>\r
+             <xsl:text> </xsl:text>\r
+           </xsl:if>\r
+         </xsl:for-each>\r
+       </xsl:variable>\r
+\r
+       <xsl:call-template name="chopPunctuation">\r
+         <xsl:with-param name="chopString">\r
+           <xsl:value-of select="substring($str,1,string-length($str)-1)"/>\r
+         </xsl:with-param>\r
+       </xsl:call-template>\r
+      </title>\r
+      <xsl:call-template name="part"/>\r
+      <!-- <xsl:call-template name="uri"/> -->\r
+    </titleInfo>\r
+  </xsl:template>\r
+\r
+\r
+  <!-- ========== topics  ========== -->\r
+  <xsl:template match="marc:subfield[@code='x']">              \r
+    <topic>\r
+      <xsl:call-template name="chopPunctuation">\r
+       <xsl:with-param name="chopString">\r
+         <xsl:value-of select="."/>\r
+       </xsl:with-param>\r
+      </xsl:call-template>\r
+    </topic>\r
+  </xsl:template>\r
+  \r
+  <xsl:template match="marc:datafield[@tag=150][marc:subfield[@code='a' or @code='b']]|marc:datafield[@tag=180][marc:subfield[@code='x']]">\r
+    <xsl:call-template name="topic"/>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=450][marc:subfield[@code='a' or @code='b']]|marc:datafield[@tag=480][marc:subfield[@code='x']]">\r
+    <variant>\r
+      <xsl:call-template name="variantTypeAttribute"/>\r
+      <xsl:call-template name="topic"/>\r
+    </variant>\r
+  </xsl:template>\r
+  \r
+  <xsl:template match="marc:datafield[@tag=550 or @tag=750][marc:subfield[@code='a' or @code='b']]">\r
+    <related>                  \r
+      <xsl:call-template name="relatedTypeAttribute"/>\r
+      <!-- <xsl:call-template name="uri"/> -->\r
+      <xsl:call-template name="topic"/>\r
+    </related>\r
+  </xsl:template> \r
+\r
+  <xsl:template name="topic">\r
+    <topic>                            \r
+      <xsl:if test="@tag=550 or @tag=750">\r
+       <xsl:call-template name="subfieldSelect">\r
+         <xsl:with-param name="codes">ab</xsl:with-param>\r
+       </xsl:call-template>\r
+      </xsl:if>\r
+      <xsl:call-template name="setAuthority"/>\r
+      <xsl:call-template name="chopPunctuation">\r
+       <xsl:with-param name="chopString">\r
+         <xsl:choose>\r
+           <xsl:when test="@tag=180 or @tag=480 or @tag=580 or @tag=780">\r
+             <xsl:apply-templates select="marc:subfield[@code='x']"/>\r
+           </xsl:when>\r
+           <xsl:otherwise>\r
+             <xsl:call-template name="subfieldSelect">\r
+               <xsl:with-param name="codes">ab</xsl:with-param>\r
+             </xsl:call-template>\r
+           </xsl:otherwise>\r
+         </xsl:choose>\r
+       </xsl:with-param>\r
+      </xsl:call-template>\r
+    </topic>\r
+    <xsl:apply-templates/>\r
+  </xsl:template>\r
+\r
+  <!-- ========= temporals  ========== -->\r
+\r
+  <xsl:template match="marc:subfield[@code='y']">\r
+    <temporal>\r
+      <xsl:call-template name="chopPunctuation">\r
+       <xsl:with-param name="chopString">\r
+         <xsl:value-of select="."/>\r
+       </xsl:with-param>\r
+      </xsl:call-template>\r
+    </temporal>\r
+  </xsl:template>\r
+  \r
+  <xsl:template match="marc:datafield[@tag=148][marc:subfield[@code='a']]|marc:datafield[@tag=182 ][marc:subfield[@code='y']]">\r
+    <xsl:call-template name="temporal"/>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=448][marc:subfield[@code='a']]|marc:datafield[@tag=482][marc:subfield[@code='y']]">\r
+    <variant>\r
+      <xsl:call-template name="variantTypeAttribute"/>\r
+      <xsl:call-template name="temporal"/>\r
+    </variant>\r
+  </xsl:template>\r
+  \r
+  <xsl:template match="marc:datafield[@tag=548 or @tag=748][marc:subfield[@code='a']]|marc:datafield[@tag=582 or @tag=782][marc:subfield[@code='y']]">\r
+    <related>\r
+      <xsl:call-template name="relatedTypeAttribute"/>\r
+      <!-- <xsl:call-template name="uri"/> -->\r
+      <xsl:call-template name="temporal"/>\r
+    </related>\r
+  </xsl:template>\r
+  \r
+  <xsl:template name="temporal">\r
+    <temporal>\r
+      <xsl:if test="@tag=548 or @tag=748">\r
+       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+      </xsl:if>\r
+      <xsl:call-template name="setAuthority"/>\r
+      <xsl:call-template name="chopPunctuation">\r
+       <xsl:with-param name="chopString">\r
+         <xsl:choose>\r
+           <xsl:when test="@tag=182 or @tag=482 or @tag=582 or @tag=782">\r
+             <xsl:apply-templates select="marc:subfield[@code='y']"/>\r
+           </xsl:when>\r
+           <xsl:otherwise>\r
+             <xsl:value-of select="marc:subfield[@code='a']"/>\r
+           </xsl:otherwise>\r
+         </xsl:choose> \r
+       </xsl:with-param>\r
+      </xsl:call-template>\r
+    </temporal>\r
+    <xsl:apply-templates/>\r
+  </xsl:template>\r
+\r
+  <!-- ========== genre  ========== -->\r
+  <xsl:template match="marc:subfield[@code='v']">\r
+    <genre>\r
+      <xsl:call-template name="chopPunctuation">\r
+       <xsl:with-param name="chopString">\r
+         <xsl:value-of select="."/>\r
+       </xsl:with-param>\r
+      </xsl:call-template>\r
+    </genre>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=155][marc:subfield[@code='a']]|marc:datafield[@tag=185][marc:subfield[@code='v']]">\r
+    <xsl:call-template name="genre"/>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=455][marc:subfield[@code='a']]|marc:datafield[@tag=485 ][marc:subfield[@code='v']]">\r
+    <variant>\r
+      <xsl:call-template name="variantTypeAttribute"/>\r
+      <xsl:call-template name="genre"/>\r
+    </variant>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=555]">\r
+    <related>\r
+      <xsl:call-template name="relatedTypeAttribute"/>\r
+      <!-- <xsl:call-template name="uri"/> -->\r
+      <xsl:call-template name="genre"/>\r
+    </related>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=555 or @tag=755][marc:subfield[@code='a']]|marc:datafield[@tag=585][marc:subfield[@code='v']]">\r
+    <related>\r
+      <xsl:call-template name="relatedTypeAttribute"/>\r
+      <xsl:call-template name="genre"/>\r
+    </related>\r
+  </xsl:template>\r
+\r
+  <xsl:template name="genre">\r
+    <genre>\r
+      <xsl:if test="@tag=555">\r
+       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+      </xsl:if>\r
+      <xsl:call-template name="setAuthority"/>\r
+      <xsl:call-template name="chopPunctuation">\r
+       <xsl:with-param name="chopString">\r
+         <xsl:choose>\r
+           <xsl:when test="@tag=185 or @tag=485 or @tag=585">\r
+             <xsl:apply-templates select="marc:subfield[@code='v']"/>\r
+           </xsl:when>\r
+           <xsl:otherwise>\r
+             <xsl:value-of select="marc:subfield[@code='a']"/>\r
+           </xsl:otherwise>\r
+         </xsl:choose>\r
+       </xsl:with-param>\r
+      </xsl:call-template>                                     \r
+    </genre>\r
+    <xsl:apply-templates/>\r
+  </xsl:template> \r
+  \r
+  <!-- ========= geographic  ========== -->\r
+  <xsl:template match="marc:subfield[@code='z']">\r
+    <geographic>\r
+      <xsl:call-template name="chopPunctuation">\r
+       <xsl:with-param name="chopString">\r
+         <xsl:value-of select="."/>\r
+       </xsl:with-param>\r
+      </xsl:call-template>\r
+    </geographic>\r
+  </xsl:template>\r
+\r
+  <xsl:template name="geographic">             \r
+    <geographic>                                       \r
+      <xsl:if test="@tag=551">\r
+       <xsl:value-of select="marc:subfield[@code='a']"/>\r
+      </xsl:if> \r
+      <xsl:call-template name="setAuthority"/>\r
+      <xsl:call-template name="chopPunctuation">\r
+       <xsl:with-param name="chopString">\r
+         <xsl:choose>\r
+           <xsl:when test="@tag=181 or @tag=481 or @tag=581">\r
+             <xsl:apply-templates select="marc:subfield[@code='z']"/>\r
+           </xsl:when>\r
+           <xsl:otherwise>\r
+             <xsl:value-of select="marc:subfield[@code='a']"/>\r
+           </xsl:otherwise>\r
+         </xsl:choose>\r
+       </xsl:with-param>\r
+      </xsl:call-template>                                             \r
+    </geographic>\r
+    <xsl:apply-templates/>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=151][marc:subfield[@code='a']]|marc:datafield[@tag=181][marc:subfield[@code='z']]">\r
+    <xsl:call-template name="geographic"/>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=451][marc:subfield[@code='a']]|marc:datafield[@tag=481][marc:subfield[@code='z']]">\r
+    <variant>\r
+      <xsl:call-template name="variantTypeAttribute"/>\r
+      <xsl:call-template name="geographic"/>                   \r
+    </variant>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=551]|marc:datafield[@tag=581][marc:subfield[@code='z']]">\r
+    <related>\r
+      <xsl:call-template name="relatedTypeAttribute"/>\r
+      <!-- <xsl:call-template name="uri"/> -->\r
+      <xsl:call-template name="geographic"/>\r
+    </related>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=580]">\r
+    <related>\r
+      <xsl:call-template name="relatedTypeAttribute"/>\r
+      <xsl:apply-templates/>\r
+    </related>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=751][marc:subfield[@code='z']]|marc:datafield[@tag=781][marc:subfield[@code='z']]">\r
+    <related>\r
+      <xsl:call-template name="relatedTypeAttribute"/>\r
+      <xsl:call-template name="geographic"/>   \r
+    </related>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=755]">\r
+    <related>\r
+      <xsl:call-template name="relatedTypeAttribute"/>\r
+      <xsl:call-template name="genre"/>        \r
+      <xsl:call-template name="setAuthority"/>\r
+      <xsl:apply-templates/>\r
+    </related>\r
+  </xsl:template> \r
+\r
+  <xsl:template match="marc:datafield[@tag=780]">\r
+    <related>\r
+      <xsl:call-template name="relatedTypeAttribute"/>\r
+      <xsl:apply-templates/>\r
+    </related>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="marc:datafield[@tag=785]">\r
+    <related>\r
+      <xsl:call-template name="relatedTypeAttribute"/>\r
+      <xsl:apply-templates/>\r
+    </related>\r
+  </xsl:template>\r
+\r
+  <!-- ========== notes  ========== -->\r
+  <xsl:template match="marc:datafield[667 &lt;= @tag and @tag &lt;= 688]">\r
+    <note>\r
+      <xsl:choose>\r
+       <xsl:when test="@tag=667">\r
+         <xsl:attribute name="type">nonpublic</xsl:attribute>\r
+       </xsl:when>\r
+       <xsl:when test="@tag=670">\r
+         <xsl:attribute name="type">source</xsl:attribute>\r
+       </xsl:when>\r
+       <xsl:when test="@tag=675">\r
+         <xsl:attribute name="type">notFound</xsl:attribute>\r
+       </xsl:when>\r
+       <xsl:when test="@tag=678">\r
+         <xsl:attribute name="type">history</xsl:attribute>\r
+       </xsl:when>\r
+       <xsl:when test="@tag=681">\r
+         <xsl:attribute name="type">subject example</xsl:attribute>\r
+       </xsl:when>\r
+       <xsl:when test="@tag=682">\r
+         <xsl:attribute name="type">deleted heading information</xsl:attribute>\r
+       </xsl:when>\r
+       <xsl:when test="@tag=688">\r
+         <xsl:attribute name="type">application history</xsl:attribute>\r
+       </xsl:when>\r
+      </xsl:choose>\r
+      <xsl:call-template name="chopPunctuation">\r
+       <xsl:with-param name="chopString">\r
+         <xsl:choose>\r
+           <xsl:when test="@tag=667 or @tag=675">\r
+             <xsl:value-of select="marc:subfield[@code='a']"/>\r
+           </xsl:when>\r
+           <xsl:when test="@tag=670 or @tag=678">\r
+             <xsl:call-template name="subfieldSelect">\r
+               <xsl:with-param name="codes">ab</xsl:with-param>\r
+             </xsl:call-template>\r
+           </xsl:when>\r
+           <xsl:when test="680 &lt;= @tag and @tag &lt;=688">\r
+             <xsl:call-template name="subfieldSelect">\r
+               <xsl:with-param name="codes">ai</xsl:with-param>\r
+             </xsl:call-template>\r
+           </xsl:when>\r
+         </xsl:choose>\r
+       </xsl:with-param>\r
+      </xsl:call-template>\r
+    </note>\r
+  </xsl:template>\r
+  <!-- ========== url  ========== -->\r
+  <xsl:template match="marc:datafield[@tag=856][marc:subfield[@code='u']]">\r
+    <url>\r
+      <xsl:if test="marc:subfield[@code='z' or @code='3']">\r
+       <xsl:attribute name="displayLabel">\r
+         <xsl:call-template name="subfieldSelect">\r
+           <xsl:with-param name="codes">z3</xsl:with-param>\r
+         </xsl:call-template>\r
+       </xsl:attribute>\r
+      </xsl:if>\r
+      <xsl:value-of select="marc:subfield[@code='u']"/>\r
+    </url>\r
+  </xsl:template>\r
+\r
+  <xsl:template name="relatedTypeAttribute">\r
+    <xsl:choose>\r
+      <xsl:when test="@tag=500 or @tag=510 or @tag=511 or @tag=548 or @tag=550 or @tag=551 or @tag=555 or @tag=580 or @tag=581 or @tag=582 or @tag=585">\r
+       <xsl:if test="substring(marc:subfield[@code='w'],1,1)='a'">\r
+         <xsl:attribute name="type">earlier</xsl:attribute>\r
+       </xsl:if>\r
+       <xsl:if test="substring(marc:subfield[@code='w'],1,1)='b'">\r
+         <xsl:attribute name="type">later</xsl:attribute>\r
+       </xsl:if>\r
+       <xsl:if test="substring(marc:subfield[@code='w'],1,1)='t'">\r
+         <xsl:attribute name="type">parentOrg</xsl:attribute>\r
+       </xsl:if>\r
+       <xsl:if test="substring(marc:subfield[@code='w'],1,1)='g'">\r
+         <xsl:attribute name="type">broader</xsl:attribute>\r
+       </xsl:if>\r
+       <xsl:if test="substring(marc:subfield[@code='w'],1,1)='h'">\r
+         <xsl:attribute name="type">narrower</xsl:attribute>\r
+       </xsl:if>\r
+       <xsl:if test="contains('fin|', substring(marc:subfield[@code='w'],1,1))">\r
+         <xsl:attribute name="type">other</xsl:attribute>\r
+       </xsl:if>\r
+      </xsl:when>\r
+      <xsl:when test="@tag=530 or @tag=730">\r
+       <xsl:attribute name="type">other</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:otherwise>\r
+       <!-- 7xx -->\r
+       <xsl:attribute name="type">equivalent</xsl:attribute>\r
+      </xsl:otherwise>\r
+    </xsl:choose>\r
+    <xsl:apply-templates select="marc:subfield[@code='i']"/>\r
+  </xsl:template>\r
+\r
+  <xsl:template name="variantTypeAttribute">\r
+    <xsl:choose>\r
+      <xsl:when test="@tag=400 or @tag=410 or @tag=411 or @tag=451 or @tag=455 or @tag=480 or @tag=481 or @tag=482 or @tag=485">\r
+       <xsl:if test="substring(marc:subfield[@code='w'],1,1)='d'">\r
+         <xsl:attribute name="type">acronym</xsl:attribute>\r
+       </xsl:if>\r
+       <xsl:if test="contains('fit', substring(marc:subfield[@code='w'],1,1))">\r
+         <xsl:attribute name="type">other</xsl:attribute>\r
+       </xsl:if>\r
+      </xsl:when>\r
+      <xsl:otherwise>\r
+       <!-- 430  -->\r
+       <xsl:attribute name="type">other</xsl:attribute>\r
+      </xsl:otherwise>\r
+    </xsl:choose>\r
+    <xsl:apply-templates select="marc:subfield[@code='i']"/>\r
+  </xsl:template>\r
+  <xsl:template name="setAuthority">\r
+    <xsl:choose>\r
+      <!-- can be called from the datafield or subfield level, so "..//@tag" means\r
+          the tag can be at the subfield's parent level or at the datafields own level -->\r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=100 and (@ind1=0 or @ind1=1) and $controlField008-11='a' and $controlField008-14='a'">   \r
+       <xsl:attribute name="authority"><xsl:text>naf</xsl:text></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=100 and (@ind1=0 or @ind1=1) and $controlField008-11='a' and $controlField008-14='b'">   \r
+       <xsl:attribute name="authority"><xsl:text>lcsh</xsl:text></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=100 and (@ind1=0 or @ind1=1) and $controlField008-11='k'">   \r
+       <xsl:attribute name="authority"><xsl:text>lacnaf</xsl:text></xsl:attribute>\r
+      </xsl:when>   \r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=100 and @ind1=3 and $controlField008-11='a' and $controlField008-14='b'">\r
+       <xsl:attribute name="authority"><xsl:text>lcsh</xsl:text></xsl:attribute>\r
+      </xsl:when>   \r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=100 and @ind1=3 and $controlField008-11='k' and $controlField008-14='b'">\r
+       <xsl:attribute name="authority">cash</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='a' and $controlField008-14='a'">\r
+       <xsl:attribute name="authority">naf</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='a' and $controlField008-14='b'">\r
+       <xsl:attribute name="authority">lcsh</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='k' and $controlField008-14='a'">\r
+       <xsl:attribute name="authority"><xsl:text>lacnaf</xsl:text></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=110 and $controlField008-11='k' and $controlField008-14='b'">\r
+       <xsl:attribute name="authority"><xsl:text>cash</xsl:text></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='b'">\r
+       <xsl:attribute name="authority"><xsl:text>lcshcl</xsl:text></xsl:attribute>\r
+      </xsl:when>   \r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=100 or ancestor-or-self::marc:datafield/@tag=110 or ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130 or ancestor-or-self::marc:datafield/@tag=151) and $controlField008-11='c'">\r
+       <xsl:attribute name="authority"><xsl:text>nlmnaf</xsl:text></xsl:attribute>\r
+      </xsl:when>   \r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=100 or ancestor-or-self::marc:datafield/@tag=110 or ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130 or ancestor-or-self::marc:datafield/@tag=151) and $controlField008-11='d'">   \r
+       <xsl:attribute name="authority"><xsl:text>nalnaf</xsl:text></xsl:attribute>\r
+      </xsl:when>   \r
+      <xsl:when test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='r'">\r
+       <xsl:attribute name="authority"><xsl:text>aat</xsl:text></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='s'">\r
+       <xsl:attribute name="authority">sears</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='v'">\r
+       <xsl:attribute name="authority">rvm</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="100 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 155 and $controlField008-11='z'">\r
+       <xsl:attribute name="authority"><xsl:value-of select="../marc:datafield[ancestor-or-self::marc:datafield/@tag=040]/marc:subfield[@code='f']"/></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130) and $controlField008-11='a' and $controlField008-14='a'">\r
+       <xsl:attribute name="authority"><xsl:text>naf</xsl:text></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130) and $controlField008-11='a' and $controlField008-14='b'">\r
+       <xsl:attribute name="authority"><xsl:text>lcsh</xsl:text></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=111 or ancestor-or-self::marc:datafield/@tag=130) and $controlField008-11='k' ">\r
+       <xsl:attribute name="authority"><xsl:text>lacnaf</xsl:text></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=148 or ancestor-or-self::marc:datafield/@tag=150  or ancestor-or-self::marc:datafield/@tag=155) and $controlField008-11='a' ">\r
+       <xsl:attribute name="authority"><xsl:text>lcsh</xsl:text></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=148 or ancestor-or-self::marc:datafield/@tag=150  or ancestor-or-self::marc:datafield/@tag=155) and $controlField008-11='a' ">\r
+       <xsl:attribute name="authority"><xsl:text>lcsh</xsl:text></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=148 or ancestor-or-self::marc:datafield/@tag=150  or ancestor-or-self::marc:datafield/@tag=155) and $controlField008-11='c' ">\r
+       <xsl:attribute name="authority"><xsl:text>mesh</xsl:text></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=148 or ancestor-or-self::marc:datafield/@tag=150  or ancestor-or-self::marc:datafield/@tag=155) and $controlField008-11='d' ">\r
+       <xsl:attribute name="authority"><xsl:text>nal</xsl:text></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=148 or ancestor-or-self::marc:datafield/@tag=150  or ancestor-or-self::marc:datafield/@tag=155) and $controlField008-11='k' ">\r
+       <xsl:attribute name="authority"><xsl:text>cash</xsl:text></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='a' and $controlField008-14='a'">\r
+       <xsl:attribute name="authority"><xsl:text>naf</xsl:text></xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='a' and $controlField008-14='b'">\r
+       <xsl:attribute name="authority">lcsh</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='k' and $controlField008-14='a'">\r
+       <xsl:attribute name="authority">lacnaf</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=151 and $controlField008-11='k' and $controlField008-14='b'">\r
+       <xsl:attribute name="authority">cash</xsl:attribute>\r
+      </xsl:when>\r
+      \r
+      <xsl:when test="(..//ancestor-or-self::marc:datafield/@tag=180 or ..//ancestor-or-self::marc:datafield/@tag=181 or ..//ancestor-or-self::marc:datafield/@tag=182 or ..//ancestor-or-self::marc:datafield/@tag=185) and $controlField008-11='a'">\r
+       <xsl:attribute name="authority">lcsh</xsl:attribute>\r
+      </xsl:when>\r
+      \r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=700 and (@ind1='0' or @ind1='1') and @ind2='0'">   \r
+       <xsl:attribute name="authority">naf</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=700 and (@ind1='0' or @ind1='1') and @ind2='5'">   \r
+       <xsl:attribute name="authority">lacnaf</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=700 and @ind1='3' and @ind2='0'">   \r
+       <xsl:attribute name="authority">lcsh</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="ancestor-or-self::marc:datafield/@tag=700 and @ind1='3' and @ind2='5'">   \r
+       <xsl:attribute name="authority">cash</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(700 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 755 ) and @ind2='1'">   \r
+       <xsl:attribute name="authority">lcshcl</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=700 or ancestor-or-self::marc:datafield/@tag=710 or ancestor-or-self::marc:datafield/@tag=711 or ancestor-or-self::marc:datafield/@tag=730 or ancestor-or-self::marc:datafield/@tag=751)  and @ind2='2'">   \r
+       <xsl:attribute name="authority">nlmnaf</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=700 or ancestor-or-self::marc:datafield/@tag=710 or ancestor-or-self::marc:datafield/@tag=711 or ancestor-or-self::marc:datafield/@tag=730 or ancestor-or-self::marc:datafield/@tag=751)  and @ind2='3'">   \r
+       <xsl:attribute name="authority">nalnaf</xsl:attribute>\r
+      </xsl:when>   \r
+      <xsl:when test="(700 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 755 ) and @ind2='6'">\r
+       <xsl:attribute name="authority">rvm</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(700 &lt;= ancestor-or-self::marc:datafield/@tag and ancestor-or-self::marc:datafield/@tag &lt;= 755 ) and @ind2='7'">   \r
+       <xsl:attribute name="authority">\r
+         <xsl:value-of select="marc:subfield[@code='2']"/>\r
+       </xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=710 or ancestor-or-self::marc:datafield/@tag=711 or ancestor-or-self::marc:datafield/@tag=730 or ancestor-or-self::marc:datafield/@tag=751)  and @ind2='5'">   \r
+       <xsl:attribute name="authority">lacnaf</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=710 or ancestor-or-self::marc:datafield/@tag=711 or ancestor-or-self::marc:datafield/@tag=730 or ancestor-or-self::marc:datafield/@tag=751)  and @ind2='0'">   \r
+       <xsl:attribute name="authority">naf</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=748 or ancestor-or-self::marc:datafield/@tag=750 or ancestor-or-self::marc:datafield/@tag=755)  and @ind2='0'">  \r
+       <xsl:attribute name="authority">lcsh</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=748 or ancestor-or-self::marc:datafield/@tag=750 or ancestor-or-self::marc:datafield/@tag=755)  and @ind2='2'">  \r
+       <xsl:attribute name="authority">mesh</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=748 or ancestor-or-self::marc:datafield/@tag=750 or ancestor-or-self::marc:datafield/@tag=755)  and @ind2='3'">      \r
+       <xsl:attribute name="authority">nal</xsl:attribute>\r
+      </xsl:when>\r
+      <xsl:when test="(ancestor-or-self::marc:datafield/@tag=748 or ancestor-or-self::marc:datafield/@tag=750 or ancestor-or-self::marc:datafield/@tag=755)  and @ind2='5'">      \r
+       <xsl:attribute name="authority">cash</xsl:attribute>\r
+      </xsl:when>\r
+    </xsl:choose>\r
+  </xsl:template>\r
+\r
+  <!--<xsl:template name="oldsetAuth">\r
+      <xsl:param name="ind2"/>\r
+      <xsl:if test="100 &lt;= @tag and @tag &lt; 200">\r
+      <xsl:attribute name="authority">\r
+      <xsl:value-of select="$auth"/>\r
+      </xsl:attribute>\r
+      </xsl:if>\r
+      <xsl:if test="(700 &lt;= @tag and @tag &lt; 800) or /marc:datafield[700 &lt;=@tag and @tag &lt; 800]">\r
+      <xsl:attribute name="authority">\r
+      <xsl:choose>\r
+      <xsl:when test="$ind2='0'">naf</xsl:when>                                        \r
+      <xsl:when test="$ind2='2'">nlm</xsl:when>\r
+      <xsl:when test="$ind2='3'">nal</xsl:when>\r
+      <xsl:when test="$ind2='5'">lac</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:if>\r
+      </xsl:template>\r
+  -->\r
+  <!--<xsl:template name="oldsetAuth2">\r
+      <xsl:param name="ind2"/>\r
+      <xsl:if test="(100 &lt;= @tag and @tag &lt; 200) or ../marc:datafield[100 &lt;=@tag and @tag &lt; 200]">\r
+      <xsl:attribute name="authority">\r
+      <xsl:choose>\r
+      <xsl:when test="$controlField008-11='a'">lcsh</xsl:when>\r
+      <xsl:when test="$controlField008-11='b'">lcac</xsl:when>\r
+      <xsl:when test="$controlField008-11='c'">mesh</xsl:when>\r
+      <xsl:when test="$controlField008-11='d'">nal</xsl:when>\r
+      <xsl:when test="$controlField008-11='k'">cash</xsl:when>\r
+      <xsl:when test="$controlField008-11='r'">aat</xsl:when>\r
+      <xsl:when test="$controlField008-11='s'">sears</xsl:when>\r
+      <xsl:when test="$controlField008-11='v'">rvm</xsl:when>\r
+      <xsl:when test="$controlField008-11='z'"><xsl:value-of select="../marc:datafield[@tag=040]/marc:subfield[@code='f']"/></xsl:when>                                \r
+      </xsl:choose>\r
+      </xsl:attribute>\r
+      </xsl:if>\r
+      <xsl:if test="(500 &lt;= @tag and @tag &lt; 800) or /marc:datafield[500 &lt;=@tag and @tag &lt; 800]">\r
+      <xsl:attribute name="authority">\r
+      <xsl:choose>\r
+      <xsl:when test="$ind2='0'">lcsh</xsl:when>\r
+      <xsl:when test="$ind2='1'">lcac</xsl:when>\r
+      <xsl:when test="$ind2='2'">mesh</xsl:when>\r
+      <xsl:when test="$ind2='3'">nal</xsl:when>\r
+      <xsl:when test="$ind2='5'">cash</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:if>\r
+      </xsl:template>-->\r
+  <!--<xsl:template match="marc:subfield[@code='0']">\r
+      <xsl:attribute name="xlink:href">\r
+      <xsl:value-of select="."/>\r
+      </xsl:attribute>\r
+      </xsl:template>\r
+  -->\r
+  <xsl:template match="*"/>\r
+  <!--<xsl:template match="*">\r
+      <n><xsl:attribute name="tag"><xsl:value-of select="@tag"/></xsl:attribute>\r
+      <xsl:attribute name="code"><xsl:value-of select="@code"/></xsl:attribute>\r
+      <xsl:value-of select="name()"/>\r
+      \r
+      <v><xsl:value-of select="."/></v></n>\r
+      </xsl:template>-->\r
+</xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2003 Copyright Sonic Software Corporation. All rights reserved.\r
+                     <metaInformation>\r
+                     <scenarios ><scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="..\..\documents\mads_short.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/xml/xslt/MARC21slim2MODS.xsl b/xml/xslt/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/xml/xslt/MARC21slim2MODS3-1.xsl b/xml/xslt/MARC21slim2MODS3-1.xsl
new file mode 100644 (file)
index 0000000..225a5a0
--- /dev/null
@@ -0,0 +1,2514 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns="http://www.loc.gov/mods/v3" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xlink marc">
+       <xsl:include href="http://www.loc.gov/marcxml/xslt/MARC21slimUtils.xsl"/>
+       <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
+       <!--
+
+Revision 1.10 MODS 3.1 revisions to language and classification elements  
+                               (plus ability to find marc:collection embedded in wrapper elements such as SRU zs: wrappers)
+                               2006/02/06  ggar
+
+Revision 1.9 subfield $y was added to field 242 2004/09/02 10:57 jrad
+
+Revision 1.8 Subject chopPunctuation expanded and attribute fixes 2004/08/12 jrad
+
+Revision 1.7 2004/03/25 08:29 jrad
+
+Revision 1.6 various validation fixes 2004/02/20 ntra
+
+Revision 1.5  2003/10/02 16:18:58  ntra
+MODS2 to MODS3 updates, language unstacking and 
+de-duping, chopPunctuation expanded
+
+Revision 1.3  2003/04/03 00:07:19  ntra
+Revision 1.3 Additional Changes not related to MODS Version 2.0 by ntra
+
+Revision 1.2  2003/03/24 19:37:42  ckeith
+Added Log Comment
+
+-->
+       <xsl:template match="/">
+               <xsl:choose>
+                       <xsl:when test="//marc:collection">
+                               <modsCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-1.xsd">
+                                       <xsl:for-each select="//marc:collection/marc:record">
+                                               <mods version="3.1">
+                                                       <xsl:call-template name="marcRecord"/>
+                                               </mods>
+                                       </xsl:for-each>
+                               </modsCollection>
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <mods version="3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-1.xsd">
+                                       <xsl:for-each select="//marc:record">
+                                               <xsl:call-template name="marcRecord"/>
+                                       </xsl:for-each>
+                               </mods>
+                       </xsl:otherwise>
+               </xsl:choose>
+       </xsl:template>
+       <xsl:template name="marcRecord">
+               <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]"/>
+               <xsl:variable name="typeOf008">
+                       <xsl:choose>
+                               <xsl:when test="$leader6='a'">
+                                       <xsl:choose>
+                                               <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when>
+                                               <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">SE</xsl:when>
+                                       </xsl:choose>
+                               </xsl:when>
+                               <xsl:when test="$leader6='t'">BK</xsl:when>
+                               <xsl:when test="$leader6='p'">MM</xsl:when>
+                               <xsl:when test="$leader6='m'">CF</xsl:when>
+                               <xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when>
+                               <xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">VM</xsl:when>
+                               <xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'">MU</xsl:when>
+                       </xsl:choose>
+               </xsl:variable>
+               <xsl:for-each select="marc:datafield[@tag=245]">
+                       <titleInfo>
+                               <xsl:variable name="title">
+                                       <xsl:choose>
+                                               <xsl:when test="marc:subfield[@code='b']">
+                                                       <xsl:call-template name="specialSubfieldSelect">
+                                                               <xsl:with-param name="axis">b</xsl:with-param>
+                                                               <xsl:with-param name="beforeCodes">afgk</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">abfgk</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:variable>
+                               <xsl:variable name="titleChop">
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="$title"/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </xsl:variable>
+                               <xsl:choose>
+                                       <xsl:when test="@ind2&gt;0">
+                                               <nonSort>
+                                                       <xsl:value-of select="substring($titleChop,1,@ind2)"/>
+                                               </nonSort>
+                                               <title>
+                                                       <xsl:value-of select="substring($titleChop,@ind2+1)"/>
+                                               </title>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <title>
+                                                       <xsl:value-of select="$titleChop"/>
+                                               </title>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                               <xsl:if test="marc:subfield[@code='b']">
+                                       <subTitle>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="axis">b</xsl:with-param>
+                                                                       <xsl:with-param name="anyCodes">b</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">afgk</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </subTitle>
+                               </xsl:if>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=210]">
+                       <titleInfo type="abbreviated">
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">a</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <xsl:call-template name="subtitle"/>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=242]">
+                       <titleInfo type="translated">
+                               <!--09/01/04 Added subfield $y-->
+                               <xsl:for-each select="marc:subfield[@code='y']">
+                                       <xsl:attribute name="lang"><xsl:value-of select="text()"/></xsl:attribute>
+                               </xsl:for-each>
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <!-- 1/04 removed $h, b -->
+                                                               <xsl:with-param name="codes">a</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <!-- 1/04 fix -->
+                               <xsl:call-template name="subtitle"/>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=246]">
+                       <titleInfo type="alternative">
+                               <xsl:for-each select="marc:subfield[@code='i']">
+                                       <xsl:attribute name="displayLabel"><xsl:value-of select="text()"/></xsl:attribute>
+                               </xsl:for-each>
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <!-- 1/04 removed $h, $b -->
+                                                               <xsl:with-param name="codes">af</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <xsl:call-template name="subtitle"/>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
+                       <titleInfo type="uniform">
+                               <title>
+                                       <xsl:variable name="str">
+                                               <xsl:for-each select="marc:subfield">
+                                                       <xsl:if test="(contains('adfklmor',@code) and (not(../marc:subfield[@code='n' or @code='p']) or (following-sibling::marc:subfield[@code='n' or @code='p'])))">
+                                                               <xsl:value-of select="text()"/>
+                                                               <xsl:text> </xsl:text>
+                                                       </xsl:if>
+                                               </xsl:for-each>
+                                       </xsl:variable>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=740][@ind2!=2]">
+                       <titleInfo type="alternative">
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">ah</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <xsl:call-template name="part"/>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=100]">
+                       <name type="personal">
+                               <xsl:call-template name="nameABCDQ"/>
+                               <xsl:call-template name="affiliation"/>
+                               <role>
+                                       <roleTerm authority="marcrelator" type="text">creator</roleTerm>
+                               </role>
+                               <xsl:call-template name="role"/>
+                       </name>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=110]">
+                       <name type="corporate">
+                               <xsl:call-template name="nameABCDN"/>
+                               <role>
+                                       <roleTerm authority="marcrelator" type="text">creator</roleTerm>
+                               </role>
+                               <xsl:call-template name="role"/>
+                       </name>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=111]">
+                       <name type="conference">
+                               <xsl:call-template name="nameACDEQ"/>
+                               <role>
+                                       <roleTerm authority="marcrelator" type="text">creator</roleTerm>
+                               </role>
+                               <xsl:call-template name="role"/>
+                       </name>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=700][not(marc:subfield[@code='t'])]">
+                       <name type="personal">
+                               <xsl:call-template name="nameABCDQ"/>
+                               <xsl:call-template name="affiliation"/>
+                               <xsl:call-template name="role"/>
+                       </name>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=710][not(marc:subfield[@code='t'])]">
+                       <name type="corporate">
+                               <xsl:call-template name="nameABCDN"/>
+                               <xsl:call-template name="role"/>
+                       </name>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=711][not(marc:subfield[@code='t'])]">
+                       <name type="conference">
+                               <xsl:call-template name="nameACDEQ"/>
+                               <xsl:call-template name="role"/>
+                       </name>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=720][not(marc:subfield[@code='t'])]">
+                       <name>
+                               <xsl:if test="@ind1=1">
+                                       <xsl:attribute name="type"><xsl:text>personal</xsl:text></xsl:attribute>
+                               </xsl:if>
+                               <namePart>
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>
+                               </namePart>
+                               <xsl:call-template name="role"/>
+                       </name>
+               </xsl:for-each>
+               <typeOfResource>
+                       <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'">sound recording-nonmusical</xsl:when>
+                               <xsl:when test="$leader6='j'">sound recording-musical</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>
+               </typeOfResource>
+               <xsl:if test="substring($controlField008,26,1)='d'">
+                       <genre authority="marc">globe</genre>
+               </xsl:if>
+               <xsl:if test="marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='r']">
+                       <genre authority="marc">remote sensing image</genre>
+               </xsl:if>
+               <xsl:if test="$typeOf008='MP'">
+                       <xsl:variable name="controlField008-25" select="substring($controlField008,26,1)"/>
+                       <xsl:choose>
+                               <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']">
+                                       <genre authority="marc">map</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-25='e' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='d']">
+                                       <genre authority="marc">atlas</genre>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:if>
+               <xsl:if test="$typeOf008='SE'">
+                       <xsl:variable name="controlField008-21" select="substring($controlField008,22,1)"/>
+                       <xsl:choose>
+                               <xsl:when test="$controlField008-21='d'">
+                                       <genre authority="marc">database</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-21='l'">
+                                       <genre authority="marc">loose-leaf</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-21='m'">
+                                       <genre authority="marc">series</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-21='n'">
+                                       <genre authority="marc">newspaper</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-21='p'">
+                                       <genre authority="marc">periodical</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-21='w'">
+                                       <genre authority="marc">web site</genre>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:if>
+               <xsl:if test="$typeOf008='BK' or $typeOf008='SE'">
+                       <xsl:variable name="controlField008-24" select="substring($controlField008,25,4)"/>
+                       <xsl:choose>
+                               <xsl:when test="contains($controlField008-24,'a')">
+                                       <genre authority="marc">abstract or summary</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'b')">
+                                       <genre authority="marc">bibliography</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'c')">
+                                       <genre authority="marc">catalog</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'d')">
+                                       <genre authority="marc">dictionary</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'e')">
+                                       <genre authority="marc">encyclopedia</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'f')">
+                                       <genre authority="marc">handbook</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'g')">
+                                       <genre authority="marc">legal article</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'i')">
+                                       <genre authority="marc">index</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'k')">
+                                       <genre authority="marc">discography</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'l')">
+                                       <genre authority="marc">legislation</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'m')">
+                                       <genre authority="marc">theses</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'n')">
+                                       <genre authority="marc">survey of literature</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'o')">
+                                       <genre authority="marc">review</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'p')">
+                                       <genre authority="marc">programmed text</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'q')">
+                                       <genre authority="marc">filmography</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'r')">
+                                       <genre authority="marc">directory</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'s')">
+                                       <genre authority="marc">statistics</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'t')">
+                                       <genre authority="marc">technical report</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'v')">
+                                       <genre authority="marc">legal case and case notes</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'w')">
+                                       <genre authority="marc">law report or digest</genre>
+                               </xsl:when>
+                               <xsl:when test="contains($controlField008-24,'z')">
+                                       <genre authority="marc">treaty</genre>
+                               </xsl:when>
+                       </xsl:choose>
+                       <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"/>
+                       <xsl:choose>
+                               <xsl:when test="$controlField008-29='1'">
+                                       <genre authority="marc">conference publication</genre>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:if>
+               <xsl:if test="$typeOf008='CF'">
+                       <xsl:variable name="controlField008-26" select="substring($controlField008,27,1)"/>
+                       <xsl:choose>
+                               <xsl:when test="$controlField008-26='a'">
+                                       <genre authority="marc">numeric data</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-26='e'">
+                                       <genre authority="marc">database</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-26='f'">
+                                       <genre authority="marc">font</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-26='g'">
+                                       <genre authority="marc">game</genre>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:if>
+               <xsl:if test="$typeOf008='BK'">
+                       <xsl:if test="substring($controlField008,25,1)='j'">
+                               <genre authority="marc">patent</genre>
+                       </xsl:if>
+                       <xsl:if test="substring($controlField008,31,1)='1'">
+                               <genre authority="marc">festschrift</genre>
+                       </xsl:if>
+                       <xsl:variable name="controlField008-34" select="substring($controlField008,35,1)"/>
+                       <xsl:if test="$controlField008-34='a' or $controlField008-34='b' or $controlField008-34='c' or $controlField008-34='d'">
+                               <genre authority="marc">biography</genre>
+                       </xsl:if>
+                       <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"/>
+                       <xsl:choose>
+                               <xsl:when test="$controlField008-33='e'">
+                                       <genre authority="marc">essay</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='d'">
+                                       <genre authority="marc">drama</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='c'">
+                                       <genre authority="marc">comic strip</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='l'">
+                                       <genre authority="marc">fiction</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='h'">
+                                       <genre authority="marc">humor, satire</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='i'">
+                                       <genre authority="marc">letter</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='f'">
+                                       <genre authority="marc">novel</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='j'">
+                                       <genre authority="marc">short story</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='s'">
+                                       <genre authority="marc">speech</genre>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:if>
+               <xsl:if test="$typeOf008='MU'">
+                       <xsl:variable name="controlField008-30-31" select="substring($controlField008,31,2)"/>
+                       <xsl:if test="contains($controlField008-30-31,'b')">
+                               <genre authority="marc">biography</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'c')">
+                               <genre authority="marc">conference publication</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'d')">
+                               <genre authority="marc">drama</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'e')">
+                               <genre authority="marc">essay</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'f')">
+                               <genre authority="marc">fiction</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'o')">
+                               <genre authority="marc">folktale</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'h')">
+                               <genre authority="marc">history</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'k')">
+                               <genre authority="marc">humor, satire</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'m')">
+                               <genre authority="marc">memoir</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'p')">
+                               <genre authority="marc">poetry</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'r')">
+                               <genre authority="marc">rehearsal</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'g')">
+                               <genre authority="marc">reporting</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'s')">
+                               <genre authority="marc">sound</genre>
+                       </xsl:if>
+                       <xsl:if test="contains($controlField008-30-31,'l')">
+                               <genre authority="marc">speech</genre>
+                       </xsl:if>
+               </xsl:if>
+               <xsl:if test="$typeOf008='VM'">
+                       <xsl:variable name="controlField008-33" select="substring($controlField008,34,1)"/>
+                       <xsl:choose>
+                               <xsl:when test="$controlField008-33='a'">
+                                       <genre authority="marc">art original</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='b'">
+                                       <genre authority="marc">kit</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='c'">
+                                       <genre authority="marc">art reproduction</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='d'">
+                                       <genre authority="marc">diorama</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='f'">
+                                       <genre authority="marc">filmstrip</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='g'">
+                                       <genre authority="marc">legal article</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='i'">
+                                       <genre authority="marc">picture</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='k'">
+                                       <genre authority="marc">graphic</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='l'">
+                                       <genre authority="marc">technical drawing</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='m'">
+                                       <genre authority="marc">motion picture</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='n'">
+                                       <genre authority="marc">chart</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='o'">
+                                       <genre authority="marc">flash card</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='p'">
+                                       <genre authority="marc">microscope slide</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='q' or marc:controlfield[@tag=007][substring(text(),1,1)='a'][substring(text(),2,1)='q']">
+                                       <genre authority="marc">model</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='r'">
+                                       <genre authority="marc">realia</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='s'">
+                                       <genre authority="marc">slide</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='t'">
+                                       <genre authority="marc">transparency</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='v'">
+                                       <genre authority="marc">videorecording</genre>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-33='w'">
+                                       <genre authority="marc">toy</genre>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:if>
+               <xsl:for-each select="marc:datafield[@tag=655]">
+                       <genre authority="marc">
+                               <xsl:attribute name="authority"><xsl:value-of select="marc:subfield[@code='2']"/></xsl:attribute>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">abvxyz</xsl:with-param>
+                                       <xsl:with-param name="delimeter">-</xsl:with-param>
+                               </xsl:call-template>
+                       </genre>
+               </xsl:for-each>
+               <originInfo>
+                       <xsl:variable name="MARCpublicationCode" select="normalize-space(substring($controlField008,16,3))"/>
+                       <xsl:if test="translate($MARCpublicationCode,'|','')">
+                               <place>
+                                       <placeTerm>
+                                               <xsl:attribute name="type">code</xsl:attribute>
+                                               <xsl:attribute name="authority">marccountry</xsl:attribute>
+                                               <xsl:value-of select="$MARCpublicationCode"/>
+                                       </placeTerm>
+                               </place>
+                       </xsl:if>
+                       <xsl:for-each select="marc:datafield[@tag=044]/marc:subfield[@code='c']">
+                               <place>
+                                       <placeTerm>
+                                               <xsl:attribute name="type">code</xsl:attribute>
+                                               <xsl:attribute name="authority">iso3166</xsl:attribute>
+                                               <xsl:value-of select="."/>
+                                       </placeTerm>
+                               </place>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='a']">
+                               <place>
+                                       <placeTerm>
+                                               <xsl:attribute name="type">text</xsl:attribute>
+                                               <xsl:call-template name="chopPunctuationFront">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="chopPunctuation">
+                                                                       <xsl:with-param name="chopString" select="."/>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </placeTerm>
+                               </place>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='m']">
+                               <dateValid point="start">
+                                       <xsl:value-of select="."/>
+                               </dateValid>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='n']">
+                               <dateValid point="end">
+                                       <xsl:value-of select="."/>
+                               </dateValid>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=046]/marc:subfield[@code='j']">
+                               <dateModified>
+                                       <xsl:value-of select="."/>
+                               </dateModified>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='b' or @code='c' or @code='g']">
+                               <xsl:choose>
+                                       <xsl:when test="@code='b'">
+                                               <publisher>
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString" select="."/>
+                                                               <xsl:with-param name="punctuation">
+                                                                       <xsl:text>:,;/ </xsl:text>
+                                                               </xsl:with-param>
+                                                       </xsl:call-template>
+                                               </publisher>
+                                       </xsl:when>
+                                       <xsl:when test="@code='c'">
+                                               <dateIssued>
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString" select="."/>
+                                                       </xsl:call-template>
+                                               </dateIssued>
+                                       </xsl:when>
+                                       <xsl:when test="@code='g'">
+                                               <dateCreated>
+                                                       <xsl:value-of select="."/>
+                                               </dateCreated>
+                                       </xsl:when>
+                               </xsl:choose>
+                       </xsl:for-each>
+                       <xsl:variable name="dataField260c">
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString" select="marc:datafield[@tag=260]/marc:subfield[@code='c']"/>
+                               </xsl:call-template>
+                       </xsl:variable>
+                       <xsl:variable name="controlField008-7-10" select="normalize-space(substring($controlField008, 8, 4))"/>
+                       <xsl:variable name="controlField008-11-14" select="normalize-space(substring($controlField008, 12, 4))"/>
+                       <xsl:variable name="controlField008-6" select="normalize-space(substring($controlField008, 7, 1))"/>
+                       <xsl:if test="$controlField008-6='e' or $controlField008-6='p' or $controlField008-6='r' or $controlField008-6='t' or $controlField008-6='s'">
+                               <xsl:if test="$controlField008-7-10 and ($controlField008-7-10 != $dataField260c)">
+                                       <dateIssued encoding="marc">
+                                               <xsl:value-of select="$controlField008-7-10"/>
+                                       </dateIssued>
+                               </xsl:if>
+                       </xsl:if>
+                       <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'">
+                               <xsl:if test="$controlField008-7-10">
+                                       <dateIssued encoding="marc" point="start">
+                                               <xsl:value-of select="$controlField008-7-10"/>
+                                       </dateIssued>
+                               </xsl:if>
+                       </xsl:if>
+                       <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'">
+                               <xsl:if test="$controlField008-11-14">
+                                       <dateIssued encoding="marc" point="end">
+                                               <xsl:value-of select="$controlField008-11-14"/>
+                                       </dateIssued>
+                               </xsl:if>
+                       </xsl:if>
+                       <xsl:if test="$controlField008-6='q'">
+                               <xsl:if test="$controlField008-7-10">
+                                       <dateIssued encoding="marc" point="start" qualifier="questionable">
+                                               <xsl:value-of select="$controlField008-7-10"/>
+                                       </dateIssued>
+                               </xsl:if>
+                       </xsl:if>
+                       <xsl:if test="$controlField008-6='q'">
+                               <xsl:if test="$controlField008-11-14">
+                                       <dateIssued encoding="marc" point="end" qualifier="questionable">
+                                               <xsl:value-of select="$controlField008-11-14"/>
+                                       </dateIssued>
+                               </xsl:if>
+                       </xsl:if>
+                       <xsl:if test="$controlField008-6='t'">
+                               <xsl:if test="$controlField008-11-14">
+                                       <copyrightDate encoding="marc">
+                                               <xsl:value-of select="$controlField008-11-14"/>
+                                       </copyrightDate>
+                               </xsl:if>
+                       </xsl:if>
+                       <xsl:for-each select="marc:datafield[@tag=033][@ind1=0 or @ind1=1]/marc:subfield[@code='a']">
+                               <dateCaptured encoding="iso8601">
+                                       <xsl:value-of select="."/>
+                               </dateCaptured>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][1]">
+                               <dateCaptured encoding="iso8601" point="start">
+                                       <xsl:value-of select="."/>
+                               </dateCaptured>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=033][@ind1=2]/marc:subfield[@code='a'][2]">
+                               <dateCaptured encoding="iso8601" point="end">
+                                       <xsl:value-of select="."/>
+                               </dateCaptured>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=250]/marc:subfield[@code='a']">
+                               <edition>
+                                       <xsl:value-of select="."/>
+                               </edition>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:leader">
+                               <issuance>
+                                       <xsl:choose>
+                                               <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">monographic</xsl:when>
+                                               <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">continuing</xsl:when>
+                                       </xsl:choose>
+                               </issuance>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=310]|marc:datafield[@tag=321]">
+                               <frequency>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">ab</xsl:with-param>
+                                       </xsl:call-template>
+                               </frequency>
+                       </xsl:for-each>
+               </originInfo>
+               <xsl:variable name="controlField008-35-37" select="normalize-space(translate(substring($controlField008,36,3),'|#',''))"/>
+               <xsl:if test="$controlField008-35-37">
+                       <language>
+                               <languageTerm authority="iso639-2b" type="code">
+                                       <xsl:value-of select="substring($controlField008,36,3)"/>
+                               </languageTerm>
+                       </language>
+               </xsl:if>
+               <xsl:for-each select="marc:datafield[@tag=041]">
+                       <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='d' or @code='e' or @code='f' or @code='g' or @code='h']">
+                               <xsl:variable name="langCodes" select="."/>
+                               <xsl:choose>
+                                       <xsl:when test="../marc:subfield[@code='2']='rfc3066'">
+                                               <!-- not stacked but could be repeated -->
+                                               <xsl:call-template name="rfcLanguages">
+                                                       <xsl:with-param name="nodeNum">
+                                                               <xsl:value-of select="1"/>
+                                                       </xsl:with-param>
+                                                       <xsl:with-param name="usedLanguages">
+                                                               <xsl:text/>
+                                                       </xsl:with-param>
+                                                       <xsl:with-param name="controlField008-35-37">
+                                                               <xsl:value-of select="$controlField008-35-37"/>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <!-- iso -->
+                                               <xsl:variable name="allLanguages">
+                                                       <xsl:copy-of select="$langCodes"/>
+                                               </xsl:variable>
+                                               <xsl:variable name="currentLanguage">
+                                                       <xsl:value-of select="substring($allLanguages,1,3)"/>
+                                               </xsl:variable>
+                                               <xsl:call-template name="isoLanguage">
+                                                       <xsl:with-param name="currentLanguage">
+                                                               <xsl:value-of select="substring($allLanguages,1,3)"/>
+                                                       </xsl:with-param>
+                                                       <xsl:with-param name="remainingLanguages">
+                                                               <xsl:value-of select="substring($allLanguages,4,string-length($allLanguages)-3)"/>
+                                                       </xsl:with-param>
+                                                       <xsl:with-param name="usedLanguages">
+                                                               <xsl:if test="$controlField008-35-37">
+                                                                       <xsl:value-of select="$controlField008-35-37"/>
+                                                               </xsl:if>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                       </xsl:for-each>
+               </xsl:for-each>
+               <xsl:variable name="physicalDescription">
+                       <xsl:if test="$typeOf008='CF' and marc:controlfield[@tag=007][substring(.,12,1)='a' or substring(.,12,1)='b']">
+                               <digitalOrigin>reformatted digital</digitalOrigin>
+                       </xsl:if>
+                       <xsl:variable name="controlField008-23" select="substring($controlField008,24,1)"/>
+                       <xsl:variable name="controlField008-29" select="substring($controlField008,30,1)"/>
+                       <xsl:variable name="check008-23">
+                               <xsl:if test="$typeOf008='BK' or $typeOf008='MU' or $typeOf008='SE' or $typeOf008='MM'">
+                                       <xsl:value-of select="true()"/>
+                               </xsl:if>
+                       </xsl:variable>
+                       <xsl:variable name="check008-29">
+                               <xsl:if test="$typeOf008='MP' or $typeOf008='VM'">
+                                       <xsl:value-of select="true()"/>
+                               </xsl:if>
+                       </xsl:variable>
+                       <xsl:choose>
+                               <xsl:when test="($check008-23 and $controlField008-23='f') or ($check008-29 and $controlField008-29='f')">
+                                       <form authority="marcform">braille</form>
+                               </xsl:when>
+                               <xsl:when test="($controlField008-23=' ' and ($leader6='c' or $leader6='d')) or (($typeOf008='BK' or $typeOf008='SE') and ($controlField008-23=' ' or $controlField008='r'))">
+                                       <form authority="marcform">print</form>
+                               </xsl:when>
+                               <xsl:when test="$leader6 = 'm' or ($check008-23 and $controlField008-23='s') or ($check008-29 and $controlField008-29='s')">
+                                       <form authority="marcform">electronic</form>
+                               </xsl:when>
+                               <xsl:when test="($check008-23 and $controlField008-23='b') or ($check008-29 and $controlField008-29='b')">
+                                       <form authority="marcform">microfiche</form>
+                               </xsl:when>
+                               <xsl:when test="($check008-23 and $controlField008-23='a') or ($check008-29 and $controlField008-29='a')">
+                                       <form authority="marcform">microfilm</form>
+                               </xsl:when>
+                       </xsl:choose>
+                       <!-- 1/04 fix -->
+                       <xsl:if test="marc:datafield[@tag=130]/marc:subfield[@code='h']">
+                               <form authority="gmd">
+                                       <xsl:call-template name="chopBrackets">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="marc:datafield[@tag=130]/marc:subfield[@code='h']"/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </form>
+                       </xsl:if>
+                       <xsl:if test="marc:datafield[@tag=240]/marc:subfield[@code='h']">
+                               <form authority="gmd">
+                                       <xsl:call-template name="chopBrackets">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="marc:datafield[@tag=240]/marc:subfield[@code='h']"/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </form>
+                       </xsl:if>
+                       <xsl:if test="marc:datafield[@tag=242]/marc:subfield[@code='h']">
+                               <form authority="gmd">
+                                       <xsl:call-template name="chopBrackets">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="marc:datafield[@tag=242]/marc:subfield[@code='h']"/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </form>
+                       </xsl:if>
+                       <xsl:if test="marc:datafield[@tag=245]/marc:subfield[@code='h']">
+                               <form authority="gmd">
+                                       <xsl:call-template name="chopBrackets">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="marc:datafield[@tag=245]/marc:subfield[@code='h']"/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </form>
+                       </xsl:if>
+                       <xsl:if test="marc:datafield[@tag=246]/marc:subfield[@code='h']">
+                               <form authority="gmd">
+                                       <xsl:call-template name="chopBrackets">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="marc:datafield[@tag=246]/marc:subfield[@code='h']"/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </form>
+                       </xsl:if>
+                       <xsl:if test="marc:datafield[@tag=730]/marc:subfield[@code='h']">
+                               <form authority="gmd">
+                                       <xsl:call-template name="chopBrackets">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="marc:datafield[@tag=730]/marc:subfield[@code='h']"/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </form>
+                       </xsl:if>
+                       <xsl:for-each select="marc:datafield[@tag=256]/marc:subfield[@code='a']">
+                               <form>
+                                       <xsl:value-of select="."/>
+                               </form>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:controlfield[@tag=007][substring(text(),1,1)='c']">
+                               <xsl:choose>
+                                       <xsl:when test="substring(text(),14,1)='a'">
+                                               <reformattingQuality>access</reformattingQuality>
+                                       </xsl:when>
+                                       <xsl:when test="substring(text(),14,1)='p'">
+                                               <reformattingQuality>preservation</reformattingQuality>
+                                       </xsl:when>
+                                       <xsl:when test="substring(text(),14,1)='r'">
+                                               <reformattingQuality>replacement</reformattingQuality>
+                                       </xsl:when>
+                               </xsl:choose>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=856]/marc:subfield[@code='q'][string-length(.)&gt;1]">
+                               <internetMediaType>
+                                       <xsl:value-of select="."/>
+                               </internetMediaType>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=300]">
+                               <extent>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abce</xsl:with-param>
+                                       </xsl:call-template>
+                               </extent>
+                       </xsl:for-each>
+               </xsl:variable>
+               <xsl:if test="string-length(normalize-space($physicalDescription))">
+                       <physicalDescription>
+                               <xsl:copy-of select="$physicalDescription"/>
+                       </physicalDescription>
+               </xsl:if>
+               <xsl:for-each select="marc:datafield[@tag=520]">
+                       <abstract>
+                               <xsl:call-template name="uri"/>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">ab</xsl:with-param>
+                               </xsl:call-template>
+                       </abstract>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=505]">
+                       <tableOfContents>
+                               <xsl:call-template name="uri"/>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">agrt</xsl:with-param>
+                               </xsl:call-template>
+                       </tableOfContents>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=521]">
+                       <targetAudience>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">ab</xsl:with-param>
+                               </xsl:call-template>
+                       </targetAudience>
+               </xsl:for-each>
+               <xsl:if test="$typeOf008='BK' or $typeOf008='CF' or $typeOf008='MU' or $typeOf008='VM'">
+                       <xsl:variable name="controlField008-22" select="substring($controlField008,23,1)"/>
+                       <xsl:choose>
+                               <!-- 01/04 fix -->
+                               <xsl:when test="$controlField008-22='d'">
+                                       <targetAudience authority="marctarget">adolescent</targetAudience>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-22='e'">
+                                       <targetAudience authority="marctarget">adult</targetAudience>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-22='g'">
+                                       <targetAudience authority="marctarget">general</targetAudience>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-22='b' or $controlField008-22='c' or $controlField008-22='j'">
+                                       <targetAudience authority="marctarget">juvenile</targetAudience>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-22='a'">
+                                       <targetAudience authority="marctarget">preschool</targetAudience>
+                               </xsl:when>
+                               <xsl:when test="$controlField008-22='f'">
+                                       <targetAudience authority="marctarget">specialized</targetAudience>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:if>
+               <xsl:for-each select="marc:datafield[@tag=245]/marc:subfield[@code='c']">
+                       <note type="statement of responsibility">
+                               <xsl:value-of select="."/>
+                       </note>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=500]">
+                       <note>
+                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                               <xsl:call-template name="uri"/>
+                       </note>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=511]">
+                       <note type="performers">
+                               <xsl:call-template name="uri"/>
+                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                       </note>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=518]">
+                       <note type="venue">
+                               <xsl:call-template name="uri"/>
+                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                       </note>
+               </xsl:for-each>
+               <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=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]">
+                       <note>
+                               <xsl:call-template name="uri"/>
+                               <xsl:variable name="str">
+                                       <xsl:for-each select="marc:subfield[@code!='6' or @code!='8']">
+                                               <xsl:value-of select="."/>
+                                               <xsl:text> </xsl:text>
+                                       </xsl:for-each>
+                               </xsl:variable>
+                               <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
+                       </note>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=034][marc:subfield[@code='d' or @code='e' or @code='f' or @code='g']]">
+                       <subject>
+                               <cartographics>
+                                       <coordinates>
+                                               <xsl:call-template name="subfieldSelect">
+                                                       <xsl:with-param name="codes">defg</xsl:with-param>
+                                               </xsl:call-template>
+                                       </coordinates>
+                               </cartographics>
+                       </subject>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=043]">
+                       <subject>
+                               <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c']">
+                                       <geographicCode>
+                                               <xsl:attribute name="authority"><xsl:if test="@code='a'"><xsl:text>marcgac</xsl:text></xsl:if><xsl:if test="@code='b'"><xsl:value-of select="following-sibling::marc:subfield[@code=2]"/></xsl:if><xsl:if test="@code='c'"><xsl:text>iso3166</xsl:text></xsl:if></xsl:attribute>
+                                               <xsl:value-of select="self::marc:subfield"/>
+                                       </geographicCode>
+                               </xsl:for-each>
+                       </subject>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=255]">
+                       <subject>
+                               <cartographics>
+                                       <xsl:for-each select="marc:subfield[@code='c']">
+                                               <coordinates>
+                                                       <xsl:value-of select="."/>
+                                               </coordinates>
+                                       </xsl:for-each>
+                                       <xsl:for-each select="marc:subfield[@code='a']">
+                                               <scale>
+                                                       <xsl:value-of select="."/>
+                                               </scale>
+                                       </xsl:for-each>
+                                       <xsl:for-each select="marc:subfield[@code='b']">
+                                               <projection>
+                                                       <xsl:value-of select="."/>
+                                               </projection>
+                                       </xsl:for-each>
+                               </cartographics>
+                       </subject>
+               </xsl:for-each>
+               <xsl:apply-templates select="marc:datafield[653 &gt;= @tag and @tag &gt;= 600]"/>
+               <xsl:apply-templates select="marc:datafield[@tag=656]"/>
+               <xsl:for-each select="marc:datafield[@tag=752]">
+                       <subject>
+                               <hierarchicalGeographic>
+                                       <xsl:for-each select="marc:subfield[@code='a']">
+                                               <country>
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString" select="."/>
+                                                       </xsl:call-template>
+                                               </country>
+                                       </xsl:for-each>
+                                       <xsl:for-each select="marc:subfield[@code='b']">
+                                               <state>
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString" select="."/>
+                                                       </xsl:call-template>
+                                               </state>
+                                       </xsl:for-each>
+                                       <xsl:for-each select="marc:subfield[@code='c']">
+                                               <county>
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString" select="."/>
+                                                       </xsl:call-template>
+                                               </county>
+                                       </xsl:for-each>
+                                       <xsl:for-each select="marc:subfield[@code='d']">
+                                               <city>
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString" select="."/>
+                                                       </xsl:call-template>
+                                               </city>
+                                       </xsl:for-each>
+                               </hierarchicalGeographic>
+                       </subject>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=045][marc:subfield[@code='b']]">
+                       <subject>
+                               <xsl:choose>
+                                       <xsl:when test="@ind1=2">
+                                               <temporal encoding="iso8601" point="start">
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString">
+                                                                       <xsl:value-of select="marc:subfield[@code='b'][1]"/>
+                                                               </xsl:with-param>
+                                                       </xsl:call-template>
+                                               </temporal>
+                                               <temporal encoding="iso8601" point="end">
+                                                       <xsl:call-template name="chopPunctuation">
+                                                               <xsl:with-param name="chopString">
+                                                                       <xsl:value-of select="marc:subfield[@code='b'][2]"/>
+                                                               </xsl:with-param>
+                                                       </xsl:call-template>
+                                               </temporal>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:for-each select="marc:subfield[@code='b']">
+                                                       <temporal encoding="iso8601">
+                                                               <xsl:call-template name="chopPunctuation">
+                                                                       <xsl:with-param name="chopString" select="."/>
+                                                               </xsl:call-template>
+                                                       </temporal>
+                                               </xsl:for-each>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                       </subject>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=050]">
+                       <xsl:for-each select="marc:subfield[@code='b']">
+                               <classification authority="lcc">
+                                       <xsl:if test="../marc:subfield[@code='3']">
+                                               <xsl:attribute name="displayLabel"><xsl:value-of select="../marc:subfield[@code='3']"/></xsl:attribute>
+                                       </xsl:if>
+                                       <xsl:value-of select="preceding-sibling::marc:subfield[@code='a'][1]"/>
+                                       <xsl:text> </xsl:text>
+                                       <xsl:value-of select="text()"/>
+                               </classification>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:subfield[@code='a'][not(following-sibling::marc:subfield[@code='b'])]">
+                               <classification authority="lcc">
+                                       <xsl:if test="../marc:subfield[@code='3']">
+                                               <xsl:attribute name="displayLabel"><xsl:value-of select="../marc:subfield[@code='3']"/></xsl:attribute>
+                                       </xsl:if>
+                                       <xsl:value-of select="text()"/>
+                               </classification>
+                       </xsl:for-each>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=082]">
+                       <classification authority="ddc">
+                               <xsl:if test="marc:subfield[@code='2']">
+                                       <xsl:attribute name="edition"><xsl:value-of select="marc:subfield[@code='2']"/></xsl:attribute>
+                               </xsl:if>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">ab</xsl:with-param>
+                               </xsl:call-template>
+                       </classification>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=080]">
+                       <classification authority="udc">
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">abx</xsl:with-param>
+                               </xsl:call-template>
+                       </classification>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=060]">
+                       <classification authority="nlm">
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">ab</xsl:with-param>
+                               </xsl:call-template>
+                       </classification>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=086][@ind1=0]">
+                       <classification authority="sudocs">
+                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                       </classification>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=086][@ind1=1]">
+                       <classification authority="candoc">
+                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                       </classification>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=086]">
+                       <classification>
+                               <xsl:attribute name="authority"><xsl:value-of select="marc:subfield[@code='2']"/></xsl:attribute>
+                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                       </classification>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=084]">
+                       <classification>
+                               <xsl:attribute name="authority"><xsl:value-of select="marc:subfield[@code='2']"/></xsl:attribute>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">ab</xsl:with-param>
+                               </xsl:call-template>
+                       </classification>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=440]">
+                       <relatedItem type="series">
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="subfieldSelect">
+                                                                       <xsl:with-param name="codes">av</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="part"/>
+                               </titleInfo>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">
+                       <relatedItem type="series">
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="subfieldSelect">
+                                                                       <xsl:with-param name="codes">av</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="part"/>
+                               </titleInfo>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=510]">
+                       <relatedItem type="isReferencedBy">
+                               <note>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abcx3</xsl:with-param>
+                                       </xsl:call-template>
+                               </note>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=534]">
+                       <relatedItem type="original">
+                               <xsl:call-template name="relatedTitle"/>
+                               <xsl:call-template name="relatedName"/>
+                               <xsl:if test="marc:subfield[@code='b' or @code='c']">
+                                       <originInfo>
+                                               <xsl:for-each select="marc:subfield[@code='c']">
+                                                       <publisher>
+                                                               <xsl:value-of select="."/>
+                                                       </publisher>
+                                               </xsl:for-each>
+                                               <xsl:for-each select="marc:subfield[@code='b']">
+                                                       <edition>
+                                                               <xsl:value-of select="."/>
+                                                       </edition>
+                                               </xsl:for-each>
+                                       </originInfo>
+                               </xsl:if>
+                               <xsl:call-template name="relatedIdentifierISSN"/>
+                               <xsl:for-each select="marc:subfield[@code='z']">
+                                       <identifier type="isbn">
+                                               <xsl:value-of select="."/>
+                                       </identifier>
+                               </xsl:for-each>
+                               <xsl:call-template name="relatedNote"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=700][marc:subfield[@code='t']]">
+                       <relatedItem>
+                               <xsl:call-template name="constituentOrRelatedType"/>
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
+                                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">g</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="part"/>
+                               </titleInfo>
+                               <name type="personal">
+                                       <namePart>
+                                               <xsl:call-template name="specialSubfieldSelect">
+                                                       <xsl:with-param name="anyCodes">aq</xsl:with-param>
+                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                       <xsl:with-param name="beforeCodes">g</xsl:with-param>
+                                               </xsl:call-template>
+                                       </namePart>
+                                       <xsl:call-template name="termsOfAddress"/>
+                                       <xsl:call-template name="nameDate"/>
+                                       <xsl:call-template name="role"/>
+                               </name>
+                               <xsl:call-template name="relatedForm"/>
+                               <xsl:call-template name="relatedIdentifierISSN"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=710][marc:subfield[@code='t']]">
+                       <relatedItem>
+                               <xsl:call-template name="constituentOrRelatedType"/>
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
+                                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">dg</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="relatedPartNumName"/>
+                               </titleInfo>
+                               <name type="corporate">
+                                       <xsl:for-each select="marc:subfield[@code='a']">
+                                               <namePart>
+                                                       <xsl:value-of select="."/>
+                                               </namePart>
+                                       </xsl:for-each>
+                                       <xsl:for-each select="marc:subfield[@code='b']">
+                                               <namePart>
+                                                       <xsl:value-of select="."/>
+                                               </namePart>
+                                       </xsl:for-each>
+                                       <xsl:variable name="tempNamePart">
+                                               <xsl:call-template name="specialSubfieldSelect">
+                                                       <xsl:with-param name="anyCodes">c</xsl:with-param>
+                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                       <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:variable>
+                                       <xsl:if test="normalize-space($tempNamePart)">
+                                               <namePart>
+                                                       <xsl:value-of select="$tempNamePart"/>
+                                               </namePart>
+                                       </xsl:if>
+                                       <xsl:call-template name="role"/>
+                               </name>
+                               <xsl:call-template name="relatedForm"/>
+                               <xsl:call-template name="relatedIdentifierISSN"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=711][marc:subfield[@code='t']]">
+                       <relatedItem>
+                               <xsl:call-template name="constituentOrRelatedType"/>
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
+                                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">g</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="relatedPartNumName"/>
+                               </titleInfo>
+                               <name type="conference">
+                                       <namePart>
+                                               <xsl:call-template name="specialSubfieldSelect">
+                                                       <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
+                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                       <xsl:with-param name="beforeCodes">gn</xsl:with-param>
+                                               </xsl:call-template>
+                                       </namePart>
+                               </name>
+                               <xsl:call-template name="relatedForm"/>
+                               <xsl:call-template name="relatedIdentifierISSN"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=730][@ind2=2]">
+                       <relatedItem>
+                               <xsl:call-template name="constituentOrRelatedType"/>
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="subfieldSelect">
+                                                                       <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="part"/>
+                               </titleInfo>
+                               <xsl:call-template name="relatedForm"/>
+                               <xsl:call-template name="relatedIdentifierISSN"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=740][@ind2=2]">
+                       <relatedItem>
+                               <xsl:call-template name="constituentOrRelatedType"/>
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="part"/>
+                               </titleInfo>
+                               <xsl:call-template name="relatedForm"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=760]|marc:datafield[@tag=762]">
+                       <relatedItem type="series">
+                               <xsl:call-template name="relatedItem76X-78X"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=765]|marc:datafield[@tag=767]|marc:datafield[@tag=777]|marc:datafield[@tag=787]">
+                       <relatedItem>
+                               <xsl:call-template name="relatedItem76X-78X"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=775]">
+                       <relatedItem type="otherVersion">
+                               <xsl:call-template name="relatedItem76X-78X"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=770]|marc:datafield[@tag=774]">
+                       <relatedItem type="constituent">
+                               <xsl:call-template name="relatedItem76X-78X"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=772]|marc:datafield[@tag=773]">
+                       <relatedItem type="host">
+                               <xsl:call-template name="relatedItem76X-78X"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=776]">
+                       <relatedItem type="otherFormat">
+                               <xsl:call-template name="relatedItem76X-78X"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=780]">
+                       <relatedItem type="preceding">
+                               <xsl:call-template name="relatedItem76X-78X"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=785]">
+                       <relatedItem type="succeeding">
+                               <xsl:call-template name="relatedItem76X-78X"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=786]">
+                       <relatedItem type="original">
+                               <xsl:call-template name="relatedItem76X-78X"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=800]">
+                       <relatedItem type="series">
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
+                                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">g</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="part"/>
+                               </titleInfo>
+                               <name type="personal">
+                                       <namePart>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="anyCodes">aq</xsl:with-param>
+                                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                                       <xsl:with-param name="beforeCodes">g</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </namePart>
+                                       <xsl:call-template name="termsOfAddress"/>
+                                       <xsl:call-template name="nameDate"/>
+                                       <xsl:call-template name="role"/>
+                               </name>
+                               <xsl:call-template name="relatedForm"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=810]">
+                       <relatedItem type="series">
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="anyCodes">tfklmorsv</xsl:with-param>
+                                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">dg</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="relatedPartNumName"/>
+                               </titleInfo>
+                               <name type="corporate">
+                                       <xsl:for-each select="marc:subfield[@code='a']">
+                                               <namePart>
+                                                       <xsl:value-of select="."/>
+                                               </namePart>
+                                       </xsl:for-each>
+                                       <xsl:for-each select="marc:subfield[@code='b']">
+                                               <namePart>
+                                                       <xsl:value-of select="."/>
+                                               </namePart>
+                                       </xsl:for-each>
+                                       <namePart>
+                                               <xsl:call-template name="specialSubfieldSelect">
+                                                       <xsl:with-param name="anyCodes">c</xsl:with-param>
+                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                       <xsl:with-param name="beforeCodes">dgn</xsl:with-param>
+                                               </xsl:call-template>
+                                       </namePart>
+                                       <xsl:call-template name="role"/>
+                               </name>
+                               <xsl:call-template name="relatedForm"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=811]">
+                       <relatedItem type="series">
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="specialSubfieldSelect">
+                                                                       <xsl:with-param name="anyCodes">tfklsv</xsl:with-param>
+                                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                                       <xsl:with-param name="afterCodes">g</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="relatedPartNumName"/>
+                               </titleInfo>
+                               <name type="conference">
+                                       <namePart>
+                                               <xsl:call-template name="specialSubfieldSelect">
+                                                       <xsl:with-param name="anyCodes">aqdc</xsl:with-param>
+                                                       <xsl:with-param name="axis">t</xsl:with-param>
+                                                       <xsl:with-param name="beforeCodes">gn</xsl:with-param>
+                                               </xsl:call-template>
+                                       </namePart>
+                                       <xsl:call-template name="role"/>
+                               </name>
+                               <xsl:call-template name="relatedForm"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=830]">
+                       <relatedItem type="series">
+                               <titleInfo>
+                                       <title>
+                                               <xsl:call-template name="chopPunctuation">
+                                                       <xsl:with-param name="chopString">
+                                                               <xsl:call-template name="subfieldSelect">
+                                                                       <xsl:with-param name="codes">adfgklmorsv</xsl:with-param>
+                                                               </xsl:call-template>
+                                                       </xsl:with-param>
+                                               </xsl:call-template>
+                                       </title>
+                                       <xsl:call-template name="part"/>
+                               </titleInfo>
+                               <xsl:call-template name="relatedForm"/>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=856][@ind2=2]/marc:subfield[@code='q']">
+                       <relatedItem>
+                               <internetMediaType>
+                                       <xsl:value-of select="."/>
+                               </internetMediaType>
+                       </relatedItem>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=020]">
+                       <identifier type="isbn">
+                               <xsl:call-template name="isInvalid"/>
+                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                       </identifier>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=024][@ind1=0]">
+                       <identifier type="isrc">
+                               <xsl:call-template name="isInvalid"/>
+                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                       </identifier>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=024][@ind1=2]">
+                       <identifier type="ismn">
+                               <xsl:call-template name="isInvalid"/>
+                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                       </identifier>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=022]">
+                       <identifier type="issn">
+                               <xsl:call-template name="isInvalid"/>
+                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                       </identifier>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=010]">
+                       <identifier type="lccn">
+                               <xsl:call-template name="isInvalid"/>
+                               <xsl:value-of select="normalize-space(marc:subfield[@code='a'])"/>
+                       </identifier>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=028]">
+                       <identifier>
+                               <xsl:call-template name="isInvalid"/>
+                               <xsl:attribute name="type"><xsl:choose><xsl:when test="@ind1=0">issue number</xsl:when><xsl:when test="@ind1=1">matrix number</xsl:when><xsl:when test="@ind1=2">music plate</xsl:when><xsl:when test="@ind1=3">music publisher</xsl:when><xsl:when test="@ind1=4">videorecording identifier</xsl:when></xsl:choose></xsl:attribute>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">
+                                               <xsl:choose>
+                                                       <xsl:when test="@ind1=0">ba</xsl:when>
+                                                       <xsl:otherwise>ab</xsl:otherwise>
+                                               </xsl:choose>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </identifier>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=024][@ind1='4']">
+                       <identifier type="sici">
+                               <xsl:call-template name="isInvalid"/>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">ab</xsl:with-param>
+                               </xsl:call-template>
+                       </identifier>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=037]">
+                       <identifier type="stock number">
+                               <xsl:call-template name="isInvalid"/>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">ab</xsl:with-param>
+                               </xsl:call-template>
+                       </identifier>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=856][marc:subfield[@code='u']]">
+                       <identifier>
+                               <xsl:attribute name="type"><xsl:choose><xsl:when test="starts-with(marc:subfield[@code='u'],'urn:doi') or starts-with(marc:subfield[@code='u'],'doi')">doi</xsl:when><xsl:when test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl') or starts-with(marc:subfield[@code='u'],'http://hdl.loc.gov')">hdl</xsl:when><xsl:otherwise>uri</xsl:otherwise></xsl:choose></xsl:attribute>
+                               <xsl:choose>
+                                       <xsl:when test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl') or starts-with(marc:subfield[@code='u'],'http://hdl.loc.gov') ">
+                                               <xsl:value-of select="concat('hdl:',substring-after(marc:subfield[@code='u'],'http://hdl.loc.gov/'))"/>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:value-of select="marc:subfield[@code='u']"/>
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                       </identifier>
+                       <xsl:if test="starts-with(marc:subfield[@code='u'],'urn:hdl') or starts-with(marc:subfield[@code='u'],'hdl')">
+                               <identifier type="hdl">
+                                       <xsl:if test="marc:subfield[@code='y' or @code='3' or @code='z']">
+                                               <xsl:attribute name="displayLabel"><xsl:call-template name="subfieldSelect"><xsl:with-param name="codes">y3z</xsl:with-param></xsl:call-template></xsl:attribute>
+                                       </xsl:if>
+                                       <xsl:value-of select="concat('hdl:',substring-after(marc:subfield[@code='u'],'http://hdl.loc.gov/'))"/>
+                               </identifier>
+                       </xsl:if>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=024][@ind1=1]">
+                       <identifier type="upc">
+                               <xsl:call-template name="isInvalid"/>
+                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                       </identifier>
+               </xsl:for-each>
+               <!-- 1/04 fix added $y -->
+               <xsl:for-each select="marc:datafield[@tag=856][marc:subfield[@code='u']]">
+                       <location>
+                               <url>
+                                       <xsl:if test="marc:subfield[@code='y' or @code='3']">
+                                               <xsl:attribute name="displayLabel"><xsl:call-template name="subfieldSelect"><xsl:with-param name="codes">y3</xsl:with-param></xsl:call-template></xsl:attribute>
+                                       </xsl:if>
+                                       <xsl:value-of select="marc:subfield[@code='u']"/>
+                               </url>
+                       </location>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=852]">
+                       <location>
+                               <physicalLocation>
+                                       <xsl:call-template name="displayLabel"/>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abje</xsl:with-param>
+                                       </xsl:call-template>
+                               </physicalLocation>
+                       </location>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=506]">
+                       <accessCondition type="restrictionOnAccess">
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">abcd35</xsl:with-param>
+                               </xsl:call-template>
+                       </accessCondition>
+               </xsl:for-each>
+               <xsl:for-each select="marc:datafield[@tag=540]">
+                       <accessCondition type="useAndReproduction">
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">abcde35</xsl:with-param>
+                               </xsl:call-template>
+                       </accessCondition>
+               </xsl:for-each>
+               <recordInfo>
+                       <xsl:for-each select="marc:datafield[@tag=040]">
+                               <recordContentSource authority="marcorg">
+                                       <xsl:value-of select="marc:subfield[@code='a']"/>
+                               </recordContentSource>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:controlfield[@tag=008]">
+                               <recordCreationDate encoding="marc">
+                                       <xsl:value-of select="substring(.,1,6)"/>
+                               </recordCreationDate>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:controlfield[@tag=005]">
+                               <recordChangeDate encoding="iso8601">
+                                       <xsl:value-of select="."/>
+                               </recordChangeDate>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:controlfield[@tag=001]">
+                               <recordIdentifier>
+                                       <xsl:if test="../marc:controlfield[@tag=003]">
+                                               <xsl:attribute name="source"><xsl:value-of select="../marc:controlfield[@tag=003]"/></xsl:attribute>
+                                       </xsl:if>
+                                       <xsl:value-of select="."/>
+                               </recordIdentifier>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:datafield[@tag=040]/marc:subfield[@code='b']">
+                               <languageOfCataloging>
+                                       <languageTerm authority="iso639-2b" type="code">
+                                               <xsl:value-of select="."/>
+                                       </languageTerm>
+                               </languageOfCataloging>
+                       </xsl:for-each>
+               </recordInfo>
+       </xsl:template>
+       <xsl:template name="displayForm">
+               <xsl:for-each select="marc:subfield[@code='c']">
+                       <displayForm>
+                               <xsl:value-of select="."/>
+                       </displayForm>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="affiliation">
+               <xsl:for-each select="marc:subfield[@code='u']">
+                       <affiliation>
+                               <xsl:value-of select="."/>
+                       </affiliation>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="uri">
+               <xsl:for-each select="marc:subfield[@code='u']">
+                       <xsl:attribute name="xlink:href"><xsl:value-of select="."/></xsl:attribute>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="role">
+               <xsl:for-each select="marc:subfield[@code='e']">
+                       <role>
+                               <roleTerm type="text">
+                                       <xsl:value-of select="."/>
+                               </roleTerm>
+                       </role>
+               </xsl:for-each>
+               <xsl:for-each select="marc:subfield[@code='4']">
+                       <role>
+                               <roleTerm authority="marcrelator" type="code">
+                                       <xsl:value-of select="."/>
+                               </roleTerm>
+                       </role>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="part">
+               <xsl:variable name="partNumber">
+                       <xsl:call-template name="specialSubfieldSelect">
+                               <xsl:with-param name="axis">n</xsl:with-param>
+                               <xsl:with-param name="anyCodes">n</xsl:with-param>
+                               <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
+                       </xsl:call-template>
+               </xsl:variable>
+               <xsl:variable name="partName">
+                       <xsl:call-template name="specialSubfieldSelect">
+                               <xsl:with-param name="axis">p</xsl:with-param>
+                               <xsl:with-param name="anyCodes">p</xsl:with-param>
+                               <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
+                       </xsl:call-template>
+               </xsl:variable>
+               <xsl:if test="string-length(normalize-space($partNumber))">
+                       <partNumber>
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString" select="$partNumber"/>
+                               </xsl:call-template>
+                       </partNumber>
+               </xsl:if>
+               <xsl:if test="string-length(normalize-space($partName))">
+                       <partName>
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString" select="$partName"/>
+                               </xsl:call-template>
+                       </partName>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="relatedPart">
+               <xsl:if test="@tag=773">
+                       <xsl:for-each select="marc:subfield[@code='g']">
+                               <part>
+                                       <text>
+                                               <xsl:value-of select="."/>
+                                       </text>
+                               </part>
+                       </xsl:for-each>
+                       <xsl:for-each select="marc:subfield[@code='q']">
+                               <part>
+                                       <xsl:call-template name="parsePart"/>
+                               </part>
+                       </xsl:for-each>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="relatedPartNumName">
+               <xsl:variable name="partNumber">
+                       <xsl:call-template name="specialSubfieldSelect">
+                               <xsl:with-param name="axis">g</xsl:with-param>
+                               <xsl:with-param name="anyCodes">g</xsl:with-param>
+                               <xsl:with-param name="afterCodes">pst</xsl:with-param>
+                       </xsl:call-template>
+               </xsl:variable>
+               <xsl:variable name="partName">
+                       <xsl:call-template name="specialSubfieldSelect">
+                               <xsl:with-param name="axis">p</xsl:with-param>
+                               <xsl:with-param name="anyCodes">p</xsl:with-param>
+                               <xsl:with-param name="afterCodes">fgkdlmor</xsl:with-param>
+                       </xsl:call-template>
+               </xsl:variable>
+               <xsl:if test="string-length(normalize-space($partNumber))">
+                       <partNumber>
+                               <xsl:value-of select="$partNumber"/>
+                       </partNumber>
+               </xsl:if>
+               <xsl:if test="string-length(normalize-space($partName))">
+                       <partName>
+                               <xsl:value-of select="$partName"/>
+                       </partName>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="relatedName">
+               <xsl:for-each select="marc:subfield[@code='a']">
+                       <name>
+                               <namePart>
+                                       <xsl:value-of select="."/>
+                               </namePart>
+                       </name>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedForm">
+               <xsl:for-each select="marc:subfield[@code='h']">
+                       <physicalDescription>
+                               <form>
+                                       <xsl:value-of select="."/>
+                               </form>
+                       </physicalDescription>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedExtent">
+               <xsl:for-each select="marc:subfield[@code='h']">
+                       <physicalDescription>
+                               <extent>
+                                       <xsl:value-of select="."/>
+                               </extent>
+                       </physicalDescription>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedNote">
+               <xsl:for-each select="marc:subfield[@code='n']">
+                       <note>
+                               <xsl:value-of select="."/>
+                       </note>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedSubject">
+               <xsl:for-each select="marc:subfield[@code='j']">
+                       <subject>
+                               <temporal encoding="iso8601">
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString" select="."/>
+                                       </xsl:call-template>
+                               </temporal>
+                       </subject>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedIdentifierISSN">
+               <xsl:for-each select="marc:subfield[@code='x']">
+                       <identifier type="issn">
+                               <xsl:value-of select="."/>
+                       </identifier>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedIdentifierLocal">
+               <xsl:for-each select="marc:subfield[@code='w']">
+                       <identifier type="local">
+                               <xsl:value-of select="."/>
+                       </identifier>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedIdentifier">
+               <xsl:for-each select="marc:subfield[@code='o']">
+                       <identifier>
+                               <xsl:value-of select="."/>
+                       </identifier>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedItem76X-78X">
+               <xsl:call-template name="displayLabel"/>
+               <xsl:call-template name="relatedTitle76X-78X"/>
+               <xsl:call-template name="relatedName"/>
+               <xsl:call-template name="relatedOriginInfo"/>
+               <xsl:call-template name="relatedLanguage"/>
+               <xsl:call-template name="relatedExtent"/>
+               <xsl:call-template name="relatedNote"/>
+               <xsl:call-template name="relatedSubject"/>
+               <xsl:call-template name="relatedIdentifier"/>
+               <xsl:call-template name="relatedIdentifierISSN"/>
+               <xsl:call-template name="relatedIdentifierLocal"/>
+               <xsl:call-template name="relatedPart"/>
+       </xsl:template>
+       <xsl:template name="subjectGeographicZ">
+               <geographic>
+                       <xsl:call-template name="chopPunctuation">
+                               <xsl:with-param name="chopString" select="."/>
+                       </xsl:call-template>
+               </geographic>
+       </xsl:template>
+       <xsl:template name="subjectTemporalY">
+               <temporal>
+                       <xsl:call-template name="chopPunctuation">
+                               <xsl:with-param name="chopString" select="."/>
+                       </xsl:call-template>
+               </temporal>
+       </xsl:template>
+       <xsl:template name="subjectTopic">
+               <topic>
+                       <xsl:call-template name="chopPunctuation">
+                               <xsl:with-param name="chopString" select="."/>
+                       </xsl:call-template>
+               </topic>
+       </xsl:template>
+       <xsl:template name="nameABCDN">
+               <xsl:for-each select="marc:subfield[@code='a']">
+                       <namePart>
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString" select="."/>
+                               </xsl:call-template>
+                       </namePart>
+               </xsl:for-each>
+               <xsl:for-each select="marc:subfield[@code='b']">
+                       <namePart>
+                               <xsl:value-of select="."/>
+                       </namePart>
+               </xsl:for-each>
+               <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
+                       <namePart>
+                               <xsl:call-template name="subfieldSelect">
+                                       <xsl:with-param name="codes">cdn</xsl:with-param>
+                               </xsl:call-template>
+                       </namePart>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="nameABCDQ">
+               <namePart>
+                       <xsl:call-template name="chopPunctuation">
+                               <xsl:with-param name="chopString">
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">aq</xsl:with-param>
+                                       </xsl:call-template>
+                               </xsl:with-param>
+                               <xsl:with-param name="punctuation">
+                                       <xsl:text>:,;/ </xsl:text>
+                               </xsl:with-param>
+                       </xsl:call-template>
+               </namePart>
+               <xsl:call-template name="termsOfAddress"/>
+               <xsl:call-template name="nameDate"/>
+       </xsl:template>
+       <xsl:template name="nameACDEQ">
+               <namePart>
+                       <xsl:call-template name="subfieldSelect">
+                               <xsl:with-param name="codes">acdeq</xsl:with-param>
+                       </xsl:call-template>
+               </namePart>
+       </xsl:template>
+       <xsl:template name="constituentOrRelatedType">
+               <xsl:if test="@ind2=2">
+                       <xsl:attribute name="type">constituent</xsl:attribute>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="relatedTitle">
+               <xsl:for-each select="marc:subfield[@code='t']">
+                       <titleInfo>
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="."/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                       </titleInfo>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedTitle76X-78X">
+               <xsl:for-each select="marc:subfield[@code='t']">
+                       <titleInfo>
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="."/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
+                                       <xsl:call-template name="relatedPartNumName"/>
+                               </xsl:if>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:subfield[@code='p']">
+                       <titleInfo type="abbreviated">
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="."/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
+                                       <xsl:call-template name="relatedPartNumName"/>
+                               </xsl:if>
+                       </titleInfo>
+               </xsl:for-each>
+               <xsl:for-each select="marc:subfield[@code='s']">
+                       <titleInfo type="uniform">
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:value-of select="."/>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </title>
+                               <xsl:if test="marc:datafield[@tag!=773]and marc:subfield[@code='g']">
+                                       <xsl:call-template name="relatedPartNumName"/>
+                               </xsl:if>
+                       </titleInfo>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="relatedOriginInfo">
+               <xsl:if test="marc:subfield[@code='b' or @code='d'] or marc:subfield[@code='f']">
+                       <originInfo>
+                               <xsl:if test="@tag=775">
+                                       <xsl:for-each select="marc:subfield[@code='f']">
+                                               <place>
+                                                       <placeTerm>
+                                                               <xsl:attribute name="type">code</xsl:attribute>
+                                                               <xsl:attribute name="authority">marcgac</xsl:attribute>
+                                                               <xsl:value-of select="."/>
+                                                       </placeTerm>
+                                               </place>
+                                       </xsl:for-each>
+                               </xsl:if>
+                               <xsl:for-each select="marc:subfield[@code='d']">
+                                       <publisher>
+                                               <xsl:value-of select="."/>
+                                       </publisher>
+                               </xsl:for-each>
+                               <xsl:for-each select="marc:subfield[@code='b']">
+                                       <edition>
+                                               <xsl:value-of select="."/>
+                                       </edition>
+                               </xsl:for-each>
+                       </originInfo>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="relatedLanguage">
+               <xsl:for-each select="marc:subfield[@code='e']">
+                       <xsl:call-template name="getLanguage">
+                               <xsl:with-param name="langString">
+                                       <xsl:value-of select="."/>
+                               </xsl:with-param>
+                       </xsl:call-template>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="nameDate">
+               <xsl:for-each select="marc:subfield[@code='d']">
+                       <namePart type="date">
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString" select="."/>
+                               </xsl:call-template>
+                       </namePart>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="subjectAuthority">
+               <xsl:if test="@ind2!=4">
+                       <xsl:if test="@ind2!=' '">
+                               <xsl:if test="@ind2!=8">
+                                       <xsl:if test="@ind2!=9">
+                                               <xsl:attribute name="authority"><xsl:choose><xsl:when test="@ind2=0">lcsh</xsl:when><xsl:when test="@ind2=1">lcshac</xsl:when><xsl:when test="@ind2=2">mesh</xsl:when><!-- 1/04 fix --><xsl:when test="@ind2=3">nal</xsl:when><xsl:when test="@ind2=5">csh</xsl:when><xsl:when test="@ind2=6">rvm</xsl:when><xsl:when test="@ind2=7"><xsl:value-of select="marc:subfield[@code='2']"/></xsl:when></xsl:choose></xsl:attribute>
+                                       </xsl:if>
+                               </xsl:if>
+                       </xsl:if>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="subjectAnyOrder">
+               <xsl:for-each select="marc:subfield[@code='v' or @code='x' or @code='y' or @code='z']">
+                       <xsl:choose>
+                               <xsl:when test="@code='v'">
+                                       <xsl:call-template name="subjectTopic"/>
+                               </xsl:when>
+                               <xsl:when test="@code='x'">
+                                       <xsl:call-template name="subjectTopic"/>
+                               </xsl:when>
+                               <xsl:when test="@code='y'">
+                                       <xsl:call-template name="subjectTemporalY"/>
+                               </xsl:when>
+                               <xsl:when test="@code='z'">
+                                       <xsl:call-template name="subjectGeographicZ"/>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:for-each>
+       </xsl:template>
+       <xsl:template name="specialSubfieldSelect">
+               <xsl:param name="anyCodes"/>
+               <xsl:param name="axis"/>
+               <xsl:param name="beforeCodes"/>
+               <xsl:param name="afterCodes"/>
+               <xsl:variable name="str">
+                       <xsl:for-each select="marc:subfield">
+                               <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])">
+                                       <xsl:value-of select="text()"/>
+                                       <xsl:text> </xsl:text>
+                               </xsl:if>
+                       </xsl:for-each>
+               </xsl:variable>
+               <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=600]">
+               <subject>
+                       <xsl:call-template name="subjectAuthority"/>
+                       <name type="personal">
+                               <xsl:call-template name="termsOfAddress"/>
+                               <namePart>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">aq</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                               </namePart>
+                               <xsl:call-template name="nameDate"/>
+                               <xsl:call-template name="affiliation"/>
+                               <xsl:call-template name="role"/>
+                       </name>
+                       <xsl:call-template name="subjectAnyOrder"/>
+               </subject>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=610]">
+               <subject>
+                       <xsl:call-template name="subjectAuthority"/>
+                       <name type="corporate">
+                               <xsl:for-each select="marc:subfield[@code='a']">
+                                       <namePart>
+                                               <xsl:value-of select="."/>
+                                       </namePart>
+                               </xsl:for-each>
+                               <xsl:for-each select="marc:subfield[@code='b']">
+                                       <namePart>
+                                               <xsl:value-of select="."/>
+                                       </namePart>
+                               </xsl:for-each>
+                               <xsl:if test="marc:subfield[@code='c' or @code='d' or @code='n' or @code='p']">
+                                       <namePart>
+                                               <xsl:call-template name="subfieldSelect">
+                                                       <xsl:with-param name="codes">cdnp</xsl:with-param>
+                                               </xsl:call-template>
+                                       </namePart>
+                               </xsl:if>
+                               <xsl:call-template name="role"/>
+                       </name>
+                       <xsl:call-template name="subjectAnyOrder"/>
+               </subject>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=611]">
+               <subject>
+                       <xsl:call-template name="subjectAuthority"/>
+                       <name type="conference">
+                               <namePart>
+                                       <xsl:call-template name="subfieldSelect">
+                                               <xsl:with-param name="codes">abcdeqnp</xsl:with-param>
+                                       </xsl:call-template>
+                               </namePart>
+                               <xsl:for-each select="marc:subfield[@code='4']">
+                                       <role>
+                                               <roleTerm authority="marcrelator" type="code">
+                                                       <xsl:value-of select="."/>
+                                               </roleTerm>
+                                       </role>
+                               </xsl:for-each>
+                       </name>
+                       <xsl:call-template name="subjectAnyOrder"/>
+               </subject>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=630]">
+               <subject>
+                       <xsl:call-template name="subjectAuthority"/>
+                       <titleInfo>
+                               <title>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString">
+                                                       <xsl:call-template name="subfieldSelect">
+                                                               <xsl:with-param name="codes">adfhklor</xsl:with-param>
+                                                       </xsl:call-template>
+                                               </xsl:with-param>
+                                       </xsl:call-template>
+                                       <xsl:call-template name="part"/>
+                               </title>
+                       </titleInfo>
+                       <xsl:call-template name="subjectAnyOrder"/>
+               </subject>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=650]">
+               <subject>
+                       <xsl:call-template name="subjectAuthority"/>
+                       <topic>
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:call-template name="subfieldSelect">
+                                                       <xsl:with-param name="codes">abcd</xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </topic>
+                       <xsl:call-template name="subjectAnyOrder"/>
+               </subject>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=651]">
+               <subject>
+                       <xsl:call-template name="subjectAuthority"/>
+                       <xsl:for-each select="marc:subfield[@code='a']">
+                               <geographic>
+                                       <xsl:call-template name="chopPunctuation">
+                                               <xsl:with-param name="chopString" select="."/>
+                                       </xsl:call-template>
+                               </geographic>
+                       </xsl:for-each>
+                       <xsl:call-template name="subjectAnyOrder"/>
+               </subject>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=653]">
+               <subject>
+                       <xsl:for-each select="marc:subfield[@code='a']">
+                               <topic>
+                                       <xsl:value-of select="."/>
+                               </topic>
+                       </xsl:for-each>
+               </subject>
+       </xsl:template>
+       <xsl:template match="marc:datafield[@tag=656]">
+               <subject>
+                       <xsl:if test="marc:subfield[@code=2]">
+                               <xsl:attribute name="authority"><xsl:value-of select="marc:subfield[@code=2]"/></xsl:attribute>
+                       </xsl:if>
+                       <occupation>
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:value-of select="marc:subfield[@code='a']"/>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </occupation>
+               </subject>
+       </xsl:template>
+       <xsl:template name="termsOfAddress">
+               <xsl:if test="marc:subfield[@code='b' or @code='c']">
+                       <namePart type="termsOfAddress">
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:call-template name="subfieldSelect">
+                                                       <xsl:with-param name="codes">bc</xsl:with-param>
+                                               </xsl:call-template>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </namePart>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="displayLabel">
+               <xsl:if test="marc:subfield[@code='i']">
+                       <xsl:attribute name="displayLabel"><xsl:value-of select="marc:subfield[@code='i']"/></xsl:attribute>
+               </xsl:if>
+               <xsl:if test="marc:subfield[@code='3']">
+                       <xsl:attribute name="displayLabel"><xsl:value-of select="marc:subfield[@code='3']"/></xsl:attribute>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="isInvalid">
+               <xsl:if test="marc:subfield[@code='z']">
+                       <xsl:attribute name="invalid">yes</xsl:attribute>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="subtitle">
+               <xsl:if test="marc:subfield[@code='b']">
+                       <subTitle>
+                               <xsl:call-template name="chopPunctuation">
+                                       <xsl:with-param name="chopString">
+                                               <xsl:value-of select="marc:subfield[@code='b']"/>
+                                               <!--<xsl:call-template name="subfieldSelect">
+                                                       <xsl:with-param name="codes">b</xsl:with-param>                                                                 
+                                               </xsl:call-template>-->
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </subTitle>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="script">
+               <xsl:param name="scriptCode"/>
+               <xsl:attribute name="script"><xsl:choose><xsl:when test="$scriptCode='(3'">Arabic</xsl:when><xsl:when test="$scriptCode='(B'">Latin</xsl:when><xsl:when test="$scriptCode='$1'">Chinese, Japanese, Korean</xsl:when><xsl:when test="$scriptCode='(N'">Cyrillic</xsl:when><xsl:when test="$scriptCode='(2'">Hebrew</xsl:when><xsl:when test="$scriptCode='(S'">Greek</xsl:when></xsl:choose></xsl:attribute>
+       </xsl:template>
+       <xsl:template name="parsePart">
+               <!-- assumes 773$q= 1:2:3<4
+                    with up to 3 levels and one optional start page
+               -->
+               <xsl:variable name="level1">
+                       <xsl:choose>
+                               <xsl:when test="contains(text(),':')">
+                                       <!-- 1:2 -->
+                                       <xsl:value-of select="substring-before(text(),':')"/>
+                               </xsl:when>
+                               <xsl:when test="not(contains(text(),':'))">
+                                       <!-- 1 or 1<3 -->
+                                       <xsl:if test="contains(text(),'&lt;')">
+                                               <!-- 1<3 -->
+                                               <xsl:value-of select="substring-before(text(),'&lt;')"/>
+                                       </xsl:if>
+                                       <xsl:if test="not(contains(text(),'&lt;'))">
+                                               <!-- 1 -->
+                                               <xsl:value-of select="text()"/>
+                                       </xsl:if>
+                               </xsl:when>
+                       </xsl:choose>
+               </xsl:variable>
+               <xsl:variable name="sici2">
+                       <xsl:choose>
+                               <xsl:when test="starts-with(substring-after(text(),$level1),':')">
+                                       <xsl:value-of select="substring(substring-after(text(),$level1),2)"/>
+                               </xsl:when>
+                               <xsl:otherwise>
+                                       <xsl:value-of select="substring-after(text(),$level1)"/>
+                               </xsl:otherwise>
+                       </xsl:choose>
+               </xsl:variable>
+               <xsl:variable name="level2">
+                       <xsl:choose>
+                               <xsl:when test="contains($sici2,':')">
+                                       <!--  2:3<4  -->
+                                       <xsl:value-of select="substring-before($sici2,':')"/>
+                               </xsl:when>
+                               <xsl:when test="contains($sici2,'&lt;')">
+                                       <!-- 1: 2<4 -->
+                                       <xsl:value-of select="substring-before($sici2,'&lt;')"/>
+                               </xsl:when>
+                               <xsl:otherwise>
+                                       <xsl:value-of select="$sici2"/>
+                                       <!-- 1:2 -->
+                               </xsl:otherwise>
+                       </xsl:choose>
+               </xsl:variable>
+               <xsl:variable name="sici3">
+                       <xsl:choose>
+                               <xsl:when test="starts-with(substring-after($sici2,$level2),':')">
+                                       <xsl:value-of select="substring(substring-after($sici2,$level2),2)"/>
+                               </xsl:when>
+                               <xsl:otherwise>
+                                       <xsl:value-of select="substring-after($sici2,$level2)"/>
+                               </xsl:otherwise>
+                       </xsl:choose>
+               </xsl:variable>
+               <xsl:variable name="level3">
+                       <xsl:choose>
+                               <xsl:when test="contains($sici3,'&lt;')">
+                                       <!-- 2<4 -->
+                                       <xsl:value-of select="substring-before($sici3,'&lt;')"/>
+                               </xsl:when>
+                               <xsl:otherwise>
+                                       <xsl:value-of select="$sici3"/>
+                                       <!-- 3 -->
+                               </xsl:otherwise>
+                       </xsl:choose>
+               </xsl:variable>
+               <xsl:variable name="page">
+                       <xsl:if test="contains(text(),'&lt;')">
+                               <xsl:value-of select="substring-after(text(),'&lt;')"/>
+                       </xsl:if>
+               </xsl:variable>
+               <xsl:if test="$level1">
+                       <detail level="1">
+                               <number>
+                                       <xsl:value-of select="$level1"/>
+                               </number>
+                       </detail>
+               </xsl:if>
+               <xsl:if test="$level2">
+                       <detail level="2">
+                               <number>
+                                       <xsl:value-of select="$level2"/>
+                               </number>
+                       </detail>
+               </xsl:if>
+               <xsl:if test="$level3">
+                       <detail level="3">
+                               <number>
+                                       <xsl:value-of select="$level3"/>
+                               </number>
+                       </detail>
+               </xsl:if>
+               <xsl:if test="$page">
+                       <extent unit="page">
+                               <start>
+                                       <xsl:value-of select="$page"/>
+                               </start>
+                       </extent>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="getLanguage">
+               <xsl:param name="langString"/>
+               <xsl:param name="controlField008-35-37"/>
+               <xsl:variable name="length" select="string-length($langString)"/>
+               <xsl:choose>
+                       <xsl:when test="$length=0"/>
+                       <xsl:when test="$controlField008-35-37=substring($langString,1,3)">
+                               <xsl:call-template name="getLanguage">
+                                       <xsl:with-param name="langString" select="substring($langString,4,$length)"/>
+                                       <xsl:with-param name="controlField008-35-37" select="$controlField008-35-37"/>
+                               </xsl:call-template>
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <language>
+                                       <languageTerm authority="iso639-2b" type="code">
+                                               <xsl:value-of select="substring($langString,1,3)"/>
+                                       </languageTerm>
+                               </language>
+                               <xsl:call-template name="getLanguage">
+                                       <xsl:with-param name="langString" select="substring($langString,4,$length)"/>
+                                       <xsl:with-param name="controlField008-35-37" select="$controlField008-35-37"/>
+                               </xsl:call-template>
+                       </xsl:otherwise>
+               </xsl:choose>
+       </xsl:template>
+       <xsl:template name="isoLanguage">
+               <xsl:param name="currentLanguage"/>
+               <xsl:param name="usedLanguages"/>
+               <xsl:param name="remainingLanguages"/>
+               <xsl:choose>
+                       <xsl:when test="string-length($currentLanguage)=0"/>
+                       <xsl:when test="not(contains($usedLanguages, $currentLanguage))">
+                               <language>
+                                       <languageTerm authority="iso639-2b" type="code">
+                                               <xsl:if test="@code!='a'">
+                                                       <xsl:attribute name="objectPart"><xsl:choose><xsl:when test="@code='b'">summary or subtitle</xsl:when><xsl:when test="@code='d'">sung or spoken text</xsl:when><xsl:when test="@code='e'">libretto</xsl:when><xsl:when test="@code='f'">table of contents</xsl:when><xsl:when test="@code='g'">accompanying material</xsl:when><xsl:when test="@code='h'">translation</xsl:when></xsl:choose></xsl:attribute>
+                                               </xsl:if>
+                                               <xsl:value-of select="$currentLanguage"/>
+                                       </languageTerm>
+                               </language>
+                               <xsl:call-template name="isoLanguage">
+                                       <xsl:with-param name="currentLanguage">
+                                               <xsl:value-of select="substring($remainingLanguages,1,3)"/>
+                                       </xsl:with-param>
+                                       <xsl:with-param name="usedLanguages">
+                                               <xsl:value-of select="concat($usedLanguages,$currentLanguage)"/>
+                                       </xsl:with-param>
+                                       <xsl:with-param name="remainingLanguages">
+                                               <xsl:value-of select="substring($remainingLanguages,4,string-length($remainingLanguages))"/>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <xsl:call-template name="isoLanguage">
+                                       <xsl:with-param name="currentLanguage">
+                                               <xsl:value-of select="substring($remainingLanguages,1,3)"/>
+                                       </xsl:with-param>
+                                       <xsl:with-param name="usedLanguages">
+                                               <xsl:value-of select="concat($usedLanguages,$currentLanguage)"/>
+                                       </xsl:with-param>
+                                       <xsl:with-param name="remainingLanguages">
+                                               <xsl:value-of select="substring($remainingLanguages,4,string-length($remainingLanguages))"/>
+                                       </xsl:with-param>
+                               </xsl:call-template>
+                       </xsl:otherwise>
+               </xsl:choose>
+       </xsl:template>
+       <xsl:template name="chopBrackets">
+               <xsl:param name="chopString"/>
+               <xsl:variable name="string">
+                       <xsl:call-template name="chopPunctuation">
+                               <xsl:with-param name="chopString" select="$chopString"/>
+                       </xsl:call-template>
+               </xsl:variable>
+               <xsl:if test="substring($string, 1,1)='['">
+                       <xsl:value-of select="substring($string,2, string-length($string)-2)"/>
+               </xsl:if>
+               <xsl:if test="substring($string, 1,1)!='['">
+                       <xsl:value-of select="$string"/>
+               </xsl:if>
+       </xsl:template>
+       <xsl:template name="rfcLanguages">
+               <xsl:param name="nodeNum"/>
+               <xsl:param name="usedLanguages"/>
+               <xsl:param name="controlField008-35-37"/>
+               <xsl:variable name="currentLanguage" select="."/>
+               <xsl:choose>
+                       <xsl:when test="not($currentLanguage)"/>
+                       <xsl:when test="$currentLanguage!=$controlField008-35-37 and $currentLanguage!='rfc3066'">
+                               <xsl:if test="not(contains($usedLanguages,$currentLanguage))">
+                                       <language>
+                                               <languageTerm authority="rfc3066" type="code">
+                                                       <xsl:if test="@code!='a'">
+                                                               <xsl:attribute name="objectPart"><xsl:choose><xsl:when test="@code='b'">summary or subtitle</xsl:when><xsl:when test="@code='d'">sung or spoken text</xsl:when><xsl:when test="@code='e'">libretto</xsl:when><xsl:when test="@code='f'">table of contents</xsl:when><xsl:when test="@code='g'">accompanying material</xsl:when><xsl:when test="@code='h'">translation</xsl:when></xsl:choose></xsl:attribute>
+                                                       </xsl:if>
+                                                       <xsl:value-of select="$currentLanguage"/>
+                                               </languageTerm>
+                                       </language>
+                               </xsl:if>
+                       </xsl:when>
+                       <xsl:otherwise>
+                               
+                       </xsl:otherwise>
+               </xsl:choose>
+       </xsl:template>
+</xsl:stylesheet>
+
+<!-- Stylus Studio meta-information - (c) 2004-2005. Progress Software Corporation. All rights reserved.
+<metaInformation>
+<scenarios ><scenario default="no" name="Apr 02 Test" userelativepaths="yes" externalpreview="no" url="file:///n:/jackie/test_files/v3.xml" htmlbaseurl="" outputurl="file:///n:/temp/x.xml" processortype="xalan" useresolver="no" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator=""/><scenario default="no" name="v3Test1" userelativepaths="yes" externalpreview="no" url="file:///n:/jackie/test_files/v3.xml" htmlbaseurl="" outputurl="file:///n:/jackie/test_files/modsv3Converted.xml" processortype="internal" useresolver="no" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator=""/><scenario default="no" name="Scenario1" userelativepaths="yes" externalpreview="no" url="file:///n:/ckeith/DESKTOP/test.xml" htmlbaseurl="" outputurl="" processortype="xalan" useresolver="no" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator=""/><scenario default="no" name="Test" userelativepaths="yes" externalpreview="no" url="file:///n:/jackie/MARCXML/marcxmlfile.xml" htmlbaseurl="" outputurl="" processortype="xalan" useresolver="no" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator=""/><scenario default="yes" name="z3950 package test" userelativepaths="yes" externalpreview="no" url="d.xml" htmlbaseurl="" outputurl="" processortype="xalan" useresolver="no" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator=""/></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/><MapperBlockPosition></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
+</metaInformation>
+-->
\ No newline at end of file
diff --git a/xml/xslt/MARC21slim2RDFDC.xsl b/xml/xslt/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/xml/xslt/MARC21slim2SRWDC.xsl b/xml/xslt/MARC21slim2SRWDC.xsl
new file mode 100644 (file)
index 0000000..5ae8ec6
--- /dev/null
@@ -0,0 +1,261 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:srw_dc="info:srw/schema/1/dc-schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="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" encoding="UTF-8"/>\r
+       <!-- modification log \r
+       NT 01/04:  added collection level element\r
+       and removed attributes\r
+\r
+       JR 06/04:  Added ISBN identifier\r
+\r
+   JR 09/05:  Added additional <subject> subfields and 651 for <coverage>\r
+   RG 10/07/05: Corrected subject subfields; 10/12/05: added if statement for <language>\r
+   JR 05/05/06:  Updated the schemaLocation\r
+-->\r
+       <xsl:template match="/">\r
+               <xsl:if test="marc:collection">\r
+                       <srw_dc:dcCollection xmlns:srw_dc="info:srw/schema/1/dc-schema" xsi:schemaLocation="info:srw/schema/1/dc-schema http://www.loc.gov/standards/sru/dc-schema.xsd">\r
+                               <xsl:for-each select="marc:collection">\r
+                                       <xsl:for-each select="marc:record">\r
+                                               <srw_dc:dc>\r
+                                                       <xsl:apply-templates select="."/>\r
+                                               </srw_dc:dc>\r
+                                       </xsl:for-each>\r
+                               </xsl:for-each>\r
+                       </srw_dc:dcCollection>\r
+               </xsl:if>\r
+               <xsl:if test="marc:record">\r
+                       <srw_dc:dc xmlns:srw_dc="info:srw/schema/1/dc-schema" xsi:schemaLocation="info:srw/schema/1/dc-schema http://www.loc.gov/standards/sru/dc-schema.xsd">\r
+                               <xsl:apply-templates select="marc:record"/>\r
+                       </srw_dc:dc>\r
+               </xsl:if>\r
+       </xsl:template>\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
+               <xsl:for-each select="marc:datafield[@tag=245]">\r
+                       <title>\r
+                               <xsl:call-template name="subfieldSelect">\r
+                                       <xsl:with-param name="codes">abfghk</xsl:with-param>\r
+                               </xsl:call-template>\r
+                       </title>\r
+               </xsl:for-each>\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
+                       <creator>\r
+                               <xsl:value-of select="normalize-space(.)"/>\r
+                       </creator>\r
+               </xsl:for-each>\r
+               <type>\r
+                       <xsl:if test="$leader7='c'">\r
+                               <!-- nt fix 1/04 -->\r
+                               <!--<xsl:attribute name="collection">yes</xsl:attribute>-->\r
+                               <xsl:text>collection</xsl:text>\r
+                       </xsl:if>\r
+                       <xsl:if test="$leader6='d' or $leader6='f' or $leader6='p' or $leader6='t'">\r
+                               <!-- nt fix 1/04 -->\r
+                               <!--<xsl:attribute name="manuscript">yes</xsl:attribute> -->\r
+                               <xsl:text>manuscript</xsl:text>\r
+                       </xsl:if>\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
+               </type>\r
+               <xsl:for-each select="marc:datafield[@tag=655]">\r
+                       <type>\r
+                               <xsl:value-of select="normalize-space(.)"/>\r
+                       </type>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=260]">\r
+                       <publisher>\r
+                               <xsl:call-template name="subfieldSelect">\r
+                                       <xsl:with-param name="codes">ab</xsl:with-param>\r
+                               </xsl:call-template>\r
+                       </publisher>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=260]/marc:subfield[@code='c']">\r
+                       <date>\r
+                               <xsl:value-of select="."/>\r
+                       </date>\r
+               </xsl:for-each>\r
+               <xsl:if test="substring($controlField008,36,3)">\r
+                       <language>\r
+                               <xsl:value-of select="substring($controlField008,36,3)"/>\r
+                       </language>\r
+               </xsl:if>               \r
+               <xsl:for-each select="marc:datafield[@tag=856]/marc:subfield[@code='q']">\r
+                       <format>\r
+                               <xsl:value-of select="."/>\r
+                       </format>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=520]">\r
+                       <description>\r
+                               <!-- nt fix 01/04 -->\r
+                               <xsl:value-of select="normalize-space(marc:subfield[@code='a'])"/>\r
+                       </description>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=521]">\r
+                       <description>\r
+                               <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                       </description>\r
+               </xsl:for-each>\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
+                       <description>\r
+                               <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                       </description>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=600]">\r
+                       <subject>\r
+                               <xsl:call-template name="subfieldSelect">\r
+                                       <xsl:with-param name="codes">abcdefghjklmnopqrstu4</xsl:with-param>\r
+                               </xsl:call-template>\r
+                               <xsl:if test="marc:subfield[@code='v' or @code='x' or @code='y' or @code='z']">\r
+                               <xsl:text>--</xsl:text>\r
+                               <xsl:call-template name="subfieldSelect">\r
+                                       <xsl:with-param name="codes">vxyz</xsl:with-param>\r
+                                       <xsl:with-param name="delimeter">--</xsl:with-param>\r
+                               </xsl:call-template>\r
+                               </xsl:if>\r
+                       </subject>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=610]">\r
+                       <subject>\r
+                               <xsl:call-template name="subfieldSelect">\r
+                                       <xsl:with-param name="codes">abcdefghklmnoprstu4</xsl:with-param>\r
+                               </xsl:call-template>\r
+                               <xsl:if test="marc:subfield[@code='v' or @code='x' or @code='y' or\r
+                                       @code='z']">\r
+                                       <xsl:text>--</xsl:text>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">vxyz</xsl:with-param>\r
+                                               <xsl:with-param name="delimeter">--</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </xsl:if>\r
+                       </subject>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=611]">\r
+                       <subject>\r
+                               <xsl:call-template name="subfieldSelect">\r
+                                       <xsl:with-param name="codes">acdefghklnpqstu4</xsl:with-param>\r
+                               </xsl:call-template>\r
+                               <xsl:if test="marc:subfield[@code='v' or @code='x' or @code='y' or\r
+                                       @code='z']">\r
+                                       <xsl:text>--</xsl:text>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">vxyz</xsl:with-param>\r
+                                               <xsl:with-param name="delimeter">--</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </xsl:if>\r
+                       </subject>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=630]">\r
+                       <subject>\r
+                               <xsl:call-template name="subfieldSelect">\r
+                                       <xsl:with-param name="codes">adfghklmnoprst</xsl:with-param>\r
+                               </xsl:call-template>\r
+                               <xsl:if test="marc:subfield[@code='v' or @code='x' or @code='y' or\r
+                                       @code='z']">\r
+                                       <xsl:text>--</xsl:text>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">vxyz</xsl:with-param>\r
+                                               <xsl:with-param name="delimeter">--</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </xsl:if>\r
+                       </subject>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=650]">\r
+                       <subject>\r
+                               <xsl:call-template name="subfieldSelect">\r
+                                       <xsl:with-param name="codes">ae</xsl:with-param></xsl:call-template>\r
+                               <xsl:if test="marc:subfield[@code='v' or @code='x' or @code='y' or\r
+                                       @code='z']">\r
+                                       <xsl:text>--</xsl:text>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">vxyz</xsl:with-param>\r
+                                               <xsl:with-param name="delimeter">--</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </xsl:if>\r
+                       </subject>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=653]">\r
+                       <subject>\r
+                               <xsl:call-template name="subfieldSelect">\r
+                                       <xsl:with-param name="codes">a</xsl:with-param>\r
+                               </xsl:call-template>\r
+                       </subject>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=651]">\r
+                       <coverage>\r
+                               <xsl:call-template name="subfieldSelect">\r
+                                       <xsl:with-param name="codes">a</xsl:with-param>\r
+                               </xsl:call-template>\r
+                               <xsl:if test="marc:subfield[@code='v' or @code='x' or @code='y' or\r
+                                       @code='z']">\r
+                                       <xsl:text>--</xsl:text>\r
+                                       <xsl:call-template name="subfieldSelect">\r
+                                               <xsl:with-param name="codes">vxyz</xsl:with-param>\r
+                                               <xsl:with-param name="delimeter">--</xsl:with-param>\r
+                                       </xsl:call-template>\r
+                               </xsl:if>\r
+                       </coverage>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=752]">\r
+                       <coverage>\r
+                               <xsl:call-template name="subfieldSelect">\r
+                                       <xsl:with-param name="codes">abcd</xsl:with-param>\r
+                               </xsl:call-template>\r
+                       </coverage>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=530]">\r
+                       <!-- nt 01/04 attribute fix -->\r
+                       <relation>\r
+                               <!--<xsl:attribute name="type">original</xsl:attribute>-->\r
+                               <xsl:call-template name="subfieldSelect">\r
+                                       <xsl:with-param name="codes">abcdu</xsl:with-param>\r
+                               </xsl:call-template>\r
+                       </relation>\r
+               </xsl:for-each>\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
+                       <relation>\r
+                               <xsl:call-template name="subfieldSelect">\r
+                                       <xsl:with-param name="codes">ot</xsl:with-param>\r
+                               </xsl:call-template>\r
+                       </relation>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=856]">\r
+                       <identifier>\r
+                               <xsl:value-of select="marc:subfield[@code='u']"/>\r
+                       </identifier>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=020]">\r
+                       <identifier>\r
+                               <xsl:text>URN:ISBN:</xsl:text>\r
+                               <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                       </identifier>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=506]">\r
+                       <rights>\r
+                               <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                       </rights>\r
+               </xsl:for-each>\r
+               <xsl:for-each select="marc:datafield[@tag=540]">\r
+                       <rights>\r
+                               <xsl:value-of select="marc:subfield[@code='a']"/>\r
+                       </rights>\r
+               </xsl:for-each>\r
+       </xsl:template>\r
+</xsl:stylesheet>\r
+<!-- Stylus Studio meta-information - (c)1998-2003 Copyright Sonic Software Corporation. All rights reserved.\r
+<metaInformation>\r
+<scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>\r
+</metaInformation>\r
+-->
\ No newline at end of file
diff --git a/xml/xslt/MARC21slimUtils.xsl b/xml/xslt/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