この文書はRSS 2.0 Specificationを元に、RSS 2.0を解説したものです。正確な仕様についての情報を得たい方は、上記URLを参照してください。

Index

  1. RSS 2.0とは何か
  2. RSS 2.0の例
  3. channel要素
    1. title要素
    2. link要素
    3. description要素
    4. language要素
    5. copyiright要素
    6. managingEditor要素
    7. webMaster要素
    8. pubDate要素
    9. lastBuildDate要素
    10. category要素
    11. generator要素
    12. docs要素
    13. cloud要素
    14. ttl要素
    15. image要素
    16. rating要素
    17. textInput要素
    18. skipHours要素
    19. skipDays要素
  4. item要素
    1. title要素
    2. link要素
    3. description要素
    4. author要素
    5. category要素
    6. comments要素
    7. enclosure要素
    8. guid要素
    9. pubDate要素
    10. source要素
  5. RSS 2.0の拡張

Contents

RSS 2.0とは何か

RSS 2.0はウェブ上の様々な成果物を配信するためのフォーマットです。

この名称は"Really Simple Syndication"の頭文字語です。

RSS 2.0はXMLの一種で、すべてのRSS 2.0ファイルはXML 1.0 Specificationに則っていなければなりません。

RSS 2.0のトップ・レベル要素はrssで、これはRSS 2.0ファイルがどのバージョンのRSS 2.0に基づいているかを示すversionという必須属性を持ちます。このversion属性の値は2.0でなければなりません。

rss要素に従属する要素は、ひとつのchannel要素です。

RSS 2.0の例

典型的なRSS 2.0のファイルは以下のようなものになります。

<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>Liftoff News</title>
    <link>http://liftoff.msfc.nasa.gov/</link>
    <description>Liftoff to Space Exploration.</description>
    <language>en-us</language>
    <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
    <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>Weblog Editor 2.0</generator>
    <managingEditor>editor@example.com</managingEditor>
    <webMaster>webmaster@example.com</webMaster>
    <item>
      <title>Star City</title>
      <link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link>
      <description>How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia's &lt;a href="http://howe.iki.rssi.ru/GCTC/gctc_e.htm"&gt;Star City&lt;/a&gt;.</description>
      <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>
      <guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid>
    </item>
    <item>
      <description>Sky watchers in Europe, Asia, and parts of Alaska and Canada will experience a &lt;a href="http://science.nasa.gov/headlines/y2003/30may_solareclipse.htm"&gt;partial eclipse of the Sun&lt;/a&gt; on Saturday, May 31st.</description>
      <pubDate>Fri, 30 May 2003 11:06:42 GMT</pubDate>
      <guid>http://liftoff.msfc.nasa.gov/2003/05/30.html#item572</guid>
    </item>
    <item>
      <title>The Engine That Does More</title>
      <link>http://liftoff.msfc.nasa.gov/news/2003/news-VASIMR.asp</link>
      <description>Before man travels to Mars, NASA hopes to design new engines that will let us fly through the Solar System more quickly.  The proposed VASIMR engine would do that.</description>
      <pubDate>Tue, 27 May 2003 08:37:32 GMT</pubDate>
      <guid>http://liftoff.msfc.nasa.gov/2003/05/27.html#item571</guid>
    </item>
    <item>
      <title>Astronauts' Dirty Laundry</title>
      <link>http://liftoff.msfc.nasa.gov/news/2003/news-laundry.asp</link>
      <description>Compared to earlier spacecraft, the International Space Station has many luxuries, but laundry facilities are not one of them.  Instead, astronauts have other options.</description>
      <pubDate>Tue, 20 May 2003 08:56:02 GMT</pubDate>
      <guid>http://liftoff.msfc.nasa.gov/2003/05/20.html#item570</guid>
    </item>
  </channel>
</rss>

RSS 1.0がchannelとitemが並列なのと比較して、RSS 2.0はRSS 0.9xと同じくitemがchannelの子になっています。

channel要素

channel要素は、RSS 2.0を配信する組織または人、ウェブサイト(以下、配信元と呼称する)などをを示す要素です。

title要素

必須です。配信元の名称を示す要素です。

<title>John Doe's Weblog</title>

必須です。配信元のURLを示す要素です。

<link>http://example.com/john.d/</link>

description要素

必須です。配信元の簡単な説明を示す要素です。

