Appendices
A.1. Link Serialisation in HTML (HTML中的链接序列化)
HTML [W3C.REC-html5-20141028]定义了<link>元素用于传达链接。例如:
`<link rel="stylesheet" href="/style.css" type="text/css">`
HTML链接与本规范中定义的链接模型之间的对应关系如下:
- 链接上下文是包含链接元素的文档的URI
- 链接关系类型由"rel"属性的值标识
- 链接目标由"href"属性的值标识
- 目标属性由其他属性(如"type"、"media"等)表示
A.2. Link Serialisation in Atom (Atom中的链接序列化)
Atom [RFC4287]定义了一个链接元素,可以出现在feed和entry中。例如:
<link rel="alternate" type="text/html"
href="http://example.org/"/>
Atom链接与本规范中定义的链接模型之间的对应关系如下:
- 链接上下文是包含链接元素的feed或entry的URI
- 链接关系类型由"rel"属性的值标识
- 链接目标由"href"属性的值标识
- 目标属性由其他属性(如"type"、"hreflang"等)表示
Appendix B. Algorithms for Parsing Link Header Fields (解析Link头字段的算法)
本附录定义了解析Link头字段的算法。这些算法是规范性的。
B.1. Parsing a Header Set for Links (解析头集合以获取链接)
给定一组HTTP头字段headers:
- 让links为空列表
- 对于headers中的每个字段field,其字段名为"Link"(不区分大小写):
- 让field_value为field的字段值
- 让field_links为解析field_value的结果(使用B.2节中的算法)
- 将field_links中的每个链接添加到links
- 返回links
B.2. Parsing a Link Field Value (解析Link字段值)
To parse a Link field value, process the field value from left to right and produce zero or more link-values:
- Split the field value on commas that are not inside a quoted string.
- For each resulting link-value, remove leading and trailing optional whitespace.
- The link target MUST be enclosed in angle brackets. The characters between
<and>form the target URI reference. - Everything after the closing
>is interpreted as a semicolon-separated parameter list. - Parse that parameter list using the algorithm in Appendix B.3.
- If a parameter name occurs more than once and the parameter definition does not allow repetition, keep the first occurrence and ignore later occurrences.
- Return each parsed link with its target URI reference, relation type, and target attributes.
Commas and semicolons inside quoted strings do not delimit link-values or parameters. Backslash escaping in quoted strings is handled by Appendix B.4.
B.3. Parsing Parameters (解析参数)
To parse a parameter list:
- Split the parameter list on semicolons that are not inside a quoted string.
- Ignore an empty item produced by leading, trailing, or repeated semicolons.
- For each item, remove leading and trailing optional whitespace.
- The parameter name is the token before the first
=character. If no=is present, the parameter has an empty value. - Parameter names are compared case-insensitively.
- If the value starts with a double quote, parse it as a quoted string using Appendix B.4.
- Otherwise, the value extends to the end of the item after optional whitespace is removed.
- Store the parameter name and value as a target attribute for the current link-value.
The rel parameter identifies the link relation type. Extension relation types are URI references and registered relation types are tokens.
B.4. Parsing a Quoted String (解析带引号的字符串)
To parse a quoted string:
- The value begins with a double quote.
- Read characters until an unescaped double quote is found.
- When a backslash is encountered, append the following character to the output value and continue.
- Characters after the closing double quote are not part of the quoted-string value.
- If the closing double quote is absent, treat the value as invalid for this link-value.
This preserves quoted commas, semicolons, and other delimiter characters as data rather than syntax.
Appendix C. Changes from RFC 5988 (与RFC 5988的变化)
本规范与RFC 5988相比的主要变化包括:
- 澄清了链接上下文和链接目标的定义
- 更新了注册程序以使用RFC 8126
- 添加了解析算法(附录B)
- 澄清了扩展关系类型的使用
- 更新了对其他规范的引用
- 改进了示例和说明文本