-
Notifications
You must be signed in to change notification settings - Fork 4
/
444.txt
360 lines (338 loc) · 16.8 KB
/
444.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
[15] A [DFN[feed]] has
[DFN[[F[entries]]][feed's entries]], which is a list of [[entries][entry]], and
[DFN[[F[authors]]][feed's authors]], which is a list of [[persons][person]].
They are initially empty.
[39] A [[feed]] has
[DFN[[F[page URL]]][feed's page URL]],
[DFN[[F[feed URL]]][feed's feed URL]],
[DFN[[F[icon URL]]][feed's icon URL]],
[DFN[[F[logo URL]]][feed's logo URL]],
[DFN[[F[title]]][feed's title]],
[DFN[[F[subtitle]]][feed's subtitle]], and
[DFN[[F[updated]]][feed's updated]].
They are initially [[null]].
[28] An [DFN[entry]] has
[DFN[[F[authors]]][entry's authors]], which is a list of [[persons][person]], and
[DFN[[F[categories]]][feed's categories]], which is a list of [[categories][category]].
They are initially empty.
[88] An [[entry]] has
[DFN[[F[feed]]][entry's feed]],
[DFN[[F[title]]][entry's title]],
[DFN[[F[summary]]][entry's summary]],
[DFN[[F[content]]][entry's content]],
[DFN[[F[published]]][entry's published]], and
[DFN[[F[updated]]][entry's updated]].
They are initially [[null]].
[81] To get the [DFN[[F[computed authors]]]] of an [[entry]] [VAR[entry]], run these steps:
[FIG(steps)[
= [82] If [VAR[entry]]'s [F[authors][entry's authors]] is not empty,
return [VAR[entry]]'s [F[authors][entry's authors]].
= [83] Otherwise, if [VAR[entry]]'s [F[feed][entry's feed]] is not null,
return [VAR[entry]]'s [F[feed][entry's feed]]'s [F[authors][feed's author]].
= [84] Otherwise, return an empty list.
]FIG]
[93] To get the [DFN[[F[computed updated]]]] of an [[entry]] [VAR[entry]], run these steps:
[FIG(steps)[
= [94] If [VAR[entry]]'s [F[updated][entry's updated]] is not [[null]],
return [VAR[entry]]'s [F[updated][entry's updated]].
= [97] Otherwise, if [VAR[entry]]'s [F[published][entry's published]] is not [[null]],
return [VAR[entry]]'s [F[published][entry's published]].
= [95] Otherwise, if [VAR[entry]]'s [F[feed][feed's entry]] is not null,
return [VAR[entry]]'s [F[feed][entry's feed]]'s [F[updated][feed's updated]].
= [96] Otherwise, return
@@ the current timestamp.
]FIG]
[29] A [DFN[person]] is a tuple of
[DFN[[F[name]]][person's name]],
[DFN[[F[email]]][person's email]], and
[DFN[[F[page URL]]][person's page URL]].
They are initially [[null]].
[30] A [DFN[category]] is a pair of
[DFN[[F[term]]][category's term]] and
[DFN[[F[label]]][category's label]].
[130] The [DFN[[F[link relation]]]] of a [CODE(XMLe)@en[link][atom:link]] element
in the [[Atom namespace]] [VAR[element]] is the value returned by the following steps:
[FIG(steps)[
= [131] If [VAR[element]] does not have a [CODE(XMLa)@en[rel]] attribute:
== [132] Return [CODE[http://www.iana.org/assignments/relation/alternate]].
= [134] Otherwise:
== [135] Let [VAR[rel]] be [VAR[element]]'s [CODE(XMLa)@en[rel]] attribute value.
== [136] If [VAR[rel]] contains a [CODE[:]] character:
=== [137] Return [VAR[rel]].
== [138] Otherwise:
=== [133] Return [CODE[http://www.iana.org/assignments/relation/]]
followed by [VAR[rel]].
]FIG]
[140] The [DFN[[F[href URL]]]] of a [CODE(XMLe)@en[link][atom:link]] element
in the [[Atom namespace]] [VAR[element]] is the value returned by the following steps:
[FIG(steps)[
= [141] Let [VAR[text]] be [VAR[element]]'s [CODE(XMLa)@en[href]] attribute value,
if any, or the empty string.
= [142] [[Parse][parse a URL]] [VAR[text]] relative to [VAR[element]]'s [F[node document]].
= [143] If failed, return [[null]].
= [144] Otherwise, return the [[resulting URL record]].
]FIG]
[1] To [DFN[process a feed response]] [VAR[res]], run these steps:
[FIG(steps)[
= [9] If [VAR[res]] is a [[network error]] or
[VAR[res]]'s [F[status][status code]] is not [CODE(HTTP)[200]],
return [[null]] and abort these steps.
= [2] Let [VAR[type]] be [VAR[res]]'s [F[computed MIME type]].
= [3] If [VAR[type]] is an [[XML MIME type]]:
== [7] Let [VAR[doc]] be a [CODE(DOMi)@en[Document]].
== [6] Let [VAR[parser]] be an [[XML parser]] associated with [VAR[doc]].
The [[XML parser]] [MUST[MUST]] implement [[XML5]].
It [MUST[MUST NOT]] [[fetch]] and process [[external entities][external entity]].
== [8] Run [VAR[parser]], using [VAR[res]]'s [F[body]] as its [F[input byte stream]].
The [CODE(MIME)@en[charset]] parameter value in the
[CODE(HTTP)@en[Content-Type]] [[header value]] of [VAR[res]], if any, is used as
the [[encoding label]] provided by the underlying transport.
== [11] Set [VAR[doc]]'s [F[address][document's address]] to
[VAR[res]]'s [F[url][response's URL]].
== [27] Set [VAR[doc]]'s [F[character encoding][document's character encoding]]
to the [[character encoding]] used by [VAR[parser]].
== [5] Return the result of [[processing a feed document][process a feed document]] [VAR[doc]].
= [4] Otherwise, return [[null]].
]FIG]
[10] To [DFN[process a feed document]] [VAR[doc]], run these steps:
[FIG(steps)[
= [12] Let [VAR[root]] be [VAR[doc]]'s [F[root element]].
= [17] Switch by [VAR[root]]:
[FIG(switch)[
: [16] If it is a [CODE(XMLe)@en[feed]] element in the [[Atom namespace]] :
Return the result of [[processing an Atom feed element][process a Atom feed element]] [VAR[root]].
: [23] If it is a [CODE(XMLe)@en[feed]] element in the [[Atom 0.3 namespace]] :
Return the result of [[processing an Atom 0.3 feed element][process a Atom 0.3 feed element]] [VAR[root]].
: [19] If it is an [CODE(XMLe)@en[rss]] element in the [[null namespace]] :
@@
: [18] If it is an [CODE(XMLe)@en[RDF]] element in the [[RDF namespace]] :
@@
: [13] Otherwise : Return [[null]].
]FIG]
]FIG]
[20] To [DFN[process an Atom feed element]] [VAR[element]], run these steps:
[FIG(steps)[
= [14] Let [VAR[feed]] be a [[feed]].
= [21] For each [[element]] [VAR[child]] in [VAR[element]]'s [F[children]], in order,
run these substeps:
== [22] Switch by [VAR[child]]'s [F[namespace]] and [F[local name]]:
[FIG(switch)[
: [CODE(XMLe)@en[icon]] element in the [[Atom namespace]] :
[FIG(steps)[
= [37] If [VAR[feed]]'s [F[icon URL][feed's icon URL]] is [[null]]:
== [35] Let [VAR[text]] be [VAR[child]]'s [F[child text content]].
== [36] [[Parse][parse a URL]] [VAR[text]] relative to [VAR[child]]'s [F[node document]].
== [38] If not failed, set [VAR[feed]]'s [F[icon URL][feed's icon URL]] to the [[resulting URL string]].
]FIG]
: [CODE(XMLe)@en[logo]] element in the [[Atom namespace]] :
[FIG(steps)[
= [40] If [VAR[feed]]'s [F[logo URL][feed's logo URL]] is [[null]]:
== [41] Let [VAR[text]] be [VAR[child]]'s [F[child text content]].
== [42] [[Parse][parse a URL]] [VAR[text]] relative to [VAR[child]]'s [F[node document]].
== [43] If not failed, set [VAR[feed]]'s [F[logo URL][feed's logo URL]] to the [[resulting URL string]].
]FIG]
: [CODE(XMLe)@en[title]] element in the [[Atom namespace]] :
[FIG(steps)[
= [44] If [VAR[feed]]'s [F[title][feed's title]] is [[null]]:
== [45] Set [VAR[feed]]'s [F[title][feed's title]] to the result of
[[processing an Atom text][process an Atom text]] [VAR[child]].
]FIG]
: [CODE(XMLe)@en[subtitle]] element in the [[Atom namespace]] :
[FIG(steps)[
= [46] If [VAR[feed]]'s [F[subtitle][feed's subtitle]] is [[null]]:
== [47] Set [VAR[feed]]'s [F[subtitle][feed's subtitle]] to the result of
[[processing an Atom text][process an Atom text]] [VAR[child]].
]FIG]
: [CODE(XMLe)@en[updated]] element in the [[Atom namespace]] :
[FIG(steps)[
= [48] If [VAR[feed]]'s [F[updated][feed's updated]] is [[null]]:
== [49] Set [VAR[feed]]'s [F[updated][feed's updated]] to the result of
[[processing an Atom date][process an Atom date]] [VAR[child]].
]FIG]
: [CODE(XMLe)@en[author]] element in the [[Atom namespace]] :
Append the result of [[processing an Atom person][process an Atom person]] [VAR[child]]
to [VAR[feed]]'s [F[authors][feed's author]].
: [CODE(XMLe)@en[entry]] element in the [[Atom namespace]] :
[FIG(steps)[
= [86] Let [VAR[entry]] be the result of [[processing an Atom entry][process an Atom entry]]
[VAR[child]].
= [85] Set [VAR[entry]]'s [F[feed][entry's feed]] to [VAR[feed]].
= [87] Append [VAR[entry]] to [VAR[feed]]'s [F[entries][feed's entry]].
]FIG]
: [CODE(XMLe)@en[link]] element in the [[Atom namespace]] :
[FIG(steps)[
= [139] If [VAR[child]]'s [F[link relation]] is
[CODE[http://www.iana.org/assignments/relation/alternate]]:
== [145] If [VAR[feed]]'s [F[page URL][feed's page URL]] is [[null]]:
=== [146] Set [VAR[feed]]'s [F[page URL][feed's page URL]] to
[VAR[child]]'s [F[href URL]].
= [150] Otherwise, if [VAR[child]]'s [F[link relation]] is
[CODE[http://www.iana.org/assignments/relation/self]]:
== [151] If [VAR[feed]]'s [F[feed URL][feed's feed URL]] is [[null]]:
=== [152] Set [VAR[feed]]'s [F[feed URL][feed's feed URL]] to
[VAR[child]]'s [F[href URL]].
]FIG]
]FIG]
= [25] Return [VAR[feed]].
]FIG]
[24] To [DFN[process an Atom person]] [VAR[element]], run these steps:
[FIG(steps)[
= [54] Let [VAR[person]] be a [[person]].
= [55] For each [[element]] [VAR[child]] in [VAR[element]]'s [F[children]], in order,
run these substeps:
== [56] Switch by [VAR[child]]'s [F[namespace]] and [F[local name]]:
[FIG(switch)[
: [CODE(XMLe)@en[name]] element in the [[Atom namespace]] :
If [VAR[person]]'s [F[name][person's name]] is [[null]],
set [VAR[person]]'s [F[name][person's name]] to [VAR[child]]'s [F[child text content]].
: [CODE(XMLe)@en[email]] element in the [[Atom namespace]] :
If [VAR[person]]'s [F[email][person's email]] is [[null]],
set [VAR[person]]'s [F[email][person's email]] to [VAR[child]]'s [F[child text content]].
: [CODE(XMLe)@en[uri]] element in the [[Atom namespace]] :
[FIG(steps)[
= [57] If [VAR[person]]'s [F[page URL][person's page URL]] is [[null]]:
== [58] Let [VAR[text]] be [VAR[child]]'s [F[child text content]].
== [59] [[Parse][parse a URL]] [VAR[text]] relative to [VAR[child]]'s [F[node document]].
== [60] If not failed, set [VAR[person]]'s [F[page URL][person's page URL]] to the [[resulting URL string]].
]FIG]
]FIG]
= [53] Return [VAR[person]]
]FIG]
[50] To [DFN[process an Atom text]] [VAR[element]], run these steps:
[FIG(steps)[
= [61] Let [VAR[type]] be the [CODE(XMLa)@en[type]] attribute value
of [VAR[element]], if any, or [[null]].
= [62] If [VAR[type]] is [CODE[html]]:
== [73] Let [VAR[div]] be a [CODE(HTMLe)@en[div]] element
whose [F[node document]] is [VAR[element]]'s [F[node document]].
== [74] Let [VAR[fragment]] be a [CODE(DOMi)@en[DocumentFragment]]
whose [F[node document]] is [VAR[element]]'s [F[node document]].
== [70] Let [VAR[nodes]] be the result of running the [[HTML fragment parsing algorithm]]
with [VAR[context]] element [VAR[div]] and
[VAR[input]] [VAR[element]]'s [F[child text content]].
== [71] For each item [VAR[node]] in [VAR[nodes]], in order,
[[insert]] [VAR[node]] into [VAR[fragment]].
== [72] Return [VAR[fragment]].
= [63] Otherwise, if [VAR[type]] is [CODE[xhtml]] and
[VAR[element]]'s [F[children]] contains a [CODE(HTMLe)@en[div]] element:
== [66] Let [VAR[div]] be a [[clone]] of [VAR[element]]'s
first [CODE(HTMLe)@en[div]] element child, with [VAR[clone children flag]] set.
== [67] Let [VAR[fragment]] be a [CODE(DOMi)@en[DocumentFragment]]
whose [F[node document]] is [VAR[element]]'s [F[node document]].
== [68] For each child [VAR[node]] in [VAR[div]]'s [F[children]], in order,
[[insert]] [VAR[node]] into [VAR[fragment]].
== [69] Return [VAR[fragment]].
= [64] Otherwise:
== [65] Return a [CODE(DOMi)@en[Text]] whose [F[data]] is the
[VAR[element]]'s [F[child text content]] and
whose [F[node document]] is [VAR[element]]'s [F[node document]].
]FIG]
[102] To [DFN[process an Atom content]] [VAR[element]], run these steps:
[FIG(steps)[
= [103] Let [VAR[type]] be the [CODE(XMLa)@en[type]] attribute value
of [VAR[element]], if any, or [[null]].
= [104] If [VAR[type]] is either [[null]], [CODE[text]], [CODE[html]], or [CODE[xhtml]]:
== [105] Return the result of [[processing an Atom text][process an Atom text]]
[VAR[element]] and abort these steps.
= [106] If [VAR[element]] has a [CODE(XMLa)@en[src]] attribute:
== [108] Let [VAR[text]] be [VAR[element]]'s [CODE(XMLa)@en[src]] attribute value.
== [109] [[Parse][parse a URL]] [VAR[text]] relative to [VAR[element]]'s [F[node document]].
== [111] If failed, return ([[null]], [[null]]) and abort these steps.
== [112] Return the [[resulting URL record]] and abort these steps.
= [110] Let [VAR[mime]] be the result of [[parsing][parse a MIME type]] [VAR[text]] as a [[MIME type]].
= [113] If [VAR[mime]] is an [[XML MIME type]]:
== [125] Let [VAR[fragment]] be a [CODE(DOMi)@en[DocumentFragment]]
whose [F[node document]] is [VAR[element]]'s [F[node document]].
== [126] For each child [VAR[node]] in [VAR[element]]'s [F[children]], in order,
[[insert]] [VAR[node]] into [VAR[fragment]].
== [127] Return [VAR[fragment]].
= [114] Otherwise:
== [117] Let [VAR[text]] be [VAR[element]]'s [F[child text content]].
== [123] If [VAR[mime]]'s [F[type]] is [CODE(MIME)@en[text][text/[VAR[*]]]]
([[ASCII case-insensitive]]):
=== [124] Return ([VAR[type]], [VAR[text]]).
== [115] Otherwise:
=== [118] Let [VAR[binary]] be the result of [[decoding base64][decode base64]] [VAR[text]].
=== [119] If [VAR[binary]] is [[null]]:
==== [120] Return ([[null]], [[null]]).
=== [121] Otherwise:
==== [122] Return ([VAR[type]], [VAR[binary]]).
]FIG]
;; [107] These steps return either
a [[URL record]],
pair ([[null]], [[null]]),
pair ([[MIME type]], [[string]]),
pair ([[MIME type]], [[byte sequence]]), or
a [CODE(DOMi)@en[Node]]. Note that a [[MIME type]] might or might not be a
[[parsible MIME type]].
@@ [116] Need to define [[decode base64]] [VAR[text]].
It returns [[null]] if failed.
[51] To [DFN[process an Atom date]] [VAR[element]], run these steps:
[FIG(steps)[
= [75] Let [VAR[text]] be [VAR[element]]'s [F[child text content]].
= [76] Return the result of [[parsing an RFC 3339 [CODE[xs:dateTime]] string][parse an RFC 3339 [CODE[xs:dateTime]] string]] [VAR[text]].
]FIG]
@@ [77] Need to define [DFN[parse an RFC 3339 [CODE[xs:dateTime]] string]].
It returns a number (JS timestamp) or [[null]].
[52] To [DFN[process an Atom entry]] [VAR[element]], run these steps:
[FIG(steps)[
= [78] Let [VAR[entry]] be an [[entry]].
= [79] For each [[element]] [VAR[child]] in [VAR[element]]'s [F[children]], in order,
run these substeps:
== [80] Switch by [VAR[child]]'s [F[namespace]] and [F[local name]]:
[FIG(switch)[
: [CODE(XMLe)@en[author]] element in the [[Atom namespace]] :
Append the result of [[processing an Atom person][process an Atom person]] [VAR[child]]
to [VAR[entry]]'s [F[authors][entry's author]].
: [CODE(XMLe)@en[category]] element in the [[Atom namespace]] :
[FIG(steps)[
= [89] Let [VAR[category]] a [[category]].
= [90] Set [VAR[category]]'s [F[term][category's term]] to the
[CODE(XMLa)@en[term]] attribute value of [VAR[child]], if any, or the empty string.
= [91] Set [VAR[category]]'s [F[label][category's label]] to the
[CODE(XMLa)@en[label]] attribute value of [VAR[child]], if any, or [VAR[category]]'s
[F[term][category's term]].
= [92] Append [VAR[category]] to [VAR[entry]]'s [F[categories][entry's categories]].
]FIG]
: [CODE(XMLe)@en[published]] element in the [[Atom namespace]] :
[FIG(steps)[
= [33] If [VAR[entry]]'s [F[published][entry's published]] is [[null]]:
== [34] Set [VAR[entry]]'s [F[published][entry's published]] to the result of
[[processing an Atom date][process an Atom date]] [VAR[child]].
]FIG]
: [CODE(XMLe)@en[updated]] element in the [[Atom namespace]] :
[FIG(steps)[
= [31] If [VAR[entry]]'s [F[updated][entry's updated]] is [[null]]:
== [32] Set [VAR[entry]]'s [F[updated][entry's updated]] to the result of
[[processing an Atom date][process an Atom date]] [VAR[child]].
]FIG]
: [CODE(XMLe)@en[title]] element in the [[Atom namespace]] :
[FIG(steps)[
= [98] If [VAR[entry]]'s [F[title][entry's title]] is [[null]]:
== [99] Set [VAR[entry]]'s [F[title][entry's title]] to the result of
[[processing an Atom text][process an Atom text]] [VAR[child]].
]FIG]
: [CODE(XMLe)@en[summary]] element in the [[Atom namespace]] :
[FIG(steps)[
= [100] If [VAR[entry]]'s [F[summary][entry's summary]] is [[null]]:
== [101] Set [VAR[entry]]'s [F[summary][entry's summary]] to the result of
[[processing an Atom text][process an Atom text]] [VAR[child]].
]FIG]
: [CODE(XMLe)@en[content]] element in the [[Atom namespace]] :
[FIG(steps)[
= [128] If [VAR[entry]]'s [F[content][entry's content]] is [[null]]:
== [129] Set [VAR[entry]]'s [F[content][entry's content]] to the result of
[[processing an Atom content][process an Atom content]] [VAR[child]].
]FIG]
: [CODE(XMLe)@en[link]] element in the [[Atom namespace]] :
[FIG(steps)[
= [147] If [VAR[child]]'s [F[link relation]] is
[CODE[http://www.iana.org/assignments/relation/alternate]]:
== [148] If [VAR[entry]]'s [F[page URL][entry's page URL]] is [[null]]:
=== [149] Set [VAR[entry]]'s [F[page URL][entry's page URL]] to
[VAR[child]]'s [F[href URL]].
]FIG]
]FIG]
]FIG]
@@
[26] To [DFN[process an Atom 0.3 feed element]] [VAR[element]], run these steps: