Network Working Group                                           J. Kunze
Request for Comments: 2731                                   Dublin Core
Category: Informational                              Metadata Initiative
                                                           December 1999
        
Network Working Group                                           J. Kunze
Request for Comments: 2731                                   Dublin Core
Category: Informational                              Metadata Initiative
                                                           December 1999
        

Encoding Dublin Core Metadata in HTML

用HTML编码都柏林核心元数据

Status of this Memo

本备忘录的状况

This memo provides information for the Internet community. It does not specify an Internet standard of any kind. Distribution of this memo is unlimited.

本备忘录为互联网社区提供信息。它没有规定任何类型的互联网标准。本备忘录的分发不受限制。

Copyright Notice

版权公告

Copyright (C) The Internet Society (1999). All Rights Reserved.

版权所有(C)互联网协会(1999年)。版权所有。

1. Abstract
1. 摘要
   The Dublin Core [DC1] is a small set of metadata elements for
   describing information resources.  This document explains how these
   elements are expressed using the META and LINK tags of HTML
   [HTML4.0].  A sequence of metadata elements embedded in an HTML file
   is taken to be a description of that file.  Examples illustrate
   conventions allowing interoperation with current software that
   indexes, displays, and manipulates metadata, such as [SWISH-E],
   [freeWAIS-sf2.0], [GLIMPSE], [HARVEST], [ISEARCH], etc., and the Perl
   [PERL] scripts in the appendix.
        
   The Dublin Core [DC1] is a small set of metadata elements for
   describing information resources.  This document explains how these
   elements are expressed using the META and LINK tags of HTML
   [HTML4.0].  A sequence of metadata elements embedded in an HTML file
   is taken to be a description of that file.  Examples illustrate
   conventions allowing interoperation with current software that
   indexes, displays, and manipulates metadata, such as [SWISH-E],
   [freeWAIS-sf2.0], [GLIMPSE], [HARVEST], [ISEARCH], etc., and the Perl
   [PERL] scripts in the appendix.
        
2. HTML, Dublin Core, and Non-Dublin Core Metadata
2. HTML、都柏林核心和非都柏林核心元数据

The Dublin Core (DC) metadata initiative [DCHOME] has produced a small set of resource description categories [DC1], or elements of metadata (literally, data about data). Metadata elements are typically small relative to the resource they describe and may, if the resource format permits, be embedded in it. Two such formats are the Hypertext Markup Language (HTML) and the Extensible Markup Language (XML); HTML is currently in wide use, but once standardized, XML [XML] in conjunction with the Resource Description Framework [RDF] promise a significantly more expressive means of encoding metadata. The [RDF] specification actually describes a way to use RDF within an HTML document by adhering to an abbreviated syntax.

都柏林核心(DC)元数据倡议[DCHOME]已经产生了一小部分资源描述类别[DC1],或元数据元素(字面上是关于数据的数据)。元数据元素相对于它们所描述的资源通常较小,如果资源格式允许,可以嵌入其中。两种这样的格式是超文本标记语言(HTML)和可扩展标记语言(XML);HTML目前正被广泛使用,但一旦标准化,XML[XML]与资源描述框架[RDF]的结合有望提供一种更具表现力的元数据编码方式。[RDF]规范实际上描述了一种通过遵循缩写语法在HTML文档中使用RDF的方法。

This document explains how to encode metadata using HTML 4.0 [HTML4.0]. It is not concerned with element semantics, which are defined elsewhere. For illustrative purposes, some element semantics are alluded to, but in no way should semantics appearing here be considered definitive.

本文档说明如何使用HTML4.0[HTML4.0]对元数据进行编码。它与元素语义无关,元素语义是在别处定义的。为了便于说明,这里提到了一些元素语义,但这里出现的语义决不能被认为是确定的。

The HTML encoding allows elements of DC metadata to be interspersed with non-DC elements (provided such mixing is consistent with rules governing use of those non-DC elements). A DC element is indicated by the prefix "DC", and a non-DC element by another prefix; for example, the prefix "AC" is used with elements from the A-Core [AC].

HTML编码允许DC元数据的元素与非DC元素穿插在一起(前提是这种混合符合管理这些非DC元素使用的规则)。DC元素由前缀“DC”表示,非DC元素由另一前缀表示;例如,前缀“AC”与A核[AC]中的元素一起使用。

3. The META Tag
3. 元标记

The META tag of HTML is designed to encode a named metadata element. Each element describes a given aspect of a document or other information resource. For example, this tagged metadata element,

HTML的META标记设计用于编码命名的元数据元素。每个元素描述文档或其他信息资源的给定方面。例如,此标记的元数据元素,

       <meta name    = "DC.Creator"
             content = "Simpson, Homer">
        
       <meta name    = "DC.Creator"
             content = "Simpson, Homer">
        

says that Homer Simpson is the Creator, where the element named Creator is defined in the DC element set. In the more general form,

表示荷马·辛普森是创建者,其中名为Creator的元素在DC元素集中定义。以更一般的形式,,

       <meta name    = "PREFIX.ELEMENT_NAME"
             content = "ELEMENT_VALUE">
        
       <meta name    = "PREFIX.ELEMENT_NAME"
             content = "ELEMENT_VALUE">
        

the capitalized words are meant to be replaced in actual descriptions; thus in the example,

大写的词语应在实际描述中替换;因此在这个例子中,

ELEMENT_NAME was: Creator ELEMENT_VALUE was: Simpson, Homer and PREFIX was: DC

元素名称为:创建者元素值为:辛普森,荷马,前缀为:DC

Within a META tag the first letter of a Dublin Core element name is capitalized. DC places no restriction on alphabetic case in an element value and any number of META tagged elements may appear together, in any order. More than one DC element with the same name may appear, and each DC element is optional. The next example is a book description with two authors, two titles, and no other metadata.

在元标记中,都柏林核心元素名称的第一个字母大写。DC对元素值中的字母大小写没有限制,任何数量的元标记元素可以以任何顺序同时出现。可能会出现多个同名的DC元素,每个DC元素都是可选的。下一个例子是一本书的描述,有两位作者,两个书名,没有其他元数据。

       <meta name    = "DC.Title"
             content = "The Communist Manifesto">
       <meta name    = "DC.Creator"
             content = "Marx, K.">
        
       <meta name    = "DC.Title"
             content = "The Communist Manifesto">
       <meta name    = "DC.Creator"
             content = "Marx, K.">
        
       <meta name    = "DC.Creator"
             content = "Engels, F.">
       <meta name    = "DC.Title"
             content = "Capital">
        
       <meta name    = "DC.Creator"
             content = "Engels, F.">
       <meta name    = "DC.Title"
             content = "Capital">
        

The prefix "DC" precedes each Dublin Core element encoded with META, and it is separated by a period (.) from the element name following it. Each non-DC element should be encoded with a prefix that can be used to trace its origin and definition; the linkage between prefix and element definition is made with the LINK tag, as explained in the next section. Non-DC elements, such as Email from the A-Core [AC], may appear together with DC elements, as in

前缀“DC”位于每个用META编码的都柏林核心元素之前,它由一个句点(.)与其后面的元素名称分隔。每个非DC元素应使用前缀进行编码,前缀可用于跟踪其来源和定义;前缀和元素定义之间的链接是通过链接标记实现的,如下一节所述。非DC元素(如A-Core[AC]的电子邮件)可能与DC元素一起出现,如中所示

       <meta name    = "DC.Creator"
             content = "Da Costa, Jos&eacute;">
       <meta name    = "AC.Email"
             content = "dacostaj@peoplesmail.org">
       <meta name    = "DC.Title"
             content = "Jesse &#34;The Body&#34; Ventura--A Biography">
        
       <meta name    = "DC.Creator"
             content = "Da Costa, Jos&eacute;">
       <meta name    = "AC.Email"
             content = "dacostaj@peoplesmail.org">
       <meta name    = "DC.Title"
             content = "Jesse &#34;The Body&#34; Ventura--A Biography">
        

This example also shows how some special characters may be encoded. The author name in the first element contains a diacritic encoded as an HTML character entity reference -- in this case an accented letter E. Similarly, the last line contains two double-quote characters encoded so as to avoid being interpreted as element content delimiters.

此示例还显示了如何对某些特殊字符进行编码。第一个元素中的作者名称包含一个编码为HTML字符实体引用的变音符号——在本例中为重音字母E。同样,最后一行包含两个双引号字符,编码后可避免被解释为元素内容分隔符。

4. The LINK Tag
4. 链接标签

The LINK tag of HTML may be used to associate an element name prefix with the reference definition of the element set that it identifies. A sequence of META tags describing a resource is incomplete without one such LINK tag for each different prefix appearing in the sequence. The previous example could be considered complete with the addition of these two LINK tags:

HTML的LINK标记可用于将元素名称前缀与其标识的元素集的引用定义相关联。描述资源的元标记序列是不完整的,如果序列中每个不同前缀没有一个这样的链接标记。前面的示例可以被认为是添加了这两个链接标签的完整示例:

       <link rel     = "schema.DC"
             href    = "http://purl.org/DC/elements/1.0/">
       <link rel     = "schema.AC"
             href    = "http://metadata.net/ac/2.0/">
        
       <link rel     = "schema.DC"
             href    = "http://purl.org/DC/elements/1.0/">
       <link rel     = "schema.AC"
             href    = "http://metadata.net/ac/2.0/">
        

In general, the association takes the form

一般来说,协会采取以下形式:

       <link rel     = "schema.PREFIX"
             href    = "LOCATION_OF_DEFINITION">
        
       <link rel     = "schema.PREFIX"
             href    = "LOCATION_OF_DEFINITION">
        

where, in actual descriptions, PREFIX is to be replaced by the prefix and LOCATION_OF_DEFINITION by the URL or URN of the defining document. When embedded in the HEAD part of an HTML file, a sequence of LINK and META tags describes the information in the surrounding HTML file itself. Here is a complete HTML file with its own embedded description.

其中,在实际描述中,前缀由前缀替换,位置由定义文档的URL或URN替换。当嵌入到HTML文件的头部时,一系列链接和元标记描述了周围HTML文件本身中的信息。这是一个完整的HTML文件,它有自己的嵌入式描述。

       <html>
       <head>
       <title> A Dirge </title>
       <link rel     = "schema.DC"
             href    = "http://purl.org/DC/elements/1.0/">
       <meta name    = "DC.Title"
             content = "A Dirge">
       <meta name    = "DC.Creator"
             content = "Shelley, Percy Bysshe">
       <meta name    = "DC.Type"
             content = "poem">
       <meta name    = "DC.Date"
             content = "1820">
       <meta name    = "DC.Format"
             content = "text/html">
       <meta name    = "DC.Language"
             content = "en">
       </head>
       <body><pre>
               Rough wind, that moanest loud
                 Grief too sad for song;
               Wild wind, when sullen cloud
                 Knells all the night long;
               Sad storm, whose tears are vain,
               Bare woods, whose branches strain,
               Deep caves and dreary main, -
                 Wail, for the world's wrong!
       </pre></body>
       </html>
        
       <html>
       <head>
       <title> A Dirge </title>
       <link rel     = "schema.DC"
             href    = "http://purl.org/DC/elements/1.0/">
       <meta name    = "DC.Title"
             content = "A Dirge">
       <meta name    = "DC.Creator"
             content = "Shelley, Percy Bysshe">
       <meta name    = "DC.Type"
             content = "poem">
       <meta name    = "DC.Date"
             content = "1820">
       <meta name    = "DC.Format"
             content = "text/html">
       <meta name    = "DC.Language"
             content = "en">
       </head>
       <body><pre>
               Rough wind, that moanest loud
                 Grief too sad for song;
               Wild wind, when sullen cloud
                 Knells all the night long;
               Sad storm, whose tears are vain,
               Bare woods, whose branches strain,
               Deep caves and dreary main, -
                 Wail, for the world's wrong!
       </pre></body>
       </html>
        
5. Encoding Recommendations
5. 编码建议

HTML allows more flexibility in principle and in practice than is recommended here for encoding metadata. Limited flexibility encourages easy development of software for extracting and processing metadata. At this early evolutionary stage of internet metadata, easy prototyping and experimentation hastens the development of useful standards.

HTML在原则上和实践上都比这里推荐的元数据编码更具灵活性。有限的灵活性鼓励轻松开发用于提取和处理元数据的软件。在互联网元数据的早期发展阶段,简单的原型设计和实验加速了有用标准的开发。

Adherence is therefore recommended to the tagging style exemplified in this document as regards prefix and element name capitalization, double-quoting (") of attribute values, and not starting more than one META tag on a line. There is much room for flexibility, but choosing a style and sticking with it will likely make metadata manipulation and editing easier. The following META tags adhere to the recommendations and carry identical metadata in three different styles:

因此,建议遵循本文件中关于前缀和元素名称大写、双引号(“)的标记样式属性值,并且不在一行上启动多个元标记。这有很大的灵活性,但选择一种样式并坚持使用它可能会使元数据操作和编辑更容易。以下元标记遵循建议,并以三种不同的样式携带相同的元数据:

       <META NAME="DC.Format"
             CONTENT="text/html; 12 Kbytes">
       <meta
               Content = "text/html; 12 Kbytes"
               Name = "DC.Format"
       >
       <meta name = "DC.Format" content = "text/html; 12 Kbytes">
        
       <META NAME="DC.Format"
             CONTENT="text/html; 12 Kbytes">
       <meta
               Content = "text/html; 12 Kbytes"
               Name = "DC.Format"
       >
       <meta name = "DC.Format" content = "text/html; 12 Kbytes">
        

Use of these recommendations is known to result in metadata that may be harvested, indexed, and manipulated by popular, freely available software packages such as [SWISH-E], [freeWAIS-sf2.0], [GLIMPSE], [HARVEST], and [ISEARCH], among others. These conventions also work with the metadata processing scripts appearing in the appendix, as well as with most of the [DCPROJECTS] applications referenced from the [DCHOME] site. Software support for the LINK tag and qualifier conventions (see the next section) is not currently widespread.

众所周知,使用这些建议会产生元数据,这些元数据可以由流行的、免费可用的软件包(如[SWISH-E]、[freeWAIS-sf2.0]、[Gliesh]、[HARVEST]和[ISEARCH]等)获取、索引和操作。这些约定也适用于附录中出现的元数据处理脚本,以及从[DCHOME]站点引用的大多数[DCPROJECTS]应用程序。对链接标记和限定符约定(见下一节)的软件支持目前并不普遍。

Ordering of metadata elements is not preserved in general. Writers of software for metadata indexing and display should try to preserve relative ordering among META tagged elements having the same name (e.g., among multiple authors), however, metadata providers and searchers have no guarantee that ordering will be preserved in metadata that passes through unknown systems.

元数据元素的顺序一般不保留。元数据索引和显示软件的编写者应尽量保持具有相同名称的元标记元素之间的相对顺序(例如,在多个编写者之间),但是,元数据提供者和搜索者不能保证顺序将保留在通过未知系统的元数据中。

6. Dublin Core in Real Descriptions
6. 真实描述中的都柏林核心

In actual resource description it is often necessary to qualify Dublin Core elements to add nuances of meaning. While neither the general principles nor the specific semantics of DC qualifiers are within scope of this document, everyday uses of the qualifier syntax are illustrated to lend realism to later examples. Without further explanation, the three ways in which the optional qualifier syntax is currently (subject to change) used to supplement the META tag may be summarized as follows:

在实际的资源描述中,通常需要限定都柏林核心元素,以增加含义的细微差别。虽然DC限定符的一般原则和特定语义都不在本文档的范围内,但为了给后面的示例提供现实性,我们对限定符语法的日常使用进行了说明。在不作进一步解释的情况下,可选限定符语法目前用于补充元标记的三种方式(可能会更改)可以总结如下:

    <meta lang    = "LANGUAGE_OF_METADATA_CONTENT" ... >
        
    <meta lang    = "LANGUAGE_OF_METADATA_CONTENT" ... >
        
    <meta scheme  = "CONTROLLED_FORMAT_OR_VOCABULARY_OF_METADATA" ... >
        
    <meta scheme  = "CONTROLLED_FORMAT_OR_VOCABULARY_OF_METADATA" ... >
        
    <meta name    = "PREFIX.ELEMENT_NAME.SUBELEMENT_NAME" ... >
        
    <meta name    = "PREFIX.ELEMENT_NAME.SUBELEMENT_NAME" ... >
        

Accordingly, a posthumous work in Spanish might be described with

因此,西班牙语的遗作可以用

       <meta name    = "DC.Language"
             scheme  = "rfc1766"
             content = "es">
       <meta name    = "DC.Title"
             lang    = "es"
             content = "La Mesa Verde y la Silla Roja">
       <meta name    = "DC.Title"
             lang    = "en"
             content = "The Green Table and the Red Chair">
       <meta name    = "DC.Date.Created"
             content = "1935">
       <meta name    = "DC.Date.Available"
             content = "1939">
        
       <meta name    = "DC.Language"
             scheme  = "rfc1766"
             content = "es">
       <meta name    = "DC.Title"
             lang    = "es"
             content = "La Mesa Verde y la Silla Roja">
       <meta name    = "DC.Title"
             lang    = "en"
             content = "The Green Table and the Red Chair">
       <meta name    = "DC.Date.Created"
             content = "1935">
       <meta name    = "DC.Date.Available"
             content = "1939">
        

Note that the qualifier syntax and label suffixes (which follow an element name and a period) used in examples in this document merely reflect current trends in the HTML encoding of qualifiers. Use of this syntax and these suffixes is neither a standard nor a recommendation.

请注意,本文示例中使用的限定符语法和标签后缀(在元素名称和句点之后)仅反映限定符HTML编码的当前趋势。使用这种语法和这些后缀既不是标准,也不是建议。

7. Encoding Dublin Core Elements
7. 都柏林核心元素编码

This section consists of very simple Dublin Core encoding examples, arranged by element.

本节包含非常简单的都柏林核心编码示例,按元素排列。

   Title (name given to the resource)
   -----
        
   Title (name given to the resource)
   -----
        
    <meta name    = "DC.Title"
          content = "Polycyclic aromatic hydrocarbon contamination">
        
    <meta name    = "DC.Title"
          content = "Polycyclic aromatic hydrocarbon contamination">
        
    <meta name    = "DC.Title"
          content = "Crime and Punishment">
        
    <meta name    = "DC.Title"
          content = "Crime and Punishment">
        
    <meta name    = "DC.Title"
          content = "Methods of Information in Medicine, Vol 32, No 4">
        
    <meta name    = "DC.Title"
          content = "Methods of Information in Medicine, Vol 32, No 4">
        
    <meta name    = "DC.Title"
          content = "Still life #4 with flowers">
        
    <meta name    = "DC.Title"
          content = "Still life #4 with flowers">
        
    <meta name    = "DC.Title"
          lang    = "de"
          content = "Das Wohltemperierte Klavier, Teil I">
        
    <meta name    = "DC.Title"
          lang    = "de"
          content = "Das Wohltemperierte Klavier, Teil I">
        
   Creator (entity that created the content)
   -------
        
   Creator (entity that created the content)
   -------
        
    <meta name    = "DC.Creator"
          content = "Gogh, Vincent van">
    <meta name    = "DC.Creator"
          content = "van Gogh, Vincent">
        
    <meta name    = "DC.Creator"
          content = "Gogh, Vincent van">
    <meta name    = "DC.Creator"
          content = "van Gogh, Vincent">
        
    <meta name    = "DC.Creator"
          content = "Mao Tse Tung">
    <meta name    = "DC.Creator"
          content = "Mao, Tse Tung">
        
    <meta name    = "DC.Creator"
          content = "Mao Tse Tung">
    <meta name    = "DC.Creator"
          content = "Mao, Tse Tung">
        
    <meta name    = "DC.Creator"
          content = "Plato">
    <meta name    = "DC.Creator"
          lang    = "fr"
          content = "Platon">
        
    <meta name    = "DC.Creator"
          content = "Plato">
    <meta name    = "DC.Creator"
          lang    = "fr"
          content = "Platon">
        
    <meta name    = "DC.Creator.Director"
          content = "Sturges, Preston">
    <meta name    = "DC.Creator.Writer"
          content = "Hecht, Ben">
    <meta name    = "DC.Creator.Producer"
          content = "Chaplin, Charles">
        
    <meta name    = "DC.Creator.Director"
          content = "Sturges, Preston">
    <meta name    = "DC.Creator.Writer"
          content = "Hecht, Ben">
    <meta name    = "DC.Creator.Producer"
          content = "Chaplin, Charles">
        
   Subject (topic or keyword)
   -------
        
   Subject (topic or keyword)
   -------
        
    <meta name    = "DC.Subject"
          content = "heart attack">
    <meta name    = "DC.Subject"
          scheme  = "MESH"
          content = "Myocardial Infarction; Pericardial Effusion">
        
    <meta name    = "DC.Subject"
          content = "heart attack">
    <meta name    = "DC.Subject"
          scheme  = "MESH"
          content = "Myocardial Infarction; Pericardial Effusion">
        
    <meta name    = "DC.Subject"
          content = "vietnam war">
    <meta name    = "DC.Subject"
          scheme  = "LCSH"
          content = "Vietnamese Conflict, 1961-1975">
        
    <meta name    = "DC.Subject"
          content = "vietnam war">
    <meta name    = "DC.Subject"
          scheme  = "LCSH"
          content = "Vietnamese Conflict, 1961-1975">
        
    <meta name    = "DC.Subject"
          content = "Friendship">
    <meta name    = "DC.Subject"
          scheme  = "ddc"
          content = "158.25">
        
    <meta name    = "DC.Subject"
          content = "Friendship">
    <meta name    = "DC.Subject"
          scheme  = "ddc"
          content = "158.25">
        
   Description (account, summary, or abstract of the content)
   -----------
        
   Description (account, summary, or abstract of the content)
   -----------
        
    <meta name    = "DC.Description"
          lang    = "en"
          content = "The Author gives some Account of Himself and Family
                     -- His First Inducements to Travel -- He is
                     Shipwrecked, and Swims for his Life -- Gets safe on
                     Shore in the Country of Lilliput -- Is made a
                     Prisoner, and carried up the Country">
        
    <meta name    = "DC.Description"
          lang    = "en"
          content = "The Author gives some Account of Himself and Family
                     -- His First Inducements to Travel -- He is
                     Shipwrecked, and Swims for his Life -- Gets safe on
                     Shore in the Country of Lilliput -- Is made a
                     Prisoner, and carried up the Country">
        
    <meta name    = "DC.Description"
          content = "A tutorial and reference manual for Java.">
        
    <meta name    = "DC.Description"
          content = "A tutorial and reference manual for Java.">
        

<meta name = "DC.Description" content = "Seated family of five, coconut trees to the left, sailboats moored off sandy beach to the right, with volcano in the background.">

<meta name=“DC.Description”content=“坐着的五口之家,左边是椰树,右边是停泊在沙滩上的帆船,背景是火山。”>

   Publisher (entity that made the resource available)
   ---------
        
   Publisher (entity that made the resource available)
   ---------
        
    <meta name    = "DC.Publisher"
          content = "O'Reilly">
        
    <meta name    = "DC.Publisher"
          content = "O'Reilly">
        
    <meta name    = "DC.Publisher"
          content = "Digital Equipment Corporation">
        
    <meta name    = "DC.Publisher"
          content = "Digital Equipment Corporation">
        
    <meta name    = "DC.Publisher"
          content = "University of California Press">
        
    <meta name    = "DC.Publisher"
          content = "University of California Press">
        
    <meta name    = "DC.Publisher"
          content = "State of Florida (USA)">
        
    <meta name    = "DC.Publisher"
          content = "State of Florida (USA)">
        
   Contributor (other entity that made a contribution)
   -----------
        
   Contributor (other entity that made a contribution)
   -----------
        
    <meta name    = "DC.Contributor"
          content = "Curie, Marie">
        
    <meta name    = "DC.Contributor"
          content = "Curie, Marie">
        
    <meta name    = "DC.Contributor.Photographer"
          content = "Adams, Ansel">
    <meta name    = "DC.Contributor.Artist"
          content = "Sendak, Maurice">
    <meta name    = "DC.Contributor.Editor"
          content = "Starr, Kenneth">
        
    <meta name    = "DC.Contributor.Photographer"
          content = "Adams, Ansel">
    <meta name    = "DC.Contributor.Artist"
          content = "Sendak, Maurice">
    <meta name    = "DC.Contributor.Editor"
          content = "Starr, Kenneth">
        
   Date (of an event in the life of the resource; [WTN8601] recommended)
   ----
        
   Date (of an event in the life of the resource; [WTN8601] recommended)
   ----
        
    <meta name    = "DC.Date"
          content = "1972">
        
    <meta name    = "DC.Date"
          content = "1972">
        
    <meta name    = "DC.Date"
          content = "1998-05-14">
    <meta name    = "DC.Date"
          scheme  = "WTN8601"
          content = "1998-05-14">
        
    <meta name    = "DC.Date"
          content = "1998-05-14">
    <meta name    = "DC.Date"
          scheme  = "WTN8601"
          content = "1998-05-14">
        
    <meta name    = "DC.Date.Created"
          content = "1998-05-14">
    <meta name    = "DC.Date.Available"
          content = "1998-05-21">
    <meta name    = "DC.Date.Valid"
          content = "1998-05-28">
        
    <meta name    = "DC.Date.Created"
          content = "1998-05-14">
    <meta name    = "DC.Date.Available"
          content = "1998-05-21">
    <meta name    = "DC.Date.Valid"
          content = "1998-05-28">
        
    <meta name    = "DC.Date.Created"
          content = "triassic">
    <meta name    = "DC.Date.Acquired"
          content = "1957">
        
    <meta name    = "DC.Date.Created"
          content = "triassic">
    <meta name    = "DC.Date.Acquired"
          content = "1957">
        
    <meta name    = "DC.Date.Accepted"
          scheme  = "WTN8601"
          content = "1998-12-02T16:59">
        
    <meta name    = "DC.Date.Accepted"
          scheme  = "WTN8601"
          content = "1998-12-02T16:59">
        
    <meta name    = "DC.Date.DataGathered"
          scheme  = "ISO8601"
          content = "98-W49-3T1659">
        
    <meta name    = "DC.Date.DataGathered"
          scheme  = "ISO8601"
          content = "98-W49-3T1659">
        
    <meta name    = "DC.Date.Issued"
          scheme  = "ANSI.X3.X30-1985"
          content = "19980514">
        
    <meta name    = "DC.Date.Issued"
          scheme  = "ANSI.X3.X30-1985"
          content = "19980514">
        
   Type (nature, genre, or category; [DCT1] recommended)
   ----
        
   Type (nature, genre, or category; [DCT1] recommended)
   ----
        
    <meta name    = "DC.Type"
          content = "poem">
        
    <meta name    = "DC.Type"
          content = "poem">
        
    <meta name    = "DC.Type"
          scheme  = "DCT1"
          content = "software">
    <meta name    = "DC.Type"
          content = "software program source code">
        
    <meta name    = "DC.Type"
          scheme  = "DCT1"
          content = "software">
    <meta name    = "DC.Type"
          content = "software program source code">
        
    <meta name    = "DC.Type"
          content = "interactive video game">
        
    <meta name    = "DC.Type"
          content = "interactive video game">
        
    <meta name    = "DC.Type"
          scheme  = "DCT1"
          content = "dataset">
        
    <meta name    = "DC.Type"
          scheme  = "DCT1"
          content = "dataset">
        
    <meta name    = "DC.Type"
          content = "web home page">
    <meta name    = "DC.Type"
          content = "web bibliography">
        
    <meta name    = "DC.Type"
          content = "web home page">
    <meta name    = "DC.Type"
          content = "web bibliography">
        
    <meta name    = "DC.Type"
          content = "painting">
    <meta name    = "DC.Type"
          content = "image; woodblock">
    <meta name    = "DC.Type"
          scheme  = "AAT"
          content = "clipeus (portrait)">
    <meta name    = "DC.Type"
          lang    = "en-US"
          content = "image; advertizement">
        
    <meta name    = "DC.Type"
          content = "painting">
    <meta name    = "DC.Type"
          content = "image; woodblock">
    <meta name    = "DC.Type"
          scheme  = "AAT"
          content = "clipeus (portrait)">
    <meta name    = "DC.Type"
          lang    = "en-US"
          content = "image; advertizement">
        
    <meta name    = "DC.Type"
          scheme  = "DCT1"
          content = "event">
    <meta name    = "DC.Type"
          content = "event; periodic">
        
    <meta name    = "DC.Type"
          scheme  = "DCT1"
          content = "event">
    <meta name    = "DC.Type"
          content = "event; periodic">
        
   Format (physical or digital data format, plus optional dimensions)
   ------
        
   Format (physical or digital data format, plus optional dimensions)
   ------
        
    <meta name    = "DC.Format"
          content = "text/xml">
    <meta name    = "DC.Format"
          scheme  = "IMT"
          content = "text/xml">
        
    <meta name    = "DC.Format"
          content = "text/xml">
    <meta name    = "DC.Format"
          scheme  = "IMT"
          content = "text/xml">
        
    <meta name    = "DC.Format"
          scheme  = "IMT"
          content = "image/jpeg">
    <meta name    = "DC.Format"
          content = "A text file with mono-spaced tables and diagrams.">
        
    <meta name    = "DC.Format"
          scheme  = "IMT"
          content = "image/jpeg">
    <meta name    = "DC.Format"
          content = "A text file with mono-spaced tables and diagrams.">
        
    <meta name    = "DC.Format"
          content = "video/mpeg; 14 minutes">
        
    <meta name    = "DC.Format"
          content = "video/mpeg; 14 minutes">
        
    <meta name    = "DC.Format"
          content = "unix tar archive, gzip compressed; 1.5 Mbytes">
        
    <meta name    = "DC.Format"
          content = "unix tar archive, gzip compressed; 1.5 Mbytes">
        
    <meta name    = "DC.Format"
          content = "watercolor; 23 cm x 31 cm">
        
    <meta name    = "DC.Format"
          content = "watercolor; 23 cm x 31 cm">
        
   Identifier (of the resource)
   ----------
        
   Identifier (of the resource)
   ----------
        
    <meta name    = "DC.Identifier"
          content = "http://foo.bar.org/zaf/">
        
    <meta name    = "DC.Identifier"
          content = "http://foo.bar.org/zaf/">
        
    <meta name    = "DC.Identifier"
          content = "urn:ietf:rfc:1766">
        
    <meta name    = "DC.Identifier"
          content = "urn:ietf:rfc:1766">
        
    <meta name    = "DC.Identifier"
          scheme  = "ISBN"
          content = "1-56592-149-6">
        
    <meta name    = "DC.Identifier"
          scheme  = "ISBN"
          content = "1-56592-149-6">
        
    <meta name    = "DC.Identifier"
          scheme  = "LCCN"
          content = "67-26020">
        
    <meta name    = "DC.Identifier"
          scheme  = "LCCN"
          content = "67-26020">
        
    <meta name    = "DC.Identifier"
          scheme  = "DOI"
          content = "10.12345/33-824688ab">
        
    <meta name    = "DC.Identifier"
          scheme  = "DOI"
          content = "10.12345/33-824688ab">
        
   Source (reference to the resource's origin)
   ------
        
   Source (reference to the resource's origin)
   ------
        
    <meta name    = "DC.Source"
          content = "Shakespeare's Romeo and Juliet">
        
    <meta name    = "DC.Source"
          content = "Shakespeare's Romeo and Juliet">
        
    <meta name    = "DC.Source"
          content = "http://a.b.org/manon/">
        
    <meta name    = "DC.Source"
          content = "http://a.b.org/manon/">
        
   Language (of the content of the resource; [RFC1766] recommended)
   --------
        
   Language (of the content of the resource; [RFC1766] recommended)
   --------
        
    <meta name    = "DC.Language"
          content = "en">
    <meta name    = "DC.Language"
          scheme  = "rfc1766"
          content = "en">
    <meta name    = "DC.Language"
          scheme  = "ISO639-2"
          content = "eng">
        
    <meta name    = "DC.Language"
          content = "en">
    <meta name    = "DC.Language"
          scheme  = "rfc1766"
          content = "en">
    <meta name    = "DC.Language"
          scheme  = "ISO639-2"
          content = "eng">
        
    <meta name    = "DC.Language"
          scheme  = "rfc1766"
          content = "en-US">
        
    <meta name    = "DC.Language"
          scheme  = "rfc1766"
          content = "en-US">
        
    <meta name    = "DC.Language"
          content = "zh">
    <meta name    = "DC.Language"
          content = "ja">
    <meta name    = "DC.Language"
          content = "es">
    <meta name    = "DC.Language"
          content = "de">
        
    <meta name    = "DC.Language"
          content = "zh">
    <meta name    = "DC.Language"
          content = "ja">
    <meta name    = "DC.Language"
          content = "es">
    <meta name    = "DC.Language"
          content = "de">
        
    <meta name    = "DC.Language"
          content = "german">
    <meta name    = "DC.Language"
          lang    = "fr"
          content = "allemand">
        
    <meta name    = "DC.Language"
          content = "german">
    <meta name    = "DC.Language"
          lang    = "fr"
          content = "allemand">
        
   Relation (reference to a related resource)
   --------
        
   Relation (reference to a related resource)
   --------
        
    <meta name    = "DC.Relation.IsPartOf"
          content = "http://foo.bar.org/abc/proceedings/1998/">
        
    <meta name    = "DC.Relation.IsPartOf"
          content = "http://foo.bar.org/abc/proceedings/1998/">
        
    <meta name    = "DC.Relation.IsFormatOf"
          content = "http://foo.bar.org/cd145.sgml">
        
    <meta name    = "DC.Relation.IsFormatOf"
          content = "http://foo.bar.org/cd145.sgml">
        
    <meta name    = "DC.Relation.IsVersionOf"
          content = "http://foo.bar.org/draft9.4.4.2">
        
    <meta name    = "DC.Relation.IsVersionOf"
          content = "http://foo.bar.org/draft9.4.4.2">
        
    <meta name    = "DC.Relation.References"
          content = "urn:isbn:1-56592-149-6">
        
    <meta name    = "DC.Relation.References"
          content = "urn:isbn:1-56592-149-6">
        
    <meta name    = "DC.Relation.IsBasedOn"
          content = "Shakespeare's Romeo and Juliet">
        
    <meta name    = "DC.Relation.IsBasedOn"
          content = "Shakespeare's Romeo and Juliet">
        
    <meta name    = "DC.Relation.Requires"
          content = "LWP::UserAgent; HTML::Parse; URI::URL;
                     Net::DNS; Tk::Pixmap; Tk::Bitmap; Tk::Photo">
        
    <meta name    = "DC.Relation.Requires"
          content = "LWP::UserAgent; HTML::Parse; URI::URL;
                     Net::DNS; Tk::Pixmap; Tk::Bitmap; Tk::Photo">
        
   Coverage (extent or scope of the content)
   --------
        
   Coverage (extent or scope of the content)
   --------
        
    <meta name    = "DC.Coverage"
          content = "US civil war era; 1861-1865">
        
    <meta name    = "DC.Coverage"
          content = "US civil war era; 1861-1865">
        
    <meta name    = "DC.Coverage"
          content = "Columbus, Ohio, USA; Lat: 39 57 N Long: 082 59 W">
        
    <meta name    = "DC.Coverage"
          content = "Columbus, Ohio, USA; Lat: 39 57 N Long: 082 59 W">
        
    <meta name    = "DC.Coverage"
          scheme  = "TGN"
          content = "Columbus (C,V)">
        
    <meta name    = "DC.Coverage"
          scheme  = "TGN"
          content = "Columbus (C,V)">
        
    <meta name    = "DC.Coverage.Jurisdiction"
          content = "Commonwealth of Australia">
        
    <meta name    = "DC.Coverage.Jurisdiction"
          content = "Commonwealth of Australia">
        
   Rights (text or identifier of a rights management statement)
   ------
        
   Rights (text or identifier of a rights management statement)
   ------
        
    <meta name    = "DC.Rights"
          lang    = "en"
          content = "Copyright Acme 1999 - All rights reserved.">
        
    <meta name    = "DC.Rights"
          lang    = "en"
          content = "Copyright Acme 1999 - All rights reserved.">
        
    <meta name    = "DC.Rights"
          content = "http://foo.bar.org/cgi-bin/terms">
        
    <meta name    = "DC.Rights"
          content = "http://foo.bar.org/cgi-bin/terms">
        
8. Security Considerations
8. 安全考虑

The syntax rules for encoding Dublin Core metadata in HTML that are documented here pose no direct risk to computers and networks. People can use these rules to encode metadata that is inaccurate or even deliberately misleading (creating mischief in the form of "index spam"), however, this reflects a general pattern of HTML META tag abuse that is not limited to the encoding of metadata from the Dublin Core set. Even traditional metadata encoding schemes (e.g., [MARC]) are not immune to inaccuracy, although they are generally followed in environments where production quality greatly exceeds that of the average Web site.

本文中记录的用HTML编码都柏林核心元数据的语法规则对计算机和网络没有直接风险。人们可以使用这些规则对不准确甚至故意误导的元数据进行编码(以“索引垃圾邮件”的形式制造恶作剧),但是,这反映了HTML元标记滥用的一般模式,不限于对都柏林核心集的元数据进行编码。即使是传统的元数据编码方案(如[MARC])也无法避免不准确,尽管在生产质量大大超过一般网站的环境中,通常都会遵循这些方案。

Systems that process metadata encoded with META tags need to consider issues related to its accuracy and validity as part of their design and implementation, and users of such systems need to consider the design and implementation assumptions. Various approaches may be relevant for certain applications, such as adding statements of metadata provenance, signing of metadata with digital signatures, and automating certain aspects of metadata creation; but these are far outside the scope of this document and the underlying META tag syntax that it describes.

处理元标签编码的元数据的系统需要考虑与其准确性和有效性相关的问题作为它们的设计和实现的一部分,并且这样的系统的用户需要考虑设计和实现假设。各种方法可能与某些应用程序相关,例如添加元数据来源声明、使用数字签名对元数据进行签名,以及自动化元数据创建的某些方面;但这些都远远超出了本文档及其描述的底层元标记语法的范围。

9. Appendix -- Perl Scripts that Manipulate HTML Encoded Metadata
9. 附录——操纵HTML编码元数据的Perl脚本

This section contains two simple programs that work with versions 4 and 5 of the Perl [PERL] scripting language interpreter. They may be taken and freely adapted for local organizational needs, research proposals, venture capital bids, etc. A variety of applications are within easy reach of implementors that choose to build on these scripts.

本节包含两个使用Perl[Perl]脚本语言解释器版本4和版本5的简单程序。它们可以根据当地的组织需求、研究建议、风险投资投标等进行自由调整。选择基于这些脚本构建的实现者可以轻松获得各种应用程序。

   Script 1:  Metadata Format Conversion
   -------------------------------------
        
   Script 1:  Metadata Format Conversion
   -------------------------------------
        

Here is a simple Perl script that correctly recognizes every example of metadata encoding in this document. It shows how a modest scripting effort can produce a utility that converts metadata from one format to another. Minor changes are sufficient to support a number of output formats.

下面是一个简单的Perl脚本,可以正确识别本文档中的每个元数据编码示例。它展示了一个适度的脚本编写工作如何生成一个实用程序,将元数据从一种格式转换为另一种格式。微小的更改足以支持多种输出格式。

#!/depot/bin/perl # # This simple perl script extracts metadata embedded in an HTML file # and outputs it in an alternate format. Issues warning about missing # element name or value. # # Handles mixed case tags and attribute values, one per line or spanning # several lines. Also handles a quoted string spanning multiple lines. # No error checking. Does not tolerate more than one "<meta" per line.

#!/depot/bin/perl####这个简单的perl脚本提取HTML文件中嵌入的元数据#,并以另一种格式输出。发出有关缺少#元素名称或值的警告。##处理混合大小写标记和属性值,每行一个或跨越几行。还处理跨多行的带引号的字符串无错误检查。每行不允许超过一个“<meta”。

print "@(urc;\n";
while (<>) {
        next if (! /<meta/i);
        ($meta) = /(<meta.*$)/i;
        if (! /<meta.*>/i) {
                while (<>) {
                        $meta .= $_;
                        last if (/>/);
                }
        }
        $name     =    $meta =~ /name\s*=\s*"([^"]*)"/i
                        ? $1 : "MISSING ELEMENT NAME";
        $content  = $meta =~ /content\s*=\s*"([^"]*)"/i
                        ? $1 : "MISSING ELEMENT VALUE";
        ($scheme) =  $meta =~ /scheme\s*=\s*"([^"]*)"/i;
        ($lang)   =    $meta =~ /lang\s*=\s*"([^"]*)"/i;
        
print "@(urc;\n";
while (<>) {
        next if (! /<meta/i);
        ($meta) = /(<meta.*$)/i;
        if (! /<meta.*>/i) {
                while (<>) {
                        $meta .= $_;
                        last if (/>/);
                }
        }
        $name     =    $meta =~ /name\s*=\s*"([^"]*)"/i
                        ? $1 : "MISSING ELEMENT NAME";
        $content  = $meta =~ /content\s*=\s*"([^"]*)"/i
                        ? $1 : "MISSING ELEMENT VALUE";
        ($scheme) =  $meta =~ /scheme\s*=\s*"([^"]*)"/i;
        ($lang)   =    $meta =~ /lang\s*=\s*"([^"]*)"/i;
        
        if ($lang || $scheme) {
                $mod = " ($lang";
                if (! $scheme)
        
        if ($lang || $scheme) {
                $mod = " ($lang";
                if (! $scheme)
        
                        { $mod .= ")"; }
                elsif (! $lang)
                        { $mod .= "$scheme)" }
                else
                        { $mod .= ", $scheme)"; }
        }
        else
                { $mod = ""; }
        
                        { $mod .= ")"; }
                elsif (! $lang)
                        { $mod .= "$scheme)" }
                else
                        { $mod .= ", $scheme)"; }
        }
        else
                { $mod = ""; }
        
        print "    @|$name$mod; $content\n";
}
print "@)urc;\n";
# ---- end of Perl script ----
        
        print "    @|$name$mod; $content\n";
}
print "@)urc;\n";
# ---- end of Perl script ----
        

When the conversion script is run on the metadata file example from the LINK tag section (section 4), it produces the following output.

在链接标记部分(第4部分)的元数据文件示例上运行转换脚本时,它将生成以下输出。

        @(urc;
            @|DC.Title; A Dirge
            @|DC.Creator; Shelley, Percy Bysshe
            @|DC.Type; poem
            @|DC.Date; 1820
            @|DC.Format; text/html
            @|DC.Language; en
        @)urc;
        
        @(urc;
            @|DC.Title; A Dirge
            @|DC.Creator; Shelley, Percy Bysshe
            @|DC.Type; poem
            @|DC.Date; 1820
            @|DC.Format; text/html
            @|DC.Language; en
        @)urc;
        
   Script 2:  Automated Metadata Creation
   --------------------------------------
        
   Script 2:  Automated Metadata Creation
   --------------------------------------
        

The creation and maintenance of high-quality metadata can be extremely expensive without automation to assist in processes such as supplying pre-set or computed defaults, validating syntax, verifying value ranges, spell checking, etc. Considerable relief could be had from a script that reduced an individual provider's metadata burden to just the title of each document. Below is such a script. It lets the provider of an HTML document abbreviate an entire embedded resource description using a single HTML comment statement that looks like

高质量元数据的创建和维护可能非常昂贵,如果没有自动化来帮助提供预设或计算的默认值、验证语法、验证值范围、拼写检查、,脚本将单个提供者的元数据负担减少到每个文档的标题,这可以大大减轻负担。下面就是这样一个脚本。它允许HTML文档的提供者使用单个HTML注释语句缩写整个嵌入式资源描述

       <!--metablock Little Red Riding Hood -->
        
       <!--metablock Little Red Riding Hood -->
        

Our script processes this statement specially as a kind of "metadata block" declaration with attached title. The general form is

我们的脚本将此语句作为一种带有附加标题的“元数据块”声明进行特殊处理。一般形式是

       <!--metablock TITLE_OF_DOCUMENT -->
        
       <!--metablock TITLE_OF_DOCUMENT -->
        

This statement works much like a "Web server-side include" in that the script replaces it with a fully-specified block of metadata and triggers other replacements. Once installed, the script can output HTML files suitable for integration into one's production Web server procedures.

此语句的工作原理非常类似于“Web服务器端包含”,因为脚本使用完全指定的元数据块替换它,并触发其他替换。一旦安装,脚本可以输出适合集成到生产Web服务器过程中的HTML文件。

The individual provider keeps a separate "template" file of infrequently changing pre-set values for metadata elements. If the provider's needs are simple enough, the only element values besides the title that differ from one document to the next may be generated automatically. Using the script, values may be referenced as variables from within the template or within the document. Our variable references have the form "(--mbVARNAME)", and here is what they look like inside a template:

单个提供者保留一个单独的“模板”文件,其中包含元数据元素的不经常更改的预设值。如果提供者的需求足够简单,那么除了标题之外,每个文档之间唯一不同的元素值可能会自动生成。使用脚本,值可以作为模板或文档中的变量引用。我们的变量引用的形式为“(-mbVARNAME)”,下面是它们在模板中的外观:

       <title> (--mbtitle) </title>
       <meta name    = "DC.Creator"
             content = "Simpson, Homer">
       <meta name    = "DC.Title"
             content = "(--mbtitle)">
       <meta name    = "DC.Date.Created"
             content = "(--mbfilemodtime)">
       <meta name    = "DC.Identifier"
             content = "(--mbbaseURL)/(--mbfilename)">
       <meta name    = "DC.Format"
             content = "text/html; (--mbfilesize)">
       <meta name    = "DC.Language"
             content = "(--mblanguage)-BUREAUCRATESE">
       <meta name    = "RC.MetadataAuthority"
             content = "Springfield Nuclear">
       <link rel     = "schema.DC"
             href    = "http://purl.org/DC/elements/1.0/">
       <link rel     = "schema.RC"
             href    = "http://nukes.org/ReactorCore/rc">
        
       <title> (--mbtitle) </title>
       <meta name    = "DC.Creator"
             content = "Simpson, Homer">
       <meta name    = "DC.Title"
             content = "(--mbtitle)">
       <meta name    = "DC.Date.Created"
             content = "(--mbfilemodtime)">
       <meta name    = "DC.Identifier"
             content = "(--mbbaseURL)/(--mbfilename)">
       <meta name    = "DC.Format"
             content = "text/html; (--mbfilesize)">
       <meta name    = "DC.Language"
             content = "(--mblanguage)-BUREAUCRATESE">
       <meta name    = "RC.MetadataAuthority"
             content = "Springfield Nuclear">
       <link rel     = "schema.DC"
             href    = "http://purl.org/DC/elements/1.0/">
       <link rel     = "schema.RC"
             href    = "http://nukes.org/ReactorCore/rc">
        

The above template represents the metadata block that will describe the document once the variable references are replaced with real values. By the conventions of our script, the following variables will be replaced in both the template and in the document:

上面的模板表示元数据块,一旦变量引用被实际值替换,该元数据块将描述文档。按照脚本的约定,模板和文档中的以下变量都将被替换:

(--mbfilesize) size of the final output file (--mbtitle) title of the document (--mblanguage) language of the document (--mbbaseURL) beginning part of document identifier (--mbfilename) last part (minus .html) of identifier (--mbfilemodtime) last modification date of the document

(-mbfilesize)最终输出文件的大小(--mbtitle)文档的标题(--mblanguage)文档的语言(--mbbaseURL)文档标识符的开始部分(--mbfilename)标识符的最后部分(减.html)(-mbfilemodtime)文档的最后修改日期

Here's an example HTML file to run the script on.

下面是一个运行脚本的示例HTML文件。

       <html>
       <head>
       <!--metablock Nutritional Allocation Increase -->
       <meta name    = "DC.Type"
             content = "Memorandum">
       </head>
       <body>
       <p>
       From:  Acting Shift Supervisor
       To:    Plant Control Personnel
       RE:    (--mbtitle)
       Date:  (--mbfilemodtime)
       <p>
       Pursuant to directive DOH:10.2001/405aec of article B-2022,
       subsection 48.2.4.4.1c regarding staff morale and employee
       productivity standards, the current allocation of doughnut
       acquisition funds shall be increased effective immediately.
       </body>
       </html>
        
       <html>
       <head>
       <!--metablock Nutritional Allocation Increase -->
       <meta name    = "DC.Type"
             content = "Memorandum">
       </head>
       <body>
       <p>
       From:  Acting Shift Supervisor
       To:    Plant Control Personnel
       RE:    (--mbtitle)
       Date:  (--mbfilemodtime)
       <p>
       Pursuant to directive DOH:10.2001/405aec of article B-2022,
       subsection 48.2.4.4.1c regarding staff morale and employee
       productivity standards, the current allocation of doughnut
       acquisition funds shall be increased effective immediately.
       </body>
       </html>
        

Note that because replacement occurs throughout the document, the provider need only enter the title once instead of twice (normally the title must be entered once in the HTML head and again in the HTML body). After running the script, the above file is transformed into this:

