* Text construct (Atom 1.0)

[8] [[Atom]] の [DFN@en[[[Text construct]]]] は、[[人間可読]]の[[文章]]を含みます。
普通は短い[[文章]]です。 [SRC@en[[[Atom 1.0]] 3.1.]]

:[[内容モデル]]:[CODE(XMLa)@en[[[type]]]] 依存
:[[属性]]:[CODE(XMLa)@en[[[type]]]]

[9] 仕様書:
- [CITE@en[RFC 4287 - The Atom Syndication Format]] ([TIME[2008-08-30 23:12:03 +09:00]] 版) <http://tools.ietf.org/html/rfc4287#section-3.1>

** 意味

[10] [[Text construct]] の[[内容]]は [[Language-Sensitive]] です
[SRC@en[[[Atom 1.0]] 3.1.]]。

** 内容

[22] [[Text construct]] の[[要素]]の[[内容]]は、 [CODE(XMLa)@en[[[type]]]] [[属性]]の値によって決まります。

*** テキスト

[23] [CODE(XMLa)@en[[[type]]]] が [DFN@en[[CODE(XML)@en[[[text]]]]]] の場合、
[[子要素]]を含んでは[['''なりません''']] [SRC@en[[[Atom 1.0]] 3.1.1.1.]]。

*** HTML

[27] [CODE(XMLa)@en[[[type]]]] が [DFN@en[[CODE(XML)@en[[[html]]]]]] の場合、
[[子要素]]を含んでは[['''なりません''']] [SRC@en[[[Atom 1.0]] 3.1.1.2.]]。

[28] [[内容]]は [[HTML 4.01]] として処理するのに適切である[['''べきです''']]。
[[HTML]] [[マーク付け]]は [[escape]] しなければ[['''なりません''']]。
[CODE(HTMLe)@en[[[div]]]] [[要素]]内に現れたとして[[妥当]]である[['''べきです''']]。
[SRC@en[[[Atom 1.0]] 3.1.1.2.]]

;; [[escaped markup]] の項も参照してください。

*** XHTML

[30] [CODE(XMLa)@en[[[type]]]] が [DFN@en[[CODE(XML)@en[[[xhtml]]]]]] の場合、
[[内容]]は [[XHTML m12n 1.0]] [CODE(HTMLe)@en[[[div]]]] [[要素]]だけでなければ[['''なりません''']]。
[[XHTML]] として処理するのに適切である[['''べきです''']]。
[SRC@en[[[Atom 1.0]] 3.1.1.3.]]

[31] [CODE(HTMLe)@en[[[div]]]] [[要素]]自体は内容の一部と考えては[['''なりません''']]。
[SRC@en[[[Atom 1.0]] 3.1.1.3.]]

[32] でも、 [CODE(HTMLe)@en[[[div]]]] [[要素]]自体は内容でないとしても、そこに
[CODE(HTMLa)@en[[[lang]]]] [[属性]]や [CODE(HTMLa)@en[[[dir]]]] [[属性]]が指定されることがあるので、
注意が必要です。
とはいっても、 [CODE(HTMLe)@en[[[div]]]] [[要素]]が特別なのではなく、
それ以外にも [CODE(XMLa)@en[[[xml:base]]]] [[属性]]や[[名前空間属性]]などのように[[先祖]]
([CODE(HTMLe)@en[[[div]]]] より更に上からも。) から[[継承]]する[[属性]]は色々ありますので、
[[フィード]]の一部を取り出して他のところに使うときには本当に注意しないといけません。

;; もちろん、他の [CODE(XMLa)@en[[[type]]]] でもです。

** 処理

[38] 未知の [CODE(XMLa)@en[type]] に遭遇した時どうするべきなのかは不明です。

[39] [CODE(XML)@en[[[type]]=[[text]]]] や [CODE(XMLa)@en[[[type]]=[[html]]]]
で[[子要素]]が出現した時どうするべきなのかは不明です。

[40] [CODE(XML)@en[[[type]]=[[xhtml]]]] で
[CODE(HTMLe)@en[div]] [[要素]]がなかったり、他に[[子要素]]があったりするときどうするべきなのかは不明です。

** レンダリング

*** テキスト

[24] 
[CODE(XMLa)@en[[[type]]]] が [CODE(XML)@en[[[text]]]] の場合、
[[Atom処理器]]は[[空白]] ([[改行]]を含みます。) をまとめたり、
[[両端揃え]]や[[可変幅フォント]]のような[[組版]]上の技術を適用したりして[['''構いません''']]
[SRC@en[[[Atom 1.0]] 3.1.1.1.]]。

** 歴史

[18] [[Atom 0.3]] では [CODE(XMLe)@en[atom:[[content]]]] [[要素]]も含めて [[Content construct]]
という名前でしたが、 [[Atom 1.0]] では [[Text construct]] に改名され、
同[[要素]]は別個の定義となりました。

[19] [[Atom 0.3]] の [[Content construct]] には [CODE(XMLa)@en[[[mode]]]] と
[CODE(XMLa)@en[[[type]]]] の2つの[[属性]]がありましたが、両者は統合されて
[CODE(XMLa)@en[[[type]]]] [[属性]]のみになりました。

** 関連

[17] [[Atom 1.0]] の [CODE(XMLe)@en[atom:[[content]]]] [[要素]]は [[Text construct]] と似ていますが、
[[平文]]や [[HTML]] 以外の内容も表せます。

** 例

[25] 
[PRE(XML example code)[
   <title type="text">
     Less: &lt;
   </title>
]PRE]

;; [[Atom 1.0]] 3.1.1.1.

[26] 
[PRE(XML example code)[
   <title type="html">
     Less: &lt;em> &amp;lt; &lt;/em>
   </title>
]PRE]

;; [[Atom 1.0]] 3.1.1.2.

[29] 
[PRE(XML example code)[
   <title type="xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml">
     <xhtml:div>
       Less: <xhtml:em> &lt; </xhtml:em>
     </xhtml:div>
   </title>
]PRE]

;; [[Atom 1.0]] 3.1.1.3.

[33] 
[PRE(XML example code)[
   <summary type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
         This is <b>XHTML</b> content.
      </div>
   </summary>
]PRE]

;; [[Atom 1.0]] 3.1.1.3.

[34] 
[PRE(XML example code)[
   <summary type="xhtml">
      <xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">
         This is <xhtml:b>XHTML</xhtml:b> content.
      </xhtml:div>
   </summary>
]PRE]

;; [[Atom 1.0]] 3.1.1.3.

[35] 
[PRE(XML example code)[
   <summary type="xhtml">
      <xh:div>
         This is <xh:b>XHTML</xh:b> content.
      </xh:div>
   </summary>

]PRE]

;; [[Atom 1.0]] 3.1.1.3.

[7] [CITE[A Blog From Behind the Trenches]] ([TIME[2008-12-06 00:55:06 +09:00]] 版) <http://my.opera.com/haavard/xml/atom/blog/>

>
[PRE(XML example code)[
<entry>
  <title type="xhtml" xml:lang="en">
    <div xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr">Net Applications admits to skewed statistics</div>
  </title>
  <author>
    <name>Haavard</name>
  </author>
  <link href="http://my.opera.com/haavard/blog/show.dml/2779029"/>
  <id>http://my.opera.com/haavard/blog/2779029</id>
  <updated>2008-12-03T12:56:55Z</updated>
  <content xml:lang="en" type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr"><hr/>In an article at &quot;The Industry Standard&quot;, Net Applications apparently <a href="http://www.thestandard.com/news/2008/12/02/safari-tops-7-global-browser-market-share-sort" target="_blank">admit that their numbers are skewed</a>. More specifically, they admit that they are skewed towards certain regions of the world (US-centric, anyone?). In such an amazing moment of honesty, I wonder why they didn't also admit to actively <a href="http://my.opera.com/haavard/blog/2008/09/04/why-is-net-applications-hitslink-changing-its-browser-stats-after-publishing" target="_blank">editing their own statistics</a>.<br/><br/><strong>Update:</strong> Their claim to be skewed towards Europe doesn't really match <a href="http://www.xitimonitor.com/en-us/browsers-barometer/browsers-barometer-september-2008/index-1-2-3-145.html" target="_blank">XiTi Monitor's statistics for Europe</a>. This would indicate that Net Applications is <strong>heavily</strong> skewed towards the US.</div></content>

</entry>
]PRE]

[CODE(XMLe)@en[atom:[[content]]]] [[要素]]や [[Text construct]] である [CODE(XMLa)@en[atom:[[title]]]] 
[[要素]]の[[子供]]の [CODE(HTMLe)@en[[[div]]]] [[要素]]に[[属性]]が指定されています。
意外と珍しい気がします。 [CODE(XML)@en[[[type]]=[[xhtml]]]] 自体珍しいかもしれませんが、
その中でも更に珍しいんじゃないかな。 [CODE(XMLa)@en[[[xml:lang]]]] [[属性]]でなく
[CODE(HTMLa)@en[[[lang]]]] [[属性]]を使っているところにも注目したいですね。

* Content construct (Atom 0.3)

