Atom Threading Extensions

IRC で miyagawa さんが貼っていた URL 経由で見つけたのですが、Atom Threading Extensions なんてものがあったのですね。

要するに、Atom Syndication Format で、メーリングリストや掲示板の様なスレッドを表現するための仕組みです。

コメントやトラックバックの関連を視覚化、というアイデアは色んな人達が考えていると思うのですが、それをサポートするような規格が既にあったとは知りませんでした。

ここではざっと要点だけご紹介します。詳細知りたい方は原文をお読みください。そんなにボリュームないですし。(このエントリも間違っている可能性があるので、できれば原文読んで頂いた方が良いかと。)

'in-reply-to' 拡張要素

entry 要素の子要素として指定するもので、そのエントリが、どのエントリに対する reply なのかを示す要素です。

<feed xmlns="http://www.w3.org/2005/Atom"
    xmlns:thr="http://purl.org/syndication/thread/1.0">
    <id>http://www.example.org/myfeed</id>
    <title>My Example Feed</title>
    <updated>2005-07-28T12:00:00Z</updated>
    <link href="http://www.example.org/myfeed" />
    <author><name>James</name></author>
    <entry>
        <id>tag:example.org,2005:1</id>
        <title>My original entry</title>
        <updated>2006-03-01T12:12:12Z</updated>
        <link
          type="application/xhtml+xml"
          href="http://www.example.org/entries/1" />
        <summary>This is my original entry</summary>
    </entry>
    <entry>
        <id>tag:example.org,2005:1,1</id>
        <title>A response to the original</title>
        <updated>2006-03-01T12:12:12Z</updated>
        <link href="http://www.example.org/entries/1/1" />
        <thr:in-reply-to
          ref="tag:example.org,2005:1"
          type="application/xhtml+xml"
          href="http://www.example.org/entries/1"/>
        <summary>This is a response to the original entry</summary>
    </entry>
</feed>

この例では、2番目の entry が最初の entry に対する reply となっています。各属性の意味は以下の通りです。

ref
元エントリの atom:id 要素。
href
元エントリの IRI。
type
元エントリのメディアタイプ。
source
元エントリが含まれる Atom Feed または Entry の IRI。

'replies' link relation

link 要素の rel 属性として replies を指定することで、その entry に対する reply が含まれている(かもしれない)リソースを参照します。

<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:thr="http://purl.org/syndication/thread/1.0">
    <id>http://www.example.org/myfeed</id>
    <title>My Example Feed</title>
    <updated>2005-07-28T12:00:00Z</updated>
    <link href="http://www.example.org/myfeed" />
    <author><name>James</name></author>
    <entry>
        <id>tag:entries.com,2005:1</id>
        <title>My original entry</title>
        <updated>2006-03-01T12:12:12Z</updated>
        <link href="http://www.example.org/entries/1" />
        <link rel="replies"
              type="application/atom+xml"
              href="http://www.example.org/mycommentsfeed.xml"
              thr:count="10" thr:updated="2005-07-28T12:10:00Z" />
        <summary>This is my original entry</summary>
    </entry>
</feed>

この link 要素は thr:count 属性と thr:updated 属性を持つことができます。各属性の意味は以下の通りです。

thr:count
href で示されるリソースに含まれている reply の数。
thr:updated
href で示されるリソース内の reply の最終更新日時。

どちらの属性も補助的なものであって、正確な数値でなくとも良い、という点には注意が必要です。

'total' 拡張要素

entry に対する reply の総数です。ドラフトにはサンプルがなかったので、以下の例は適当です。間違ってたらごめんなさい。

<feed xmlns="http://www.w3.org/2005/Atom"
    xmlns:thr="http://purl.org/syndication/thread/1.0">
    <id>http://www.example.org/myfeed</id>
    <title>My Example Feed</title>
    <updated>2005-07-28T12:00:00Z</updated>
    <link href="http://www.example.org/myfeed" />
    <author><name>James</name></author>
    <entry>
        <id>tag:example.org,2005:1</id>
        <title>My original entry</title>
        <updated>2006-03-01T12:12:12Z</updated>
        <link
          type="application/xhtml+xml"
          href="http://www.example.org/entries/1" />
        <summary>This is my original entry</summary>
        <thr:total>10</thr:total>
    </entry>
    </entry>
</feed>

これもやはり補助的な数値なので、正確な数値だと期待してはいけないようです。

thr:count, thr:updated, total の数値が正確なものでなくて良い理由については、ドラフトの「6. Considerations for using thr:count, thr:updated and total」について書かれていますので、ここでは省略します。(書くのめんどくさくなった。)