我想将带有唯一标识符标记的自定义xml转换为MARCXML,但我不知道从哪里开始。例如,我需要获取<untl:title qualifier="officialtitle" >Equation of State and Heat Content of Uranium</untl:title>
并将其分配给 245 字段。这是我尝试拉取标题,但我不知道在哪里指定使用哪个限定符从正确的元素中提取。我对 XSLT 的理解非常稀少,非常感谢任何帮助。
<xsl:for-each select="untl:title">
<datafield tag="245" ind1="1" ind2="0">
<subfield code="a">
<xsl:value-of select="."/>
</subfield>
</datafield>
</xsl:for-each>
编辑(8/17/2020):我正在使用一个名为MarcEdit的程序,他创建了XSLT工作表的预设,我相信可以为UNTL修改这些预设,但是我目前没有知识或专业知识来自定义它们。您将在下面看到目标结构表、我的当前代码以及我用作参考的预设 XSLT
。到目前为止的代码:不是很多,真的试图确定 UNTL 的命名空间。通过在线阅读,我对xsl:import的理解是,它将允许将目标结构(MARC21slimUtils)导入到我当前的XSL文件中。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:untl="https://library.unt.edu/digital-projects-unit/metadata/input-guidelines-descriptive/"
xmlns:untlterms ="https://library.unt.edu/digital-projects-unit/metadata/input-guidelines-descriptive/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://digital2.library.unt.edu/untl.xsd"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.loc.gov/MARC21/slim" exclude-result-prefixes=" untl untlterms ">
<xsl:import href="MARC21slimUtils.xsl"/>
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" >
<xsl:apply-templates />
</collection>
</xsl:template>
</xsl:stylesheet>
示例记录:
<record>
<header>
<identifier>info:ark/67531/metadc714189</identifier>
<datestamp>2019-04-23T20:54:10Z</datestamp>
<setSpec>partner:UNTGD</setSpec>
<setSpec>collection:TRAIL</setSpec>
<setSpec>collection:TRAMC</setSpec>
<setSpec>access_rights:public</setSpec>
</header>
<metadata>
<untl:metadata xmlns:untl="http://digital2.library.unt.edu/untl/">
<untl:title qualifier="officialtitle">Critical-Assembly Studies on an Intermediate Reactor for Aircraft Propulsion</untl:title>
<untl:title qualifier="seriestitle">BMI (Series)</untl:title>
<untl:title qualifier="seriestitle">Battelle Memorial Institute Reports</untl:title>
<untl:title qualifier="addedtitle">Battelle Memorial Institute Report BMI-1209</untl:title>
<untl:creator qualifier="aut">
<untl:name>Marinaccio, Lawrence F.</untl:name>
<untl:type>per</untl:type>
</untl:creator>
<untl:creator qualifier="aut">
<untl:name>Jung, Richard G.</untl:name>
<untl:type>per</untl:type>
</untl:creator>
<untl:creator qualifier="aut">
<untl:name>Jankowski, Francis J.</untl:name>
<untl:type>per</untl:type>
</untl:creator>
<untl:creator qualifier="aut">
<untl:name>Dingee, David A.</untl:name>
<untl:type>per</untl:type>
</untl:creator>
<untl:creator qualifier="aut">
<untl:name>Chastain, Joel W.</untl:name>
<untl:type>per</untl:type>
</untl:creator>
<untl:contributor qualifier="org">
<untl:name>U.S. Atomic Energy Commission</untl:name>
<untl:type>org</untl:type>
</untl:contributor>
<untl:contributor qualifier="org">
<untl:name>Battelle Memorial Institute</untl:name>
<untl:type>org</untl:type>
</untl:contributor>
<untl:publisher>
<untl:location>Columbus, Ohio</untl:location>
<untl:name>Battelle Memorial Institute</untl:name>
</untl:publisher>
<untl:date qualifier="creation">1957-07-15</untl:date>
<untl:language>eng</untl:language>
<untl:description qualifier="content">The following report studies an intermediate solid-fuel reactor system for aircraft propulsion.</untl:description>
<untl:description qualifier="physical">[87] p. : ill., tables ; 28 cm.</untl:description>
<untl:subject qualifier="LCSH">Airplanes -- Nuclear power plants.</untl:subject>
<untl:subject qualifier="LCSH">Liquid metal cooled reactors.</untl:subject>
<untl:primarySource>1</untl:primarySource>
<untl:coverage qualifier="placeName">United States</untl:coverage>
<untl:collection>TRAIL</untl:collection>
<untl:collection>TRAMC</untl:collection>
<untl:institution>UNTGD</untl:institution>
<untl:rights qualifier="note">The contents of TRAIL Microcard Collection, hosted by the University of North Texas Libraries (digital content including images, text, and sound and video recordings) are made publicly available by the collection-holding partners for use in research, teaching, and private study. For the full terms of use, see https://digital.library.unt.edu/terms-of-use/</untl:rights>
<untl:resourceType>text_report</untl:resourceType>
<untl:format>text</untl:format>
<untl:identifier qualifier="itemURL">https://digital.library.unt.edu/ark:/67531/metadc714189/</untl:identifier>
<untl:identifier qualifier="OCLC">922939295</untl:identifier>
<untl:identifier qualifier="SUDOC">Y 3.AT 7:22/BMI-1209</untl:identifier>
<untl:identifier qualifier="REP-NO">BMI-1209</untl:identifier>
<untl:identifier qualifier="thumbnailURL">https://digital.library.unt.edu/ark:/67531/metadc714189/small/</untl:identifier>
<untl:identifier qualifier="ARK">ark:/67531/metadc714189</untl:identifier>
<untl:identifier qualifier="iiif-manifest">https://digital.library.unt.edu/ark:/67531/metadc714189/manifest/</untl:identifier>
<untl:note qualifier="display">Digitized from microopaque cards.</untl:note>
<untl:meta qualifier="system">DC</untl:meta>
<untl:meta qualifier="ark">ark:/67531/metadc714189</untl:meta>
<untl:meta qualifier="metadataCreationDate">2018-02-12, 07:42:45</untl:meta>
<untl:meta qualifier="metadataModifier">htarver</untl:meta>
<untl:meta qualifier="metadataModificationDate">2019-04-23, 20:54:10</untl:meta>
<untl:meta qualifier="hidden">False</untl:meta>
</untl:metadata>
</metadata>
</record>
目标结构 (MARC21slimUtils):
xsd:schema xmlns="http://www.loc.gov/MARC21/slim" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.loc.gov/MARC21/slim" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.1" xml:lang="en">
<xsd:annotation>
<xsd:documentation> MARCXML: The MARC 21 XML Schema Prepared by Corey Keith May 21, 2002 - Version 1.0 - Initial Release ********************************************** Changes. August 4, 2003 - Version 1.1 - Removed import of xml namespace and the use of xml:space="preserve" attributes on the leader and controlfields. Whitespace preservation in these subfields is accomplished by the use of xsd:whiteSpace value="preserve" May 21, 2009 - Version 1.2 - in subfieldcodeDataType the pattern "[da-z!"#$%&'()*+,-./:;<=>?{}_^`~[]\]{1}" changed to: "[dA-Za-z!"#$%&'()*+,-./:;<=>?{}_^`~[]\]{1}" i.e "A-Z" added after "[d" before "a-z" to allow upper case. This change is for consistency with the documentation. ************************************************************ This schema supports XML markup of MARC21 records as specified in the MARC documentation (see www.loc.gov). It allows tags with alphabetics and subfield codes that are symbols, neither of which are as yet used in the MARC 21 communications formats, but are allowed by MARC 21 for local data. The schema accommodates all types of MARC 21 records: bibliographic, holdings, bibliographic with embedded holdings, authority, classification, and community information. </xsd:documentation>
</xsd:annotation>
<xsd:element name="record" type="recordType" nillable="true" id="record.e">
<xsd:annotation>
<xsd:documentation>record is a top level container element for all of the field elements which compose the record</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="collection" type="collectionType" nillable="true" id="collection.e">
<xsd:annotation>
<xsd:documentation>collection is a top level container element for 0 or many records</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:complexType name="collectionType" id="collection.ct">
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="record"/>
</xsd:sequence>
<xsd:attribute name="id" type="idDataType" use="optional"/>
</xsd:complexType>
<xsd:complexType name="recordType" id="record.ct">
<xsd:sequence minOccurs="0">
<xsd:element name="leader" type="leaderFieldType"/>
<xsd:element name="controlfield" type="controlFieldType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="datafield" type="dataFieldType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="type" type="recordTypeType" use="optional"/>
<xsd:attribute name="id" type="idDataType" use="optional"/>
</xsd:complexType>
<xsd:simpleType name="recordTypeType" id="type.st">
<xsd:restriction base="xsd:NMTOKEN">
<xsd:enumeration value="Bibliographic"/>
<xsd:enumeration value="Authority"/>
<xsd:enumeration value="Holdings"/>
<xsd:enumeration value="Classification"/>
<xsd:enumeration value="Community"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="leaderFieldType" id="leader.ct">
<xsd:annotation>
<xsd:documentation>MARC21 Leader, 24 bytes</xsd:documentation>
</xsd:annotation>
<xsd:simpleContent>
<xsd:extension base="leaderDataType">
<xsd:attribute name="id" type="idDataType" use="optional"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:simpleType name="leaderDataType" id="leader.st">
<xsd:restriction base="xsd:string">
<xsd:whiteSpace value="preserve"/>
<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| )"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="controlFieldType" id="controlfield.ct">
<xsd:annotation>
<xsd:documentation>MARC21 Fields 001-009</xsd:documentation>
</xsd:annotation>
<xsd:simpleContent>
<xsd:extension base="controlDataType">
<xsd:attribute name="id" type="idDataType" use="optional"/>
<xsd:attribute name="tag" type="controltagDataType" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:simpleType name="controlDataType" id="controlfield.st">
<xsd:restriction base="xsd:string">
<xsd:whiteSpace value="preserve"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="controltagDataType" id="controltag.st">
<xsd:restriction base="xsd:string">
<xsd:whiteSpace value="preserve"/>
<xsd:pattern value="00[1-9A-Za-z]{1}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="dataFieldType" id="datafield.ct">
<xsd:annotation>
<xsd:documentation>MARC21 Variable Data Fields 010-999</xsd:documentation>
</xsd:annotation>
<xsd:sequence maxOccurs="unbounded">
<xsd:element name="subfield" type="subfieldatafieldType"/>
</xsd:sequence>
<xsd:attribute name="id" type="idDataType" use="optional"/>
<xsd:attribute name="tag" type="tagDataType" use="required"/>
<xsd:attribute name="ind1" type="indicatorDataType" use="required"/>
<xsd:attribute name="ind2" type="indicatorDataType" use="required"/>
</xsd:complexType>
<xsd:simpleType name="tagDataType" id="tag.st">
<xsd:restriction base="xsd:string">
<xsd:whiteSpace value="preserve"/>
<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}))"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="indicatorDataType" id="ind.st">
<xsd:restriction base="xsd:string">
<xsd:whiteSpace value="preserve"/>
<xsd:pattern value="[da-z ]{1}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="subfieldatafieldType" id="subfield.ct">
<xsd:simpleContent>
<xsd:extension base="subfieldDataType">
<xsd:attribute name="id" type="idDataType" use="optional"/>
<xsd:attribute name="code" type="subfieldcodeDataType" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:simpleType name="subfieldDataType" id="subfield.st">
<xsd:restriction base="xsd:string">
<xsd:whiteSpace value="preserve"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="subfieldcodeDataType" id="code.st">
<xsd:restriction base="xsd:string">
<xsd:whiteSpace value="preserve"/>
<xsd:pattern value="[dA-Za-z!"#$%&'()*+,-./:;<=>?{}_^`~[]\]{1}"/>
<!-- "A-Z" added after "d" May 21, 2009 -->
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="idDataType" id="id.st">
<xsd:restriction base="xsd:ID"/>
</xsd:simpleType>
</xsd:schema>
引用 MarcEdit 中的 XSLT Sheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/1.1"
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/
http://www.openarchives.org/OAI/2.0/oai_dc.xsd"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.loc.gov/MARC21/slim" exclude-result-prefixes="dc dcterms oai_dc">
<xsl:import href="MARC21slimUtils.xsl"/>
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" >
<xsl:apply-templates />
</collection>
</xsl:template>
<xsl:template name="OAI-PMH">
<xsl:for-each select = "ListRecords/record/metadata/oai_dc:dc">
<xsl:apply-templates />
</xsl:for-each>
<xsl:for-each select = "GetRecord/record/metadata/oai_dc:dc">
<xsl:apply-templates />
</xsl:for-each>
</xsl:template>
<xsl:template match="text()" />
<xsl:template match="oai_dc:dc">
<record>
<xsl:element name="leader">
<xsl:variable name="type" select="dc:type"/>
<xsl:variable name="leader06">
<xsl:choose>
<xsl:when test="$type='collection'">p</xsl:when>
<xsl:when test="$type='dataset'">m</xsl:when>
<xsl:when test="$type='event'">r</xsl:when>
<xsl:when test="$type='image'">k</xsl:when>
<xsl:when test="$type='interactive resource'">m</xsl:when>
<xsl:when test="$type='service'">m</xsl:when>
<xsl:when test="$type='software'">m</xsl:when>
<xsl:when test="$type='sound'">i</xsl:when>
<xsl:when test="$type='text'">a</xsl:when>
<xsl:otherwise>a</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="leader07">
<xsl:choose>
<xsl:when test="$type='collection'">c</xsl:when>
<xsl:otherwise>m</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat(' ',$leader06,$leader07,' a 3u ')"/>
</xsl:element>
<datafield tag="042" ind1=" " ind2=" ">
<subfield code="a">dc</subfield>
</datafield>
<xsl:for-each select="dc:creator">
<xsl:choose>
<xsl:when test="(.!='') and (position()=1)">
<xsl:call-template name="persname_template">
<xsl:with-param name="string" select="." />
<xsl:with-param name="field" select="'100'" />
<xsl:with-param name="ind1" select = "'1'" />
<xsl:with-param name="ind2" select = "'0'" />
<xsl:with-param name="type" select="'author'" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:if test=".!=''">
<xsl:call-template name="persname_template">
<xsl:with-param name="string" select="." />
<xsl:with-param name="field" select="'700'" />
<xsl:with-param name="ind1" select = "'1'" />
<xsl:with-param name="ind2" select = "'0'" />
<xsl:with-param name="type" select="'author'" />
</xsl:call-template>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:for-each select="dc:title[1]">
<datafield tag="245" ind1="0" ind2="0">
<subfield code="a">
<xsl:value-of select="."/>
</subfield>
</datafield>
</xsl:for-each>
<xsl:for-each select="dc:title[position()>1]">
<xsl:if test=".!=''">
<datafield tag="246" ind1="3" ind2="3">
<subfield code="a">
<xsl:value-of select="."/>
</subfield>
</datafield>
</xsl:if>
</xsl:for-each>
<xsl:choose>
<xsl:when test="dc:publisher">
<xsl:if test="translate(dc:publisher/.,'.,:;','')!=''">
<datafield tag="260" ind1=" " ind2=" ">
<xsl:choose>
<xsl:when test="dc:date">
<subfield code="b"><xsl:value-of select="dc:publisher[1]"/>, </subfield>
<xsl:if test="translate(dc:date[1]/., '.,:;','')!=''">
<subfield code="c"><xsl:value-of select="dc:date[1]" />.</subfield>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<subfield code="b"><xsl:value-of select="dc:publisher[1]"/>.</subfield>
</xsl:otherwise>
</xsl:choose>
</datafield>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:if test="translate(dc:date[1],'.,:;','')!=''">
<datafield tag="260" ind1=" " ind2=" ">
<subfield code="c"><xsl:value-of select="dc:date[1]" />.</subfield>
</datafield>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="dc:coverage">
<xsl:choose>
<xsl:when test="translate(., '0123456789-.?','')=''">
<!--Likely;this is a date-->
<datafield tag="500" ind1=" " ind2=" ">
<subfield code="a"><xsl:value-of select="."/></subfield>
</datafield>
</xsl:when>
<xsl:otherwise>
<!--likely a geographic subject, we will print this later-->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:for-each select="dc:identifier">
<xsl:if test="position()!=last()">
<datafield tag="500" ind1=" " ind2=" ">
<subfield code="a"><xsl:value-of select="." /></subfield>
</datafield>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="dc:description">
<datafield tag="520" ind1=" " ind2=" ">
<subfield code="a">
<xsl:value-of select="normalize-space(.)"/>
</subfield>
</datafield>
</xsl:for-each>
<xsl:for-each select="dc:rights">
<datafield tag="540" ind1=" " ind2=" ">
<subfield code="a">
<xsl:value-of select="."/>
</subfield>
</datafield>
</xsl:for-each>
<xsl:for-each select="dc:language">
<datafield tag="546" ind1=" " ind2=" ">
<subfield code="a">
<xsl:value-of select="."/>
</subfield>
</datafield>
</xsl:for-each>
<xsl:for-each select="dc:subject">
<datafield tag="690" ind1=" " ind2=" ">
<subfield code="a">
<xsl:value-of select="."/>
</subfield>
</datafield>
</xsl:for-each>
<xsl:for-each select="dc:coverage">
<xsl:choose>
<xsl:when test="translate(., '0123456789-.?','')=''">
<!--Likely; this is a date-->
</xsl:when>
<xsl:otherwise>
<!--likely a geographic subject-->
<datafield tag="691" ind1=" " ind2=" ">
<subfield code="a"><xsl:value-of select="." /></subfield>
</datafield>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:for-each select="dc:type">
<datafield tag="655" ind1="7" ind2=" ">
<subfield code="a">
<xsl:value-of select="."/>
</subfield>
<subfield code="2">local</subfield>
</datafield>
</xsl:for-each>
<xsl:for-each select="dc:contributor">
<xsl:call-template name="persname_template">
<xsl:with-param name="string" select="." />
<xsl:with-param name="field" select="'100'" />
<xsl:with-param name="ind1" select = "'1'" />
<xsl:with-param name="ind2" select = "'0'" />
<xsl:with-param name="type" select="'contributor'" />
</xsl:call-template>
</xsl:for-each>
<xsl:for-each select="dc:source">
<datafield tag="786" ind1="0" ind2=" ">
<subfield code="n">
<xsl:value-of select="."/>
</subfield>
</datafield>
</xsl:for-each>
<xsl:for-each select="dc:relation">
<datafield tag="787" ind1="0" ind2=" ">
<subfield code="n">
<xsl:value-of select="."/>
</subfield>
</datafield>
</xsl:for-each>
<xsl:if test="dc:identifier">
<datafield tag="856" ind1="4" ind2="1">
<subfield code="u"><xsl:value-of select="dc:identifier[last()]" /></subfield>
<subfield code="z">Connect to this object online.</subfield>
</datafield>
</xsl:if>
</record>
</xsl:template>
<xsl:template name="persname_template">
<xsl:param name="string" />
<xsl:param name="field" />
<xsl:param name="ind1" />
<xsl:param name="ind2" />
<xsl:param name="type" />
<datafield>
<xsl:attribute name="tag">
<xsl:value-of select="$field" />
</xsl:attribute>
<xsl:attribute name="ind1">
<xsl:value-of select="$ind1" />
</xsl:attribute>
<xsl:attribute name="ind2">
<xsl:value-of select="$ind2" />
</xsl:attribute>
<!-- Sample input: Brightman, Samuel C. (Samuel Charles), 1911-1992 -->
<!-- Sample output: $aBrightman, Samuel C. $q(Samuel Charles), $d1911-. -->
<!-- will handle names with dashes e.g. Bourke-White, Margaret -->
<!-- CAPTURE PRIMARY NAME BY LOOKING FOR A PAREN OR A DASH OR NEITHER -->
<xsl:choose>
<!-- IF A PAREN, STOP AT AN OPENING PAREN -->
<xsl:when test="contains($string, '(')!=0">
<subfield code="a">
<xsl:value-of select="substring-before($string, '(')" />
</subfield>
</xsl:when>
<!-- IF A DASH, CHECK IF IT'S A DATE OR PART OF THE NAME -->
<xsl:when test="contains($string, '-')!=0">
<xsl:variable name="name_1" select="substring-before($string, '-')" />
<xsl:choose>
<!-- IF IT'S A DATE REMOVE IT -->
<xsl:when test="translate(substring($name_1, (string-length($name_1)), 1), '0123456789', '9999999999') = '9'">
<xsl:variable name="name" select="substring($name_1, 1, (string-length($name_1)-6))" />
<subfield code="a">
<xsl:value-of select="$name" />
</subfield>
</xsl:when>
<!-- IF IT'S NOT A DATE, CHECK WHETHER THERE IS A DATE LATER -->
<xsl:otherwise>
<xsl:variable name="remainder" select="substring-after($string, '-')" />
<xsl:choose>
<!-- IF THERE'S A DASH, ASSUME IT'S A DATE AND REMOVE IT -->
<xsl:when test="contains($remainder, '-')!=0">
<xsl:variable name="tmp" select="substring-before($remainder, '-')" />
<xsl:variable name="name_2" select="substring($tmp, 1, (string-length($tmp)-6))" />
<subfield code="a">
<xsl:value-of select="$name_1" />-<xsl:value-of select="$name_2" />
</subfield>
</xsl:when>
<!-- IF THERE'S NO DASH IN THE REMAINDER, OUTPUT IT -->
<xsl:otherwise>
<subfield code="a">
<xsl:value-of select="$string" />
</subfield>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- NO DASHES, NO PARENS, JUST OUTPUT THE NAME -->
<xsl:otherwise>
<subfield code="a">
<xsl:value-of select="$string" />
</subfield>
</xsl:otherwise>
</xsl:choose>
<!-- CAPTURE SECONDARY NAME IN PARENS FOR SUBFIELD Q -->
<xsl:if test="contains($string, '(')!=0">
<xsl:variable name="subq_tmp" select="substring-after($string, '(')" />
<xsl:variable name="subq" select="substring-before($subq_tmp, ')')" />
<subfield code="q">
(<xsl:value-of select="$subq" />)
</subfield>
</xsl:if>
<!-- CAPTURE DATE FOR SUBFIELD D, ASSUME DATE IS LAST ITEM IN FIELD -->
<!-- Note: does not work if name has a dash in it -->
<xsl:if test="contains($string, '-')!=0">
<xsl:variable name="date_tmp" select="substring-before($string, '-')" />
<xsl:variable name="remainder" select="substring-after($string, '-')" />
<xsl:choose>
<!-- CHECK SECOND HALF FOR ANOTHER DASH; IF PRESENT, ASSUME THAT IS DATE -->
<xsl:when test="contains($remainder, '-')!=0">
<xsl:variable name="tmp" select="substring-before($remainder, '-')" />
<xsl:variable name="date_1" select="substring($remainder, (string-length($tmp)-3))" />
<!-- CHECK WHETHER IT HAS A NUMBER BEFORE IT AND IF SO, OUTPUT IT AS DATE -->
<xsl:if test="translate(substring($date_1, 1, 1), '0123456789', '9999999999') = '9'">
<subfield code="d">
<xsl:value-of select="$date_1" />.
</subfield>
</xsl:if>
</xsl:when>
<!-- OTHERWISE THIS IS THE ONLY DASH SO TAKE IT -->
<xsl:otherwise>
<xsl:variable name="date_2" select="substring($string, (string-length($date_tmp)-3))" />
<!-- CHECK WHETHER IT HAS A NUMBER BEFORE IT AND IF SO, OUTPUT IT AS DATE -->
<xsl:if test="translate(substring($date_2, 1, 1), '0123456789', '9999999999') = '9'">
<subfield code="d">
<xsl:value-of select="$date_2" />.
</subfield>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<subfield code="e"><xsl:value-of select="$type" /></subfield>
</datafield>
</xsl:template>
</xsl:stylesheet>
我认为这会让你开始。它显示了如何输出字段 100(作者):
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:untl="http://digital2.library.unt.edu/untl/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.loc.gov/MARC21/slim"
exclude-result-prefixes="untl"
>
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*" />
<xsl:template match="/">
<collection xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd">
<xsl:apply-templates select="record" />
</collection>
</xsl:template>
<xsl:template match="record">
<record>
<xsl:apply-templates select="metadata/untl:metadata" />
</record>
</xsl:template>
<xsl:template match="untl:metadata">
<!-- add more <xsl:apply-templates> in the desired field output order -->
<xsl:apply-templates select="untl:creator[@qualifier='aut']" />
</xsl:template>
<!-- write one template for each field -->
<xsl:template match="untl:creator[@qualifier='aut']">
<datafield tag="100" ind1="1" ind2=" ">
<subfield code="a">
<xsl:value-of select="untl:name" />
<xsl:text>,</xsl:text>
</subfield>
</datafield>
</xsl:template>
</xsl:stylesheet>
我特意为每个节点使用了一个模板,因此您可以看到程序如何从输入的根节点(/
)流出,然后继续选择每个节点都有自己的模板的特定节点。
我认为您根本不需要包含MARC21slimUtils.xsl
- 我已经看过它,在这种情况下,其中的实用程序函数没有增加任何实际价值。
输出(与官方 MARCXML 示例对齐),为便于阅读而格式化:
<collection xmlns="http://www.loc.gov/MARC21/slim"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
>
<record>
<datafield tag="100" ind1="1" ind2=" ">
<subfield code="a">Marinaccio, Lawrence F.,</subfield>
</datafield>
<datafield tag="100" ind1="1" ind2=" ">
<subfield code="a">Jung, Richard G.,</subfield>
</datafield>
<datafield tag="100" ind1="1" ind2=" ">
<subfield code="a">Jankowski, Francis J.,</subfield>
</datafield>
<datafield tag="100" ind1="1" ind2=" ">
<subfield code="a">Dingee, David A.,</subfield>
</datafield>
<datafield tag="100" ind1="1" ind2=" ">
<subfield code="a">Chastain, Joel W.,</subfield>
</datafield>
</record>
</collection>
我不确定具体细节,例如作者姓名中的尾随逗号,或者ind1
和ind2
的意义,你会比我更了解这些事情。