请注意,由于替换在整个文档中进行,因此提供程序只需输入一次标题,而不是两次(通常,标题必须在HTML标题中输入一次,然后在HTML正文中输入一次)。运行脚本后,上述文件将转换为:

       <html>
       <head>
           <title> Nutritional Allocation Increase </title>
       <meta name    = "DC.Creator"
             content = "Simpson, Homer">
       <meta name    = "DC.Title"
             content = "Nutritional Allocation Increase">
       <meta name    = "DC.Date.Created"
             content = "1999-03-08">
       <meta name    = "DC.Identifier"
             content = "http://moes.bar.com/doh/homer.html">
       <meta name    = "DC.Format"
             content = "text/html;    1320  bytes">
       <meta name    = "DC.Language"
             content = "en-BUREAUCRATESE">
       <meta name    = "RC.MetadataAuthority"
             content = "Springfield Nuclear">
       <link rel     = "schema.DC"
             href    = "http://purl.org/DC/elements/1.0/">
       <link rel     = "schema.RC"
        
       <html>
       <head>
           <title> Nutritional Allocation Increase </title>
       <meta name    = "DC.Creator"
             content = "Simpson, Homer">
       <meta name    = "DC.Title"
             content = "Nutritional Allocation Increase">
       <meta name    = "DC.Date.Created"
             content = "1999-03-08">
       <meta name    = "DC.Identifier"
             content = "http://moes.bar.com/doh/homer.html">
       <meta name    = "DC.Format"
             content = "text/html;    1320  bytes">
       <meta name    = "DC.Language"
             content = "en-BUREAUCRATESE">
       <meta name    = "RC.MetadataAuthority"
             content = "Springfield Nuclear">
       <link rel     = "schema.DC"
             href    = "http://purl.org/DC/elements/1.0/">
       <link rel     = "schema.RC"
        
             href    = "http://nukes.org/ReactorCore/rc">
       <meta name    = "DC.Type"
             content = "Memorandum">
       </head>
       <body>
       <p>
       From:  Acting Shift Supervisor
       To:    Plant Control Personnel
       RE:    Nutritional Allocation Increase
       Date:  1999-03-08
       <p>
       Pursuant to directive DOH:10.2001/405aec of article B-2022,
       subsection 48.2.4.4.1c regarding staff morale and employee
       productivity standards, the current allocation of doughnut
       acquisition funds shall be increased effective immediately.
       </body>
       </html>
        
             href    = "http://nukes.org/ReactorCore/rc">
       <meta name    = "DC.Type"
             content = "Memorandum">
       </head>
       <body>
       <p>
       From:  Acting Shift Supervisor
       To:    Plant Control Personnel
       RE:    Nutritional Allocation Increase
       Date:  1999-03-08
       <p>
       Pursuant to directive DOH:10.2001/405aec of article B-2022,
       subsection 48.2.4.4.1c regarding staff morale and employee
       productivity standards, the current allocation of doughnut
       acquisition funds shall be increased effective immediately.
       </body>
       </html>
        

Here is the script that accomplishes this transformation.

下面是完成此转换的脚本。

#!/depot/bin/perl # # This Perl script processes metadata block declarations of the form # <!--metablock TITLE_OF_DOCUMENT --> and variable references of the # form (--mbVARNAME), replacing them with full metadata blocks and # variable values, respectively. Requires a "template" file. # Outputs an HTML file. # # Invoke this script with a single filename argument, "foo". It creates # an output file "foo.html" using a temporary working file "foo.work". # The size of foo.work is measured after variable replacement, and is # later inserted into the file in such a way that the file's size does # not change in the process. Has little or no error checking.

#!/depot/bin/perl###这个perl脚本处理#<形式的元数据块声明--_DOCUMENT-->的元块TITLE_和#form(-mbVARNAME)的变量引用,分别用完整元数据块和#变量值替换它们。需要一个“模板”文件输出一个HTML文件使用单个文件名参数“foo”调用此脚本。它使用临时工作文件“foo.work”创建一个输出文件“foo.html”foo.work的大小是在变量替换后测量的,然后插入到文件中,这样文件的大小在过程中不会改变。很少或没有错误检查。

$infile = shift;
open(IN, "< $infile")
        or die("Could not open input file \"$infile\"");
$workfile = "$infile.work";
unlink($workfile);
open(WORK, "+> $workfile")
        or die("Could not open work file \"$workfile\"");
        
$infile = shift;
open(IN, "< $infile")
        or die("Could not open input file \"$infile\"");
$workfile = "$infile.work";
unlink($workfile);
open(WORK, "+> $workfile")
        or die("Could not open work file \"$workfile\"");
        
@offsets = ();          # records locations for late size replacement
$title = "";            # gets the title during metablock processing
$language = "en";       # pre-set language here (not in the template)
$baseURL = "http://moes.bar.com/doh";   # pre-set base URL here also
$filename = "$infile.html";             # final output filename
$filesize = "(--mbfilesize)";           # replaced late (separate pass)
        
@offsets = ();          # records locations for late size replacement
$title = "";            # gets the title during metablock processing
$language = "en";       # pre-set language here (not in the template)
$baseURL = "http://moes.bar.com/doh";   # pre-set base URL here also
$filename = "$infile.html";             # final output filename
$filesize = "(--mbfilesize)";           # replaced late (separate pass)
        
($year, $month, $day) = (localtime( (stat IN) [9] ))[5, 4, 3];
$filemodtime = sprintf "%s-%02s-%02s", 1900 + $year, 1 + $month, $day;
        
($year, $month, $day) = (localtime( (stat IN) [9] ))[5, 4, 3];
$filemodtime = sprintf "%s-%02s-%02s", 1900 + $year, 1 + $month, $day;
        
sub putout {            # outputs current line with variable replacement
        if (! /\(--mb/) {
                print WORK;
                return;
        }
        if (/\(--mbfilesize\)/)                 # remember where it was
                { push @offsets, tell WORK; }   # but don't replace yet
        s/\(--mbtitle\)/$title/g;
        s/\(--mblanguage\)/$language/g;
        s/\(--mbbaseURL\)/$baseURL/g;
        s/\(--mbfilename\)/$filename/g;
        s/\(--mbfilemodtime\)/$filemodtime/g;
        print WORK;
}
        
sub putout {            # outputs current line with variable replacement
        if (! /\(--mb/) {
                print WORK;
                return;
        }
        if (/\(--mbfilesize\)/)                 # remember where it was
                { push @offsets, tell WORK; }   # but don't replace yet
        s/\(--mbtitle\)/$title/g;
        s/\(--mblanguage\)/$language/g;
        s/\(--mbbaseURL\)/$baseURL/g;
        s/\(--mbfilename\)/$filename/g;
        s/\(--mbfilemodtime\)/$filemodtime/g;
        print WORK;
}
        
while (<IN>) {                          # main loop for input file
        if (! /(.*)<!--metablock\s*(.*)/) {
                &putout;
                next;
        }
        $title = $2;
        $_ = $1;
        &putout;
        if ($title =~ s/\s*-->(.*)//) {
                $remainder = $1;
        }
        else {
                while (<IN>) {
                        $title .= $_;
                        last if (/(.*)\s*-->(.*)/);
                }
                $title .= $1;
                $remainder = $2;
        }
        open(TPLATE, "< template")
                or die("Could not open template file");
        while (<TPLATE>)                # subloop for template file
                { &putout; }
        close(TPLATE);
        $_ = $remainder;
        &putout;
        
while (<IN>) {                          # main loop for input file
        if (! /(.*)<!--metablock\s*(.*)/) {
                &putout;
                next;
        }
        $title = $2;
        $_ = $1;
        &putout;
        if ($title =~ s/\s*-->(.*)//) {
                $remainder = $1;
        }
        else {
                while (<IN>) {
                        $title .= $_;
                        last if (/(.*)\s*-->(.*)/);
                }
                $title .= $1;
                $remainder = $2;
        }
        open(TPLATE, "< template")
                or die("Could not open template file");
        while (<TPLATE>)                # subloop for template file
                { &putout; }
        close(TPLATE);
        $_ = $remainder;
        &putout;
        
}
close(IN);
        
}
close(IN);
        
# Now replace filesize variables without altering total byte count.
select( (select(WORK), $| = 1) [0] );   # first flush output so we
if (($size = -s WORK) < 100000)         # can get final file size
        { $scale = 0; }                 # and set scale factor or
else {                  # compute it, keeping width of size field low
        for ($scale = 0; $size >= 1000; $scale++)
                { $size /= 1024; }
}
$filesize = sprintf "%7.7s %sbytes",
        $size, (" ", "K", "M", "G", "T", "P") [$scale];
        
# Now replace filesize variables without altering total byte count.
select( (select(WORK), $| = 1) [0] );   # first flush output so we
if (($size = -s WORK) < 100000)         # can get final file size
        { $scale = 0; }                 # and set scale factor or
else {                  # compute it, keeping width of size field low
        for ($scale = 0; $size >= 1000; $scale++)
                { $size /= 1024; }
}
$filesize = sprintf "%7.7s %sbytes",
        $size, (" ", "K", "M", "G", "T", "P") [$scale];
        
foreach $pos (@offsets) {       # loop through saved size locations
        seek WORK, $pos, 0;             # read the line found there
        $_ = <WORK>;
        # $filesize must be exactly as wide as "(--mbfilesize)"
        s/\(--mbfilesize\)/$filesize/g;
        seek WORK, $pos, 0;             # rewrite it with replacement
        print WORK;
}
        
foreach $pos (@offsets) {       # loop through saved size locations
        seek WORK, $pos, 0;             # read the line found there
        $_ = <WORK>;
        # $filesize must be exactly as wide as "(--mbfilesize)"
        s/\(--mbfilesize\)/$filesize/g;
        seek WORK, $pos, 0;             # rewrite it with replacement
        print WORK;
}
        
close(WORK);
rename($workfile, "$filename")
        or die("Could not rename \"$workfile\" to \"$filename\"");
# ---- end of Perl script ----
        
close(WORK);
rename($workfile, "$filename")
        or die("Could not rename \"$workfile\" to \"$filename\"");
# ---- end of Perl script ----
        
10. Author's Address
10. 作者地址

John A. Kunze Center for Knowledge Management University of California, San Francisco 530 Parnassus Ave, Box 0840 San Francisco, CA 94143-0840, USA

约翰·A·昆泽加利福尼亚大学知识管理中心,旧金山530 Parnassus Ave,旧金山0840,美国94143-0840

   Fax:   +1 415-476-4653
   EMail: jak@ckm.ucsf.edu
        
   Fax:   +1 415-476-4653
   EMail: jak@ckm.ucsf.edu
        
11. References
11. 工具书类
   [AAT]            Art and Architecture Thesaurus, Getty Information
                    Institute.
                    http://shiva.pub.getty.edu/aat_browser/
        
   [AAT]            Art and Architecture Thesaurus, Getty Information
                    Institute.
                    http://shiva.pub.getty.edu/aat_browser/
        
   [AC]             The A-Core: Metadata about Content Metadata, (in
                    progress)
                    http://metadata.net/ac/draft-iannella-admin-01.txt
        
   [AC]             The A-Core: Metadata about Content Metadata, (in
                    progress)
                    http://metadata.net/ac/draft-iannella-admin-01.txt
        

[DC1] Weibel, S., Kunze, J., Lagoze, C. and M. Wolf, "Dublin Core Metadata for Resource Discovery", RFC 2413, September 1998. ftp://ftp.isi.edu/in-notes/rfc2413.txt

[DC1]Weibel,S.,Kunze,J.,Lagoze,C.和M.Wolf,“用于资源发现的都柏林核心元数据”,RFC 2413,1998年9月。ftp://ftp.isi.edu/in-notes/rfc2413.txt

   [DCHOME]         Dublin Core Initiative Home Page.
                    http://purl.org/DC/
        
   [DCHOME]         Dublin Core Initiative Home Page.
                    http://purl.org/DC/
        
   [DCPROJECTS]     Projects Using Dublin Core Metadata.
                    http://purl.org/DC/projects/index.htm
        
   [DCPROJECTS]     Projects Using Dublin Core Metadata.
                    http://purl.org/DC/projects/index.htm
        
   [DCT1]           Dublin Core Type List 1, DC Type Working Group,
                    March 1999.
                    http://www.loc.gov/marc/typelist.html
        
   [DCT1]           Dublin Core Type List 1, DC Type Working Group,
                    March 1999.
                    http://www.loc.gov/marc/typelist.html
        
   [freeWAIS-sf2.0] The enhanced freeWAIS distribution, February 1999.
                    http://ls6-www.cs.uni-
                    dortmund.de/ir/projects/freeWAIS-sf/
        
   [freeWAIS-sf2.0] The enhanced freeWAIS distribution, February 1999.
                    http://ls6-www.cs.uni-
                    dortmund.de/ir/projects/freeWAIS-sf/
        
   [GLIMPSE]        Glimpse Home Page.
                    http://glimpse.cs.arizona.edu/
        
   [GLIMPSE]        Glimpse Home Page.
                    http://glimpse.cs.arizona.edu/
        
   [HARVEST]        Harvest Web Indexing.
                    http://www.tardis.ed.ac.uk/harvest/
        
   [HARVEST]        Harvest Web Indexing.
                    http://www.tardis.ed.ac.uk/harvest/
        
   [HTML4.0]        Hypertext Markup Language 4.0 Specification, April
                    1998.
                    http://www.w3.org/TR/REC-html40/
        
   [HTML4.0]        Hypertext Markup Language 4.0 Specification, April
                    1998.
                    http://www.w3.org/TR/REC-html40/
        
   [ISEARCH]        Isearch Resources Page.
                    http://www.etymon.com/Isearch/
        
   [ISEARCH]        Isearch Resources Page.
                    http://www.etymon.com/Isearch/
        
   [ISO639-2]       Code for the representation of names of languages,
                    1996.
                    http://www.indigo.ie/egt/standards/iso639/iso639-2-
                    en.html
        
   [ISO639-2]       Code for the representation of names of languages,
                    1996.
                    http://www.indigo.ie/egt/standards/iso639/iso639-2-
                    en.html
        
   [ISO8601]        ISO 8601:1988(E), Data elements and interchange
                    formats -- Information interchange -- Representation
                    of dates and times, International Organization for
                    Standardization, June 1988.
                    http://www.iso.ch/markete/8601.pdf
        
   [ISO8601]        ISO 8601:1988(E), Data elements and interchange
                    formats -- Information interchange -- Representation
                    of dates and times, International Organization for
                    Standardization, June 1988.
                    http://www.iso.ch/markete/8601.pdf
        
   [MARC]           USMARC Format for Bibliographic Data, US Library of
                    Congress.
                    http://lcweb.loc.gov/marc/marc.html
        
   [MARC]           USMARC Format for Bibliographic Data, US Library of
                    Congress.
                    http://lcweb.loc.gov/marc/marc.html
        

[PERL] L. Wall, T. Christiansen, R. Schwartz, Programming Perl, Second Edition, O'Reilly, 1996.

[PERL]L.Wall,T.Christiansen,R.Schwartz,PERL编程,第二版,O'Reilly,1996年。

   [RDF]            Resource Description Framework Model and Syntax
                    Specification, February 1999.
                    http://www.w3.org/TR/REC-rdf-syntax/
        
   [RDF]            Resource Description Framework Model and Syntax
                    Specification, February 1999.
                    http://www.w3.org/TR/REC-rdf-syntax/
        
   [RFC1766]        Alvestrand, H., "Tags for the Identification of
                    Languages", RFC 1766, March 1996.
                    ftp://ftp.isi.edu/in-notes/rfc1766.txt
        
   [RFC1766]        Alvestrand, H., "Tags for the Identification of
                    Languages", RFC 1766, March 1996.
                    ftp://ftp.isi.edu/in-notes/rfc1766.txt
        
   [SWISH-E]        Simple Web Indexing System for Humans - Enhanced.
                    http://sunsite.Berkeley.EDU/SWISH-E/
        
   [SWISH-E]        Simple Web Indexing System for Humans - Enhanced.
                    http://sunsite.Berkeley.EDU/SWISH-E/
        
   [TGN]            Thesaurus of Geographic Names, Getty Information
                    Institute.
                    http://shiva.pub.getty.edu/tgn_browser/
        
   [TGN]            Thesaurus of Geographic Names, Getty Information
                    Institute.
                    http://shiva.pub.getty.edu/tgn_browser/
        
   [WTN8601]        W3C Technical Note - Profile of ISO 8601 Date and
                    Time Formats.
                    http://www.w3.org/TR/NOTE-datetime
        
   [WTN8601]        W3C Technical Note - Profile of ISO 8601 Date and
                    Time Formats.
                    http://www.w3.org/TR/NOTE-datetime
        
   [XML]            Extensible Markup Language (XML).
                    http://www.w3.org/TR/REC-xml
        
   [XML]            Extensible Markup Language (XML).
                    http://www.w3.org/TR/REC-xml
        
12. Full Copyright Statement
12. 完整版权声明

Copyright (C) The Internet Society (1999). All Rights Reserved.

版权所有(C)互联网协会(1999年)。版权所有。

This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organizations, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English.

本文件及其译本可复制并提供给他人,对其进行评论或解释或协助其实施的衍生作品可全部或部分编制、复制、出版和分发,不受任何限制,前提是上述版权声明和本段包含在所有此类副本和衍生作品中。但是,不得以任何方式修改本文件本身,例如删除版权通知或对互联网协会或其他互联网组织的引用,除非出于制定互联网标准的需要,在这种情况下,必须遵循互联网标准过程中定义的版权程序,或根据需要将其翻译成英语以外的其他语言。

The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns.

上述授予的有限许可是永久性的,互联网协会或其继承人或受让人不会撤销。

This document and the information contained herein is provided on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

本文件和其中包含的信息是按“原样”提供的,互联网协会和互联网工程任务组否认所有明示或暗示的保证,包括但不限于任何保证,即使用本文中的信息不会侵犯任何权利,或对适销性或特定用途适用性的任何默示保证。

Acknowledgement

确认

Funding for the RFC Editor function is currently provided by the Internet Society.

RFC编辑功能的资金目前由互联网协会提供。