[1] [[Atom 0.3]] の [DFN[[[Content construct]]]] は、
任意の[[子供]][[内容]]を含めることができます [SRC@en[[[Atom 0.3]]]]。

仕様書:
[CITE[The Atom Syndication Format 0.3 (PRE-DRAFT)]] ([TIME[2006-12-22 17:03:44 +09:00]] 版) <http://www.mnot.net/drafts/draft-nottingham-atom-format-02.html#rfc.section.3.1>

[2] [[属性]]は2つあり、[[子供]]の[[特性]]を指定します [SRC@en[[[Atom 0.3]]]]。

- [CODE(XMLa)@en[[[type]]]]
- [CODE(XMLa)@en[[[mode]]]]


** 関連

[6] [[Content construct]] は、 [[Atom 1.0]] では [[Text construct]] に改名され、
2つの[[属性]]も1つの [CODE(XMLa)@en[[[type]]]] [[属性]]に統合されています。
更に、 [CODE(XMLe)@en[atom:[[content]]]] [[要素]]は独立した[[内容モデル]]に変更されています。

* [CODE(XMLa)@en[type]] 属性 (Atom 1.0)

[11] [[Atom 1.0]] の [[Text construct]] の 
[DFN[[CODE(XMLa)@en[[[type]]]] [[属性]]]]は、
[[内容]]の種類を表します。

[12] 
:[[要素]]: [[Text construct]] の[[要素]]
:[[属性名]]:[CODE(XMLa)@en[[[type]]]]
:[[データ型]]:[CODE(XML)@en[[[text]]]] | [CODE(XML)@en[[[html]]]] | [CODE(XML)@en[[[xhtml]]]]
:[[既定値]]:[CODE(XML)@en[[[text]]]]

[13] 仕様書:
-[CITE@en[RFC 4287 - The Atom Syndication Format]] ([TIME[2008-08-30 23:12:03 +09:00]] 版) <http://tools.ietf.org/html/rfc4287#section-3.1.1>

** 属性値

[14] [[Atom 1.0]] では3種類の値が定義されています。
:[CODE(XML)@en[[[text]]]]:[[平文]]を表します。
:[CODE(HTML)@en[[[html]]]]:[[HTML]] を表します。 [[escaped markup]] として解釈されます。
:[CODE(HTML)@en[[[xhtml]]]]:[[XHTML]] を表します。[[子孫要素]]がそのまま [[HTML]] 片として解釈されます。

[21] [CODE(XMLe)@en[atom:[[content]]]] [[属性]]の [CODE(XMLa)@en[[[type]]]] [[属性]]とは異なり、
[[媒体型]]を指定しては[['''なりません''']] [SRC@en[[[Atom 1.0]] 3.1.1.]]。

** 既定値

[15] この[[属性]]の[[既定値]]は陽には定義されていません。

[16] [[Atom処理器]]は、この[[属性]]が存在しない場合、
[CODE(XML)@en[[[text]]]] と同じように動作しなければ[['''なりません''']]
[SRC@en[[[Atom 1.0]] 3.1.1.]]。

** 歴史

[20] [[Atom 0.3]] [[Content construct]] には [CODE(XMLa)@en[[[type]]]] [[属性]]と
[CODE(XMLa)@en[[[mode]]]] [[属性]]がありましたが、 [[Atom 1.0]]
では両者が統合され、 [CODE(XMLa)@en[[[type]]]] [[属性]]のみとなりました。
[[Content construct]] と違って [[Base64]] や任意の[[媒体型]]を使うことはできなくなっています
([[Atom 1.0]] [CODE(XMLe)@en[atom:[[content]]]] [[要素]]では可能です)。

* [CODE(XMLa)@en[mode]] 属性 (Atom 0.3)

[3] [[Atom 0.3]] の [[Content construct]] の
[DFN[[CODE(XMLa)@en[mode]] [[属性]]]]は、
[[内容]]の[[符号化]]の方法を表します [SRC@en[[[Atom 0.3]]]]。

:状態:[[廃止]] → [[Atom 1.0]] [[Text construct]]/[CODE(XMLe)@en[atom:[[content]]]] [CODE(XMLa)@en[[[type]]]]
:[[要素]]:[[Content construct]] な[[要素]]
:[[局所名]]:[CODE(XMLa)@en[[[mode]]]]
:[[データ型]]:[CODE(XML)@en[[[xml]]]] / [CODE(XML)@en[[[escaped]]]] / [CODE(XML)@en[[[base64]]]]

仕様書:
[CITE[The Atom Syndication Format 0.3 (PRE-DRAFT)]] ([TIME[2006-12-22 17:03:44 +09:00]] 版) <http://www.mnot.net/drafts/draft-nottingham-atom-format-02.html#rfc.section.3.1.2>

** 属性値

[4] [[属性値]]は次のいずれかでなければ[['''なりません''']] [SRC@en[[[Atom 0.3]]]]。

:[DFN[[CODE(XML)@en[[[xml]]]]]]:
[[要素]]の[[内容]]が[[行内]] [[XML]] であることを表します。
(例: [[名前空間]]に属する [[XHTML]]) [SRC@en[[[Atom 0.3]]]]
:[DFN[[CODE(XML)@en[[[escaped]]]]]]:
[[要素]]の[[内容]]が[[逃避]]された[[文字列]]であることを示します。
[[処理器]]は、 [CODE(XMLa)@en[[[type]]]] で指定された[[媒体型]]として解釈する前に[[逃避]]を元に戻さなければ[['''なりません''']]。 [SRC@en[[[Atom 0.3]]]]
:[DFN[[CODE(XML)@en[[[base64]]]]]]:
[[要素]]の[[内容]]は [[RFC 2045]] [[Base64]] で[[符号化]]された[[文字列]]です。
[[処理器]]は、 [CODE(XMLa)@en[[[type]]]] で指定された[[媒体型]]として解釈する前に[[復号]]しなければ[['''なりません''']]。 [SRC@en[[[Atom 0.3]]]]


** 既定値

[5] [[既定値]]は [CODE(XML)@en[[[xml]]]] です [SRC@en[[[Atom 0.3]]]]。

* Text construct (Metalink)

[37] [[Metalink]] の [[Text construct]] は[[属性]]を持たず、常に [CODE(XML)@en[text]]
相当のようです。

[REFS[
- [36] [CITE@en[RFC 5854 - The Metalink Download Description Format]] ([TIME[2014-09-14 16:54:14 +09:00]] 版) <http://tools.ietf.org/html/rfc5854#section-3.1>
]REFS]

[FIG(quote)[
[FIGCAPTION[
[41] ([TIME[2016-03-19 18:26:28 +09:00]] 版)
<http://blog.suzaka.jp/xmlsrv/atom.php?blog=79>
]FIGCAPTION]

> <entry>
> 		<title type="text/plain" mode="xml">新刊入荷しました&#38;休館日のお知らせ</title>

]FIG]


[FIG(quote)[
[FIGCAPTION[
[42] [CITE[はてなフォトライフAtomAPI - Hatena Developer Center]]
([TIME[2016-03-21 10:42:59 +09:00]] 版)
<http://developer.hatena.ne.jp/ja/documents/fotolife/apis/atom>
]FIGCAPTION]

> POST /atom/post
> <entry xmlns="http://purl.org/atom/ns#">
>   <title>Sample</title>
>   <content mode="base64" type="image/jpeg">/9j/2wCEAAQDAwQDAw.../9n/AA==</content>
> </entry>

]FIG]


[FIG(quote)[
[FIGCAPTION[
[43] [CITE@en[Blogger: Atom API Documentation]]
([TIME[2016-03-21 11:04:04 +09:00]] 版)
<https://blogger-developers.googleblog.com/archives/atom-docs.html>
]FIGCAPTION]

> 
>   <title mode="escaped" type="text/plain">atom test</title>

]FIG]


[FIG(quote)[
[FIGCAPTION[
[44] [CITE@en[Blogger: Atom API Documentation]]
([TIME[2016-03-21 11:04:25 +09:00]] 版)
<https://blogger-developers.googleblog.com/archives/atom-docs.html>
]FIGCAPTION]

> 
>   <content type="application/xhtml+xml">
>     <div xmlns="http://www.w3.org/1999/xhtml">Testing the Atom API</div>
>   </content>

]FIG]


[45] [CITE@en[RFC 8120 - Mutual Authentication Protocol for HTTP]]
([TIME[2017-04-20 12:04:06 +09:00]])
<https://tools.ietf.org/html/rfc8120#section-3.2.3>

[46] [CITE@en[Clarify base64 vs base64url for hashes.]]
([[mikewest]]著, [TIME[2017-05-09 22:58:11 +09:00]])
<https://github.com/w3c/webappsec-csp/commit/1ceea1b95e73d34dd717282fbe8c19189043c07b>

[FIG(quote)[
[FIGCAPTION[
[47] ([TIME[2018-02-09 09:49:24 +09:00]])
<https://info.quantcast.com/rs/516-DGM-318/images/Framework%20CMP%20JS%20API%20Specification.pdf>
]FIGCAPTION]

>  metadata: websafe-base64 encoded string,
> 

]FIG]