<description>Weblog edited by John Doe.</description>

language要素

配信元の言語を示す要素です。Netscape社によって定められた利用できる値を取ることが出来ます。また、W3Cによって定められたHTMLで利用されている言語コードを値として取っても構いません。

<language>en-us</language>

copyiright要素

RSS 2.0ファイルの権利の帰属を示す要素です。

<copyright>Copyright 2004, John Doe</copyright>

managingEditor要素

RSS 2.0ファイルの配信を担当する人を示す要素です。

<managingEditor>john.d@example.com (John Doe)</managingEditor>

webMaster要素

配信元の技術的な問題の報告を引き受ける人を示す要素です。

<webMaster>webmaster@example.com (John Doe)</webMaster>

RSS 1.0でAdministrativeモジュールを利用し、admin:erroRepotrsTo要素で示すものと等価だと思います。

pubDate要素

RSS 2.0ファイルの配信元が最後に更新された日付けと時刻を示す要素です。RFC 822の書式に従う必要があります。

<pubDate>Sun, 29 Aug 2004 15:42:09 +0900</pubDate>

配信元がウェブサイトなどの場合は、トップページのHTMLファイルのmtimeになると思います。

lastBuildDate要素

RSS 2.0ファイルが最後に更新された日付けと時刻を示す要素です。RFC 822の書式に従う必要があります。

<lastBuildDate>Tue, 31 Aug 2004 19:03:22 +0900</lastBuildDate>

RSS 2.0のmtimeになると思います。

category要素

配信元がどんなジャンルのものかを示す要素です。

<category>Weblog</category>

generator要素

配信元を制作するのに使われたプログラムの名称を示す要素です。

<generator>blosxom v2.0</generator>

RSS 1.0でAdministrativeモジュールを利用し、admin:generatorAgent要素で示すものと等価ですが、generator要素は文字列、admin:generatorAgent要素はURIで示します。

docs要素

RSS 2.0ファイルがどんなフォーマットに従っているかを示す要素です。そのフォーマットを公式に説明したページのURLを記述します。

<docs>http://blogs.law.harvard.edu/tech/rss</docs>

通常は上記例で固定で構わないと思います。

cloud要素

よくわからないので割愛させていただきます。

ttl要素

RSS 2.0をキャッシュすべき分を示す要素です。

<ttl>60</ttl>

image要素

配信元のイメージ画像を示す要素です。

<image>
  <url>http://example.com/john.d/img/logo.png</url>
  <title>John Doe's Weblog</title>
  <link>http://example.com/john.d/</link>
  <description>John Doe's Weblog</description>
  <width>88</width>
  <height>31</heaight>
</image>

image要素は以下の子要素から成ります。

url
必須です。画像ファイルのURLを示す要素です。
title
必須です。画像ファイルのALTテキストを示す要素です。画像ファイルの説明ではありません。
link
必須です。画像ファイルにリンクさせるURLを示す要素です。
description
linkで示されたURLの簡単な説明を示す要素です。
width
画像ファイルの横幅を示す要素です。最大値は144です。
height
画像ファイルの縦幅を示す要素です。最大値は400です。

widthとheightに最大値が設定されていますが、根拠があるとは思えないです。

rating要素

よくわからないので割愛させていただきます。

textInput要素

配信元の情報と共に表示されるテキスト入力ボックスとボタンを示す要素です。配信元がウェブサイトの場合、そのウェブサイト内の検索に利用できるテキスト入力ボックスとボタンを作れるように各子要素を設定します。別の利用方法ではフィードバックのためのフォームを作れるように設定しても構いません。

<textInput>
  <title>Search</title>
  <description>Input Search Text Here</description>
  <name>q</name>
  <link>http://example.com/john.d/cgi-bin/search.cgi</link>
</textInput>

textInput要素は以下の子要素から成ります。

title
必須です。ボタンのラベルに表示する文字列を示す要素です。
description
必須です。テキスト入力ボックスにデフォルトで入力しておく文字列を示す要素です。
name
必須です。link要素によって指定されたURLに渡すパラメータの識別名を示す要素です。
link
必須です。テキスト入力ボックスに入力された文字列を渡すURLを示す要素です。

skipHours要素

RSS 2.0ファイルをクロールするソフトウェアにチェックをして欲しくない時刻を示す要素です。

