Moving From MARC to XML - Part One

There have been discussions on encoding bibliographic records in other than the MARC standard, so that machine-readable bibliographic data can become more open and interchangeable in the Internet environment. In 1995, the Library of Congress (LC) began to look into the feasibility of using the SGML (Standard Generalized Markup Language) standard to encode MARC 21 format. Subsequently, the MARC DTDs (Document Type Definitions) that define the MARC 21 data in SGML format were released. Early this year (1998), LC announced a software to convert between MARC 21 and SGML. See: for details.

The MARC DTDs developed by LC are mainly designed for the exchange of bibliographic data between MARC and SGML. To illustrate how complicated the structure is, I have included in the Appendix an example of the SGML-structured MARC record. It was converted from ISO2709 MARC format, using LC's conversion utilitiy

In December 1997, the World Wide Web Consortium published XML (Extensible Markup Language) Version 1.0. XML is a simplified standard of SGML. It promises to made the Web smarter by allowing Web pages to carry not just the layout, but the semantic structure of its content. Since then, many software companies have raced to apply it in various areas. Obviously, bibliographic data is one of the potential areas. Using XML standard and the XSL (Extensible Stylesheet Language) stylesheets,

Partly driven by an interest in knowing more about XML and partly driven by the need for a data interchange format for the SLS software, I began to develop an XML document type for MARC two weeks ago (it was 7 July 1998). It took me one hour to come up with a proposal. Refer to the Appendix for the XML equivalent of the above example for details. The example contains Chinese characters in Unicode's UTF-8, which is the default encoding scheme for the XML standard. However, you can use any encoding scheme that is registered on the Internet.

It took me several late nights to learn the XSL language and to write up a stylesheet to display the XML MARC record on a Web browser in MARC tag format. A sample XSL for this purpose is attached in the Appendix. You can view the effects by clicking on the following samples via Microsoft's Internet Explorer 5.x or above.

Netscape Version 6.0 still does not support XML and XSL. Before major browsers are able to support them, we will have to write server side scripts to do the XSL transformation to HTML format for displaying by the browsers.

K.T. Lam (
Created: 21 July 1998.
Last Revised: 28 November 2001.

Appendix: An Example

Library of Congress SGML Format

<?xml version="1.0" encoding="UTF-8"?>  
<mrcb format-type="bd">  
<mrcbldr-bd-05 value="n"/>  
<mrcbldr-bd-06 value="a"/>  
<mrcbldr-bd-07 value="m"/>  
<mrcbldr-bd-08 value="blank"/>  
<mrcbldr-bd-09 value="blank"/>  
<mrcbldr-bd-17 value="I"/>  
<mrcbldr-bd-18 value="a"/>  
<mrcbldr-bd-19 value="blank"/>  
<mrcb008-bk-00-05 value="920811"/>  
<mrcb008-bk-06 value="s"/>  
<mrcb008-bk-07-10 value="1991"/>  
<mrcb008-bk-11-14 value="blank"/>  
<mrcb008-bk-15-17 value="ch "/>  
<mrcb008-bk-18-21 value="blank"/>  
<mrcb008-bk-22 value="blank"/>  
<mrcb008-bk-23 value="blank"/>  
<mrcb008-bk-24-27 value="b   "/>  
<mrcb008-bk-28 value="blank"/>  
<mrcb008-bk-29 value="0"/>  
<mrcb008-bk-30 value="0"/>  
<mrcb008-bk-31 value="0"/>  
<mrcb008-bk-32 value="blank"/>  
<mrcb008-bk-33 value="0"/>  
<mrcb008-bk-34 value="blank"/>  
<mrcb008-bk-35-37 value="chi"/>  
<mrcb008-bk-38 value="blank"/>  
<mrcb008-bk-39 value="d"/>  
<mrcb020 i1="i1-blank" i2="i2-blank">  
<mrcb020-a>9571502537 (deluxe ed.)</mrcb020-a>  
<mrcb020 i1="i1-blank" i2="i2-blank">  
<mrcb020-a>9571502545 (pbk.)</mrcb020-a>  
<mrcb040 i1="i1-blank" i2="i2-blank">  
<mrcb049 i1="i1-blank" i2="i2-blank">  
<mrcb066 i1="i1-blank" i2="i2-blank">  
<mrcb090 i1="i1-blank" i2="i2-blank">  
<mrcb090-b>C467 1991</mrcb090-b>  
<mrcb100 i1="i1-1" i2="i2-blank">  
<mrcb100-a>Cheng, Yuanmin.</mrcb100-a>  
<mrcb245 i1="i1-1" i2="i2-0">  
<mrcb245-a>Chun qiu Zuo shi jing zhuan ji jie xu shu zheng /</mrcb245-a>  
<mrcb245-c>Cheng Yuanmin zhu.</mrcb245-c>  
<mrcb250 i1="i1-blank" i2="i2-blank">  
<mrcb250-a>Chu ban.</mrcb250-a>  
<mrcb260 i1="i1-blank" i2="i2-blank">  
<mrcb260-a>Taibei shi :</mrcb260-a>  
<mrcb260-b>Taiwan xue sheng shu ju,</mrcb260-b>  
<mrcb260-c>Min guo 80 [1991]</mrcb260-c>  
<mrcb300 i1="i1-blank" i2="i2-blank">  
<mrcb300-a>112 p. ;</mrcb300-a>  
<mrcb300-c>22 cm.</mrcb300-c>  
<mrcb504 i1="i1-blank" i2="i2-blank">  
<mrcb504-a>Includes bibliographical references (p. 109-112)</mrcb504-a>  
<mrcb600 i1="i1-0" i2="i2-0">  
<mrcb600-t>Chun qiu.</mrcb600-t>  
<mrcb600 i1="i1-1" i2="i2-0">  
<mrcb600-a>Zuoqiu, Ming.</mrcb600-a>  
<mrcb600-t>Zuo zhuan.</mrcb600-t>  
<mrcb700 i1="i1-1" i2="i2-blank">  
<mrcb700-a>Zuoqiu, Ming.</mrcb700-a>  
<mrcb700-t>Zuo zhuan.</mrcb700-t>  
<mrcb700 i1="i1-0" i2="i2-2">  
<mrcb700-t>Chun qiu.</mrcb700-t>  
<mrcb880 i1="i1-1" i2="i2-blank">  
<mrcb880 i1="i1-1" i2="i2-0">  
<mrcb880-a>春秋左氏經傳集解序疏證 /</mrcb880-a>  
<mrcb880 i1="i1-blank" i2="i2-blank">  
<mrcb880 i1="i1-blank" i2="i2-blank">  
<mrcb880-a>臺北市 :</mrcb880-a>  
<mrcb880-c>民國80 [1991]</mrcb880-c>  
<mrcb880 i1="i1-0" i2="i2-0">  
<mrcb880 i1="i1-1" i2="i2-0">  
<mrcb880 i1="i1-1" i2="i2-blank">  
<mrcb880 i1="i1-0" i2="i2-2">  
<mrcb948 i1="i1-blank" i2="i2-blank">  

XML Format for Bibliographic Data

<?xml version="1.0" encoding="UTF-8"?> 
  <fd id="1" name="001" ind1=" " ind2=" " label="OCLC #">
      <sf name="">26376377</sf></fd>
  <fd id="2" name="008" ind1=" " ind2=" " label="MARC">
      <sf name="">920811s1991    ch       b    000 0 chi dnamIa </sf></fd>
  <fd id="3" name="020" ind1=" " ind2=" " label="STANDARD #">
      <sf name="a">9571502537 (deluxe ed.)</sf></fd>
  <fd id="4" name="020" ind1=" " ind2=" " label="STANDARD #">
      <sf name="a">9571502545 (pbk.)</sf></fd>
  <fd id="5" name="040" ind1=" " ind2=" " label="MARC">
      <sf name="a">GZM</sf>
      <sf name="c">GZM</sf>
      <sf name="d">HNK</sf></fd>
  <fd id="6" name="049" ind1=" " ind2=" " label="MARC">
      <sf name="a">HNKA</sf></fd>
  <fd id="7" name="090" ind1=" " ind2=" " label="CALL #">
      <sf name="a">PL2470.Z6</sf>
      <sf name="b">C467 1991</sf></fd>
  <fd id="8.1" script="cjk.chinese" name="100" ind1="1" ind2=" " label="AUTHOR">
      <sf name="a">程元敏/sf></fd>
  <fd id="8.2" script="latin.chinese" name="100" ind1="1" ind2=" " label="AUTHOR">
        <sf name="a">Cheng, Yuanmin</sf></fd>
  <fd id="10.1" script="cjk.chinese" name="245" ind1="1" ind2="0" label="TITLE">
      <sf name="a">春秋左氏經傳集解序疏證 /</sf>
      <sf name="c">程元敏著</sf></fd>
  <fd id="10.2" script="latin.chinese" name="245" ind1="1" ind2="0" label="TITLE">
      <sf name="a">Chun qiu Zuo shi jing zhuan ji jie xu shu zheng /</sf>
      <sf name="c">Cheng Yuanmin zhu</sf></fd>
  <fd id="12.1" script="cjk.chinese" name="250" ind1=" " ind2=" " label="EDITION">
      <sf name="a">初版</sf></fd>
  <fd id="12.2" script="latin.chinese" name="250" ind1=" " ind2=" " label="EDITION">
      <sf name="a">Chu ban</sf></fd>
  <fd id="14.1" script="cjk.chinese" name="260" ind1=" " ind2=" " label="IMPRINT">
      <sf name="a">臺北市 :</sf>
      <sf name="b">臺灣學生書局,</sf>
      <sf name="c">民國80 [1991]</sf></fd>
  <fd id="14.2" script="latin.chinese" name="260" ind1=" " ind2=" " label="IMPRINT">
      <sf name="a">Taibei shi :</sf>
      <sf name="b">Taiwan xue sheng shu ju,</sf>
      <sf name="c">Min guo 80 [1991]</sf></fd>
  <fd id="16" name="300" ind1=" " ind2=" " label="COLLATION">
      <sf name="a">112 p. ;</sf>
      <sf name="c">22 cm</sf></fd>
  <fd id="17" name="504" ind1=" " ind2=" " label="NOTE">
      <sf name="a">Includes bibliographical references (p. 109-112)</sf></fd>
  <fd id="18.1" script="cjk.chinese" name="600" ind1="0" ind2="4" label="SUBJECT">
      <sf name="a">孔子.</sf>
      <sf name="t">春秋</sf></fd>
  <fd id="18.2" script="latin.chinese" name="600" ind1="0" ind2="0" label="SUBJECT">
      <sf name="a">Confucius.</sf>
      <sf name="t">Chun qiu</sf></fd>
  <fd id="20.1" script="cjk.chinese" name="600" ind1="2" ind2="0" label="SUBJECT">
      <sf name="a">左丘明.</sf>
      <sf name="t">左傳</sf></fd>
  <fd id="20.2" script="latin.chinese" name="600" ind1="1" ind2="0" label="SUBJECT">
      <sf name="a">Zuoqiu, Ming.</sf>
      <sf name="t">Zuo zhuan</sf></fd>
  <fd id="22.1" script="cjk.chinese" name="700" ind1="2" ind2="2" label="ADD. AUTHOR">
      <sf name="a">左丘明.</sf>
      <sf name="t">左傳.</sf>
      <sf name="f">1991</sf></fd>
  <fd id="22.2" script="latin.chinese" name="700" ind1="1" ind2=" " label="ADD. AUTHOR">
      <sf name="a">Zuoqiu, Ming.</sf>
      <sf name="t">Zuo zhuan.</sf>
      <sf name="f">1991</sf></fd>
  <fd id="24.1" script="cjk.chinese" name="700" ind1="0" ind2="2" label="ADD. AUTHOR">
      <sf name="a">孔子.</sf>
      <sf name="t">春秋.</sf>
      <sf name="f">1991</sf></fd>
  <fd id="24.2" script="latin.chinese" name="700" ind1="0" ind2="2" label="ADD. AUTHOR">
      <sf name="a">Confucius.</sf>
      <sf name="t">Chun qiu.</sf>
      <sf name="f">1991</sf></fd>
  <fd id="26" name="910" ind1=" " ind2=" " label="MARC">
      <sf name="a">tk</sf>
      <sf name="b">hkust</sf>
      <sf name="c">hkust</sf></fd>
  <fd id="27" name="948" ind1="" ind2="" label="MARC">
      <sf name="a">.b212750</sf></fd>

XSL Stylesheet for Displaying MARC Tags

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
  <xsl:template match="/">
        <TITLE>Sample MARC 21 Record - XML to MARC</TITLE>
        <H3>Sample MARC 21 Record converted from XML</H3> 
          <xsl:for-each select="/marc/fd">
              <TD VALIGN="TOP"><SPAN STYLE="color:#0000FF"><xsl:value-of select="@name"/></SPAN></TD>
              <TD VALIGN="TOP">
                  <xsl:when test="@ind1='b'">_</xsl:when>
                  <xsl:otherwise><xsl:value-of select="@ind1"/></xsl:otherwise>
                  <xsl:when test="@ind2='b'">_</xsl:when>
                  <xsl:otherwise><xsl:value-of select="@ind2"/></xsl:otherwise>
              <TD VALIGN="TOP">
                <xsl:for-each select="sf">
                  <xsl:if test="@name!=''">
                    <SPAN STYLE="color:#FF0000">|<xsl:value-of select="@name"/></SPAN>
                    <SPAN STYLE="color:#0000FF"><xsl:value-of select="."/></SPAN>