<skipHours>
  <hour>0</hour>
  <hour>6</hour>
  <hour>12</hour>
  <hour>18</hour>
</skipHours>

skipHours要素は1以上24以内のhour要素から成ります。day要素の値は0から23の数字で、0がGMTでの深夜0時を示します。

skipDays要素

RSS 2.0ファイルをクロールするソフトウェアにチェックをして欲しくない曜日を示す要素です。

<skipDays>
  <day>Monday</day>
  <day>Wednesday</day>
  <day>Friday</day>
</skipDays>

skipDays要素は1以上7以内のday要素から成ります。day要素の値はMonday、Tuesday、Wednesday、Thursday、Friday、Saturday、Sundayという文字列のいずれかで、GMTでの曜日を示します。

item要素

item要素は、配信したい成果物(以下、配信物と呼称する)のメタ・データの集合です。channel要素以下item要素の数に制限はありません。

title要素

配信物のタイトルを示す要素です。

<title>Big Surprise, too!</title>

配信物の存在するURLを示す要素です。

<link>http://example.com/john.d/2004/08/29.html#</link>

description要素

配信物の簡単な説明を示す要素です。

<description>I am surprised when reading the following article.</description>

author要素

配信物を作成した人を示す要素です。

<author>john.d@example.com (John Doe)</author>

category要素

配信物がどんなジャンルのものかを示す要素です。

<category>Daily Report</category>

category要素はdomainという属性を利用して、URLでジャンルを示すことが出来るようですが、よくわかりません。

comments要素

配信物に対するコメントを受け付けているページのURLを示す要素です。

<comments>http://example.com/john.d/cgi-bin/comments.cgi?id=264</comments>

enclosure要素

配信物に添付されているメディアを示す要素です。

<enclosure url="http://example.com/john.d/media/my-love-song.mp3" length="12216320" type="audio/mpeg" />

enclosure要素には以下の属性から成ります。

url
必須です。添付されているメディアのURLを示す属性です。httpで始まるURLでなければなりません。
length
必須です。添付されているメディアのサイズを示す属性です。単位はbyteです。
type
必須です。添付されているメディアのMIME typeを示す属性です。

urlはhttp始まりとなっていますが、根拠があるかどうかは不明です。私見では、それなりにメジャーなmmsなどのスキームなら利用しても良いのではないかなと思います。

guid要素

配信物を識別するためのユニークなIDを示す要素です。

<guid>264@example.com/john.d</guid>

guid要素にpermanent linkを利用する場合は、isPermaLinkという属性を指定し、値をtrueに設定してください。

<guid isPermaLink="true">http://example.com/john.d/2004/08/29.html#</guid>

pubDate要素

配信物が公開された日付けと時刻を示す要素です。RFC 822の書式に従う必要があります。

<pubDate>Mon, 30 Aug 2004 15:36:22 +0900</pubDate>

source要素

配信物を作成する上で参考にしたRSS 2.0ファイルを示す要素です。

<source url="http://example.com/jane.d/rss.xml">Jane Doe's Journal</source>

source要素はurlという属性が必要です。url属性の値はRSS 2.0ファイルのURLです。

RSS 2.0の拡張

RSS 2.0はRSS 2.0 Specificationで定められていない要素に限り、モジュールによる拡張が可能です。

定められていない要素に限り拡張することが出来るので、以下のようなRSS 2.0ファイルは認められません。

<?xml version="1.0"?>
  <rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    ...
    <item>
      ...
      <dc:date>2004-08-30T16:11:45+09:00</dc:date>
    </item>
  </channel>
</rss>

以上の例では、Dublin Coreモジュールによるdate要素はitem要素のpubDate要素と同じ意味を持つと考えられるので、問題があります。対してitem要素のdescription要素とは別に、配信物の完全な内容を配信したい場合に、以下のようにContentモジュールを利用することは可能です。

<?xml version="1.0"?>
  <rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    ...
    <item>
      ...
      <content:encoded>
        <![CDATA[<p>What a <em>beautiful</em> day!</p>]]>
      </content:encoded>
    </item>
  </channel>
</rss>

ということになっていますが、根拠があるかどうかは不明です。

License

この文書はRSS 2.0 Specificationと同じく、Creative Commons - Attribution-ShareAlikeで提供されます。

Authorship

この文書はRSS 2.0 Specificationの翻訳なので、ほぼすべての著作権はRSS Advisory Boardに帰属します。