基于配置文件的内容协商

W3C 工作草案

关于本文档的更多详细信息
此版本:
https://www.w3.org/TR/2026/WD-dx-prof-conneg-20260703/
最新发布版本:
https://www.w3.org/TR/dx-prof-conneg/
最新编辑草案:
https://w3c.github.io/dx-connegp/connegp/
历史:
https://www.w3.org/standards/history/dx-prof-conneg/
提交历史
测试套件:
https://github.com/w3c/prof-conneg-testing
实现报告:
https://w3c.github.io/dx-connegp/connegp-implementation-report/
编辑:
Lars G. Svensson 受邀专家,此前在 Deutsche Nationalbibliothek
Rob Atkinson Metalinkage,Open Geospatial Consortium
KurrawongAI,此前为 SURROUND Australia,再之前为 CSIRO
Mines Saint-Étienne,Institut Mines-Télécom
反馈:
GitHub w3c/dx-connegp拉取请求新建议题开放议题
public-dxwg-comments@w3.org ,主题行请填写 [dx-prof-conneg] … 消息主题 …归档
贡献者
Ruben Verborgh

摘要

本文档描述了互联网客户端如何可以基于内容所符合的 数据 配置文件,与服务器协商获取其提供的内容。这不同于按媒体类型或语言进行协商: 配置文件可以 指定返回信息的内容,这些内容可以是响应服务器拥有的关于所请求资源的信息的一个子集, 并且可以按特定方式组织,以满足某个实践社区的互操作性 要求。

本文档状态

本节描述了本文档在发布时的状态。当前 W3C 出版物列表以及本技术报告的最新修订版本可在 W3C 标准和草案 索引中找到。

本文档由 数据集交换工作组作为 工作草案发布,并使用 推荐标准 轨道

发布为 工作草案并不意味着获得 W3C 及其会员的认可。

这是一份草案文档,可能在任何时候被其他文档更新、替换或废弃。 除非作为进行中的工作,否则不应引用本文档。

本文档由一个 遵循 W3C 专利 政策运作的工作组制作。 W3C 维护着一个 公开的专利披露列表, 其中列出了与该工作组交付物相关的任何专利披露; 该页面还包含 专利披露说明。任何实际 知晓某项专利,并且认为该专利包含 必要权利要求的个人, 必须按照 W3C 专利政策第 6 节 披露该信息。

本文档受 2025 年 8 月 18 日 W3C 流程文档约束。

DXWG 关于配置文件的文档概览

本文档是一组关于配置文件的文档之一,由 W3C 数据集交换工作组(DXWG) 和互联网工程任务组(IETF)编辑。DXWG 文档包括:

以下文档由 IETF 主持维护,为本文档奠定技术 基础,但不属于 DXWG 的范围:

1. 引言

本节为非规范性内容。

通过解引用互联网标识符交付的内容,可以以不同 方式成为协商对象。使用 HTTP 协议 [RFC9110] 时,客户端可以设置一个或多个请求标头:

然而,客户端此前没有一种 已定义的方式来基于内容对某个信息模型的遵循情况来协商内容:该信息模型可以是标准、 规范配置文件。 本文档描述了如何提供此类功能。

当关于某个资源的在线信息遵循一个或多个配置文件时,此处描述的方法允许 客户端请求这些配置文件的列表,并按偏好顺序根据一个或多个配置文件请求内容。

例如,一个目录可以提供某个数据集描述的多种表示形式供选择,这些表示形式符合 不同的信息模型,例如 [VOID]、 [VOCAB-DATA-CUBE] 和 [VOCAB-DCAT]。此外,[VOCAB-DCAT] 表示形式可能符合 [DCAT-AP] 配置文件、 [GeoDCAT-AP] 配置文件,也可能符合某个组织专用的配置文件“MyOrgDCATProfile”。 这些范围更窄的配置文件会在它们所属的更一般规范之外,进一步约束数据集描述的各种元素。 对该数据集描述的可能表示形式信息的请求,可以 要求列出该数据集可用的配置文件列表,或者可以明确要求 符合某个特定配置文件的表示形式,例如 [GeoDCAT-AP]。 当未请求配置文件或请求了不受支持的配置文件时,服务器会返回符合服务器所支持 默认配置文件的默认内容。

在选择内容协商机制时,互联网客户端可以使用 HTTP 协议,但也可以 使用其他方法向服务器提供指令。一种潜在机制是 URL 查询字符串 参数(QSA)。QSA 对人和机器都很有用,适用于无法通过 HTTP 进行协商的情形,例如 手动在 Web 浏览器中输入请求时。本规范提供了一个 基于配置文件的内容协商抽象模型,并就两种符合该抽象模型的特定方法的使用提出指导, 即 HTTP 和 QSA

HTTP 标头和 URL QSA 方法被定义为抽象模型的功能 配置文件。 虽然本规范只描述这两个功能配置文件,但预期 实现者会希望为其他环境实现抽象模型的功能配置文件, 包括未来可能出现的环境。

实现者需要确保他们定义的任何功能配置文件 实现抽象模型的功能,并且能够按照备用表示数据模型 交付备用表示信息。

描述资源表示如何符合配置文件,以及配置文件和规范如何相互关联, 并不属于本规范的一部分。这些问题的某些方面由 Profiles Vocabulary [DX-PROF] 处理,它同样由 DXWG 制定。

2. 一致性

除标记为非规范性的章节外,本规范中的所有创作指南、图表、示例和注释 均为非规范性内容。本规范中的其他所有内容均为规范性内容。

本文档中的关键字 MAYMUSTMUST NOTRECOMMENDEDSHOULDSHOULD NOT 应按 BCP 14 [RFC2119] [RFC8174] 中的描述来解释,但仅当它们像此处所示那样以全 大写形式出现时才如此。

为了合规性目的,本文档的规范性章节为 3. 定义7. 抽象模型8. 功能配置文件10. 测试套件。 附录为非规范性内容。

资源表示的内容可能符合的规范和配置文件,会体现它们自身的一致性概念, 这些概念不在本规范范围内。

3. 定义

规范

一种比较基础;一个可用来评估其他事物的参照点。

来源:DCMI Metadata Terms [DCTERMS] 对 Standard 的定义。

数据规范

一种具有可由人和/或机器处理的表示形式的 规范,用于定义给定上下文中所用数据的内容和结构。

来源:DXWG 的审议。

功能规范

一种具有可由人和/或机器处理的表示形式的 规范, 用于定义某个应用在给定上下文中的行为。

来源:DXWG 的审议。

配置文件

一种 规范,它约束、扩展、组合其他规范,或者就其他规范的使用 提供指导或说明。

如果被配置文件化的规范是一种专门类型的规范,例如数据规范或 功能 规范,则该配置文件也将属于同一类型——数据配置文件或功能配置文件。

本《基于配置文件的内容协商》规范关注的是针对数据配置文件的协商, 并为实现此目标的不同方式指定了功能配置文件。 在本文档中,术语“profile”的大多数出现均指“data profile”。

数据配置文件

一种 数据规范,它约束、扩展、组合 其他数据规范,或者就其他数据规范的使用提供指导或说明。

此定义包括有时被称为“应用配置文件”“元数据配置文件”或 “元数据应用配置文件”的内容。

来源:DXWG 的审议。

功能配置文件

一种 功能规范,它约束、 扩展、组合 其他功能规范,或者就其他功能规范的使用提供指导或说明。

来源:DXWG 的审议。

客户端
为发送一个或多个 HTTP 请求而与 服务器建立连接的程序。 [RFC9110]
服务器
一种接受连接以服务 HTTP 请求,并发送 HTTP 响应的程序。 [RFC9110]
资源
由 URI 标识的实体。常见示例包括电子 文档、图像、具有一致目的的信息源。 [RFC3986]
表示

HTTP 通信中某个事物当前或期望状态的抽象。 [RFC9110]

在本规范中,表示属于 资源

元数据
关于某个资源所提供的信息。 [RFC3986]
请求
通过互联网从 客户端发送到 服务器的消息,用于请求有关 资源的信息。 [RFC9110]
响应
通过互联网从 服务器发送到 客户端的消息,用于应答针对 资源信息的 请求。 [RFC9110]
令牌
标识某物的短名称。在本文档的上下文中,令牌有时用于 标识配置文件

4. 命名空间

本规范中使用的完整命名空间和前缀集合见下表。

前缀 命名空间
altr http://www.w3.org/ns/dx/connegp/altr#
dcat http://www.w3.org/ns/dcat#
dcterms http://purl.org/dc/terms/
ex http://example.com/
owl http://www.w3.org/2002/07/owl#
prof http://www.w3.org/ns/dx/prof/
rdfs http://www.w3.org/2000/01/rdf-schema#
sdo https://schema.org/
skos http://www.w3.org/2004/02/skos/core#
xsd http://www.w3.org/2001/XMLSchema#

5. 动机

本节为非规范性内容。

在许多情况下,在单一媒体类型的范围内可以有多种方式来描述一个资源。 例如,XML 文档虽然符合 application/xml 媒体类型,但可能遵循 多个 DTD 或 XML Schema 中的一个。RDF 文档可以选择 text/turtleapplication/rdf+xml 等媒体类型序列化形式,并且有大量词汇表 (类和属性)可用于其内容的信息模型。当客户端发起对 某个互联网资源的请求(例如通过 HTTP GET 检索资源表示)时,客户端和服务器 必须有一种标准化方式来交换信息,说明所传输的资源 将如何按照 DTD、XML Schema、词汇表或其他标准、规范或 配置文件 进行结构化。 在使用非 HTTP 内容协商时,此前已经实现过带有查询字符串 参数的 URI 等方法, 例如 OAI-PMH [OAI-PMH] 和 OGCCSW [CSW] 协议。

本文档描述了一种基于抽象功能的基于配置文件内容协商规范,并 给出一个 HTTP 标头功能配置文件和两个基于查询字符串参数的功能配置文件, 用于在不同环境中实现该规范。查询字符串 方法既提供了“后备”(抽象规范的第二种非 HTTP 实现),以满足 数据集交换工作组章程(第 2.3 节)的要求, 也展示了抽象规范的功能配置文件,潜在的功能配置文件 实现者可以将其作为实现指导。

本抽象规范的其他查询字符串或基于 REST 的功能配置文件 被认为是可能的,但此处未作规定。一般而言,支持列出资源表示的 备用 配置文件并检索符合配置文件的资源表示的现有 API,也可以 通过实现本规范所要求的功能来支持并展示与本规范的一致性,就像 本文档中的功能配置文件所做的那样。

本节为非规范性内容。

内容协商 HTTP 标头的标准化属于 IETF 的职责范围。一份关于 在 HTTP 中指示和协商配置文件的互联网 草案的首个提案 [PROF-IETF] 已经可用,但尚未提交给 IETF。 当前版本的 IETF 草案(-00)预计将与 本文档的并行工作一起被完全重写,并且 在本文档删除此段之前,应将其视为进行中的工作。

7. 抽象模型

本节描述了一个用于基于配置文件进行内容协商的概念性——抽象——模型,它独立于 在特定环境中的任何 实现。

面向不同环境的此抽象模型实现称为 功能配置文件。 要成为有效的功能配置文件,它们 MUST 实现这些抽象模型 功能。 它们如何实现这些功能将取决于具体环境。

功能配置文件 MAY 在此抽象模型之上扩展其自身的附加特性, 但这些 附加内容 MUST NOT 使此处定义的功能失效。

此处给出了一个数据模型,用于描述符合不同数据配置文件的资源表示, 并且所有功能配置文件 MUST 使用该模型。该数据模型如何 实现由实现者 决定。这里不会详细处理已实现数据模型的一致性如何证明, 仅给出如下 指导:实现者 SHOULD 通过发布其备用 表示数据模型 实现中环境特定实现形式与本规范中给出的该模型的 某种具体实现形式之间的映射,来证明一致性,例如其 OWL 本体表示

7.1 内容协商背景

互联网上的所有内容协商都发生在一个 客户端和一个 服务器 之间: 前者通过 请求 请求某个 资源的表示,或某个 资源元数据, 并通过 响应接收所请求的表示。对于任何给定的一对通信 机器, 随着信息来回请求, 客户端服务器的角色可能会互换。

一个互联网 资源可能具有许多方面,可供一对 客户端/服务器代理 就内容进行协商。这些方面应当被独立处理,因此涉及按配置文件协商和按任何其他方面协商的 资源内容协商 不会相互影响。

在此抽象模型中,除定义一节 3. 定义中已经为这些术语提供的细节外,我们不假定关于 客户端服务器资源元数据请求响应的任何具体细节。

7.2 配置文件标识

请求符合某个 数据配置文件资源表示的 客户端 请求 MUST 使用统一资源标识符(URI) [RFC3986] 标识该 资源,并且 MUST 使用 URI 或 令牌标识该 配置文件

如果使用 URI 进行配置文件标识,则它 SHOULD 是一个 HTTP URI, 解引用后可得到该配置文件的描述。 也 MAY 使用其他种类的 URI,例如 URN,而这些 URI 可能不可 解引用。 如果使用令牌,则它 MUST 在一对 请求/响应消息中明确标识该 数据配置文件。 服务器 MUST 声明该令牌可以映射到某个 URI 的上下文。

7.3 请求和响应

关于基于配置文件的内容协商,客户端可能向 服务器发出的 请求主要有两种类型。希望通过符合本规范的配置文件来协商内容的 客户端 MUST 能够实现这两种请求类型:

  1. 列出配置文件
    客户端请求列出 服务器能够为其交付合规 资源 表示数据配置文件 URI 列表
  2. 按配置文件获取资源
    客户端请求所请求 资源的一个 表示, 该表示符合某个特定 配置文件

遵循本规范的 服务器 MUST 对每个请求作出以下相应 响应

  1. 列出配置文件
    服务器以其能够为之交付合规 资源 表示数据配置文件 URI 列表 响应 客户端
  2. 按配置文件获取资源
    服务器要么响应一个符合 客户端所标识的已请求 配置文件资源的特定 数据配置文件, 要么以默认 数据配置文件作出响应

这些请求及其响应的更详细描述如下。

7.3.1 列出配置文件

客户端希望知道 服务器能够为哪些 数据配置文件交付 资源的合规表示。配置文件列表可以在针对某个特定 资源表示的 请求发出之前已知,也可以只在发出初始 请求之后 才知道。

列出配置文件 请求 MUST 要么是独立请求, 要么是另一 功能配置文件请求的一部分。

列出配置文件 请求 MAY 产生一种 响应,其格式可以是多种格式之一,前提是资源 表示所符合的 数据配置文件 要么通过 URI,要么通过 令牌得到明确标识。 如果是后者,它 MUST 能够在某一个特定客户端/服务器消息对内 映射到 URI。

当给出指定某个 数据配置文件按配置文件获取资源 请求时,如果 服务器无法交付该配置文件,则它 MUST NOT 列出该 数据配置文件

示例 4 展示了一对符合 QSA 功能 配置文件的请求/响应消息,其中该请求是针对某个特定资源的 列出配置文件请求。

示例 4:简单的列出配置文件请求和响应消息(QSA 功能 配置文件)
# A request for all the profiles to which representations of resource a conform
GET /resource/a?_profile=alt HTTP/1.1

---

# The server returns a list of profiles both in its HTTP response header and also
# in the response body (HTML). Note that the action of returning the response message
# conforms to the QSA Functional Profile and this is indicated with the Link header
# combined with the "profile" relation
HTTP/1.1 200 OK
Content-Type: text/html
Link: <http://www.w3.org/ns/dx/connegp/profile/qsa>; rel="profile"
# This Link header indicates representations are available that conform to Profile X
# & Y and that the Profile X-conformant representations are available in HTML
# & XML Media Types.
Link:
  <http://example.org/resource/a?_profile=profile-x&_mediatype=text/html>;
          rel="canonical"; type="text/html";
          formats="http://otherexample.org/profile/x",
  <http://example.org/resource/a?_profile=profile-x&_mediatype=application/xml>;
          rel="alternate";
          type="application/xml";
          formats="http://otherexample.org/profile/x",
  <http://example.org/resource/a?_profile=profile-y&_mediatype=application/xml>;
          rel="alternate";
          type="application/xml";
          formats="http://otherexample.org/profile/y"

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Profiles for Resource A</title>
  </head>
  <body>
    <h1>Profiles available for Resource X</h1>
    <ul>
      <li><a href="?_profile=profile-x&_mediatype=text/html">X, in HTML</a></li>
      <li><a href="?_profile=profile-x&_mediatype=application/xml">X, in XML</a></li>
      <li><a href="?_profile=profile-y&_mediatype=application/xml">Y, in XML</a></li>
    </ul>
  </body>
</html>

7.3.2 按配置文件获取资源

基于配置文件内容协商的最基本 请求是: 客户端 请求 一个声称符合某个 数据配置文件资源表示。

执行按配置文件获取资源 请求客户端 MUST 使用 URI 或会在会话内明确映射到 URI 的令牌来标识该 数据配置文件

执行按配置文件获取资源客户端 MAY 请求 符合任意数量 数据配置文件之一的 资源表示,并以功能配置文件特定的顺序表达其偏好。

服务器 SHOULD 尝试以最匹配客户端请求的配置文件进行回复。 服务器为确定最匹配配置文件而 MUST 遵循的偏好 顺序是:先精确匹配,然后是该资源表示所符合的下一个最具体的配置文件。 注意,资源 表示可能通过某种层次结构(即传递地)符合更一般的规范或其他配置文件。

如 [RFC9110] 所规定,如果在指定 profile、媒体类型或其他协商维度偏好的请求中使用 HEAD 方法,则响应应与 GET 方法的响应相同, 包括标头和状态码,但正文 MUST 为空。需要注意的是, 只有在生成响应内容时才能确定其值的标头 MAY 被省略。

如果服务器重定向到另一个资源,它 MUST 指示从客户端所请求列表中 选定的配置文件,并且 SHOULD 在重定向请求(303 响应)中 指示预期将返回的某个更窄的具体配置文件(如果已知)。

: 重定向到另一个资源
由于按配置文件获取资源请求是针对 资源表示,并且 具有符合配置文件表示的资源可能不是信息资源,因此需要 注意,服务器的响应可以采用重定向到另一个资源的形式。这符合 W3C 关于处理 所谓“httpRange-14”问题的建议。重定向响应的示例见 示例 6

示例 5 展示了一个根据 HTTP 标头功能配置文件包含 Accept-ProfileLink: rel="profile" 标头的简单请求/响应消息对; 示例 6 展示了带重定向的示例。 示例 7 展示了一个 HTTP 标头功能配置文件消息对,表明响应使用了 比请求配置文件更窄的配置文件。

示例 5: 简单的按配置文件获取资源请求和响应(HTTP 标头功能 配置文件)
# A request for resource a according to Profile x is made
GET /resource/a HTTP/1.1
Accept-Profile: <http://example.org/profile/x>

---

# The server returns a representation of Resource a conforming with Profile x
HTTP/1.1 200 OK
Link: <http://example.org/profile/x>; rel="profile"

[response body]
示例 6: 带 303 重定向的按配置文件获取资源请求和响应(HTTP 标头功能 配置文件)
# A request for a non-information resource a according to Profile x is made
GET /resource/a HTTP/1.1
Accept-Profile: <http://example.org/profile/x>

---

# The server returns a 303 Redirect to another URI identifying an information
# resource that then returns the requested resource representation. The redirecting
# server indicates the profile to which the redirected to resource representation
# conforms
HTTP/1.1 303 See Other
Location: http://example.org/info-resource/b
Link: <http://example.org/profile/x>; rel="profile"

---

# The client now requests the indicated information resource. Note that the
# Accept-Profile header is no longer needed since the original response has
# catered for that in the redirect response
GET /info-resource/b HTTP/1.1

---

# The final server response with the information resource. Note that this
# response does not include the profile-indicating Link rel="profile" header
HTTP/1.1 200 OK

[response body]
示例 7:按配置文件获取资源时,以一个合规且更窄的 配置文件进行响应(HTTP 标头功能配置文件)
# A request for Resource A whose representation conforms
# to Profile X is made

GET /resource/a HTTP/1.1
Accept-Profile: <http://example.org/profile/x>
[more request headers]

---

# The server is able to respond with a representation of
# Resource a according to Profile Y which it knows is a
# profile of Profile X

# The server responds with the list of profiles that it knows
# the resource representations conforms to ensuring that the
# requested profile, Profile X, is listed. Here Profile Y and
# a further profile irrelevant for the client, Profile Z, are
# indicated.

HTTP/1.1 200 OK
[other response headers]
Link: <http://example.org/profile/x>; rel="profile", \
      <http://example.org/profile/y>; rel="profile", \
      <http://example.org/profile/z>; rel="profile"
[more response headers]

[content conforming to to Profile X, Y & Z]

当返回的资源符合两个或更多不属于同一配置文件层次结构的配置文件时 (即该资源符合一组配置文件,但其中一些彼此独立,并非该集合中其他配置文件的 特化 配置文件),服务器 SHOULD 指示其符合每个独立配置文件。

例如,使用 HTTP 标头功能配置文件时,来自某个服务器的响应同时符合 [GeoDCAT-AP] 和 [STATDCAT-AP], 鉴于二者互不配置文件化,因此没有单一的一致性指示可以同时涵盖二者, (注意它们 都确实配置文件化了 [DCAT-AP],参见 [DX-PROF] 中的 DCAT-AP 层次结构 示例),那么使用 [GeoDCAT-AP] 和 [STATDCAT-AP] 的配置文件 URI 的响应可以是:

Link: <https://joinup.ec.europa.eu/release/geodcat-ap-v10>; rel="profile", <https://joinup.ec.europa.eu/release/statdcat-ap/101>; rel="profile"

7.4 备用 表示数据模型

此数据模型 MUST 用于描述符合不同 配置文件的资源表示。

1 给出了该模型的图形化概览。

Alternate Profiles data model
1 使用 OWL 实现的 Alternate Profiles 数据模型图 [OWL2-OVERVIEW]。

符合不同配置文件的资源备用表示描述 MAY 根据实现此模型的建模系统来呈现, 具体取决于被认为与创建本规范所针对的应用配置文件 相关的内容。例如, HTTP 应用配置文件(8.2 超文本传输协议标头)受限于 [RFC9110] 中 HTTP 规范标头结构约束内的文本, 因此在该环境中对此数据模型的语法通信 必须根据其约束来实现。

用于测试数据实例对该数据模型某些实现的一致性的工具见 10. 测试套件。关于该数据模型的具体实现和扩展, 以及在预期情形中的使用建议,见 A.4 备用表示数据模型 - 详细信息。该附录中还给出了 建议用法的示例。

7.5 实现配置文件的 优先顺序

服务 MAY 实现多个 功能 配置文件,包括 HTTP、QSA 以及可能的其他 方法。 在这种情况下,客户端可以通过不同机制指定相互冲突的选择,例如一种常见 情况是 客户端发送默认标头,但要求某个特定表示。 此处定义的优先顺序决定了必须使用哪种机制。

优先顺序为 QSA 高于 HTTP。 其依据是 URI 越精确地指向某个资源, 代理就越有可能意图请求该精确资源, 无论该请求随带发送了哪些 HTTP 标头。

如果定义了抽象模型的其他潜在冲突功能配置文件,则需要 建立优先顺序。这里没有提出如何声明这一点的具体机制。

8. 功能配置文件

8.1 本规范的功能配置文件

本节为不同系统环境定义本 规范抽象模型功能配置文件。也可以定义其他配置文件, 并且符合抽象模型的任何配置文件的一致性,都满足 本规范的一致性。

本规范为两种环境提供抽象模型的功能配置文件:HTTP 标头 和人类浏览器(URL 查询字符串 参数)。

此外,资源表示描述 (cnpr:rrd)配置文件可用于声明 服务器将指示服务器对 GetResource 请求的响应符合哪些配置文件。

对于人类浏览器环境,本文给出两个功能配置文件,以展示不同的使用模式。 本规范的其他功能配置文件 MAY 针对其他环境,或者甚至针对 这些环境中的受限场景来实现,并鼓励实现者创建符合本 规范的附加配置文件。

此处预定义的本规范功能配置文件列于 2。 它们的命名空间前缀为:

URI 名称 描述 使用说明
cnpr:http HTTP 标头功能配置文件 用于符合 8.2 超文本传输协议 标头中给出的功能配置文件。 当资源符合 HTTP 标头功能配置文件时使用
cnpr:qsa QSA 功能配置文件 用于符合 8.3 URL 查询字符串参数中给出的功能配置文件。 当资源符合 URL QSA 功能配置文件,并按照 8.3 URL 查询字符串 参数中的建议使用查询字符串 参数 _profile_mediatype 时使用。
cnpr:qsa-alt QSA 备用关键字功能配置文件 用于符合 8.3 URL 查询字符串参数中给出的功能配置文件。 当资源符合 URL QSA 功能配置文件,但按 8.3 URL 查询字符串参数中的建议所允许, 对查询字符串参数 _profile_mediatype 使用备用关键字时使用。
cnpr:rrd 资源表示描述 用于符合 7.3.2 按配置文件获取资源 当资源表示能够按照 7.3.2 按 配置文件获取资源中的抽象规范,指示其符合哪些配置文件时使用。
2 基于配置文件的内容协商规范的配置文件,供资源 和系统用于指示其符合该规范的一种或多种形式。

用于上述功能配置文件的命名空间 http://www.w3.org/ns/dx/connegp/profile/ 是数据集交换工作组保留的 W3C 命名空间 http://www.w3.org/ns/dx/ 的一部分,该命名空间为与 该工作组所处理问题相关的所有命名空间需求而预留。/profile/ 路径段 表示一个配置文件对象登记表,目前仅包含 2中的上述 4 个实例。

8.2 超文本传输 协议标头

此处给出了一个使用超文本传输协议(HTTP)标头的抽象模型功能配置文件。 该实现基于 HTTP 内容协商,并使用以 特定方式构造的 Link 标头,以及一个新的 HTTP 标头 Accept-Profile;后者将在即将发布的 互联网草案 [PROF-IETF] 中定义。

:POST/PUT 不在 范围内

POST 和 PUT 方法被认为不在此功能配置文件的范围内。目前尚不清楚 这些 HTTP 方法会实现所提议抽象模型中的哪些功能。

可以在 POST 和 PUT 请求中指定带有 rel="profile"Link 标头,以传达 请求消息内容的一致性。

尽管服务器可以自由地按其认为合适的方式实现协商, 但如果用户代理发送了 Accept-Profile 标头, 它们 SHOULD 将不符合任何所列配置文件的表示 视为客户端不可解释。 这意味着,一个符合所列配置文件的表示, 即使在其他维度上的偏好分数较低, 也 SHOULD 被认为比 一个在其他维度上偏好分数更高、 但不符合任何所列配置文件的表示更受期望。 如果未给出 Accept-Profile 标头偏好, 则在协商目的下 SHOULD 忽略 profile 维度。 不过,在所有情况下, 服务器响应 SHOULD 包含一个 带有 rel="profile"Link 标头, 列出它所知该表示符合的所有配置文件的 URI。

8.2.1 列出配置文件

检索服务器针对特定资源所支持配置文件列表的首选方式, 是对该资源发出 GETHEAD 请求。 在任一情况下,实现 基于配置文件的内容协商的服务器 SHOULD 返回一个 HTTP Link 标头,其中包含关于该 资源的默认表示和任何备用表示的信息, 包括它们所符合的配置文件。默认表示——即在未请求特定表示时 将返回的表示—— SHOULDrel="canonical" 标识,其他表示 由 rel="alternate" 标识。

例如,考虑资源 http://example.org/resource/a,它可用的媒体类型包括 application/xmltext/htmltext/turtletext/html 表示 没有配置文件,而 application/xmltext/turtle 表示 均可用于配置文件 urn:example:profile:xurn:example:profile:y

假设没有 Accept-Profile 标头的请求默认交付 符合 urn:example:profile:x 的内容,则 HTTP 请求/响应对会如 示例 8 所示。

示例 8中,对于每一种不同的 媒体类型 / 配置文件组合, 资源的 URI 保持不变,改变返回响应的是分别用于 媒体类型和配置文件的 AcceptAccept-Profile 标头。

服务器 MAY 使用 Content-Location HTTP 标头来指示 按媒体类型 / 配置文件组合得到的资源表示的直接链接; 如果这样做,它可以按照示例 ,用这些直接 URI 替换 Link 标头中 不变的 URI。

8.2.1.1 HTTP 备用表示数据模型实现

功能配置文件实现需要确保,除了实现抽象 模型的功能外,它们还能够按照备用 表示 数据模型交付备用表示信息。在此 HTTP 标头功能配置文件中, 为此选择的机制是 Links 标头(来自 [RFC8288]),如下所述。

HTTP Link(来自 [RFC8288])是“两个资源之间的 类型化连接,并由以下部分组成”:

  • 一个链接上下文
  • 一个链接目标
  • 一个链接关系类型,以及
  • 可选的目标属性

链接上下文是正在为其交付 Link 标头的资源。 关系类型rel 属性键名给出,链接目标是一个 URI, 其他可选 目标属性可以包括 profile,以 profile 属性键名给出。

示例 9中,针对 链接上下文 resource/a 的请求返回的 Link 标头第一部分 包含以下部分:

  • 链接目标 - <http://example.org/resource/a.prof1.ttl>
  • 关系类型 - rel="canonical"
  • 目标属性 - type="text/turtle"formats="urn:example:profile:x"

使用这些 Link HTTP 标头部分,此 HTTP 标头功能配置文件能够按照 备用配置文件数据 模型来传达资源的备用数据配置文件,并且下方 3 将标头部分映射到该数据模型的 OWL 本体表示,这是一种具体且正式的实现形式。 此映射的给出遵循 7. 抽象模型中的指令: “实现者 SHOULD 通过发布其备用 表示数据模型 实现的环境特定实现形式与本规范中给出的该模型的具体实现形式 之间的映射,来证明一致性,例如其 OWL 本体 表示。

8.2.1.2 令牌映射

如果 HTTP 服务器希望允许 客户端通过 令牌来标识 配置文件, 除了通过 URI 强制标识 配置文件外, 服务器 SHOULD 为每个受支持的令牌指示其对应的配置文件 URI。 在实现本规范的 HTTP 标头功能配置文件时, 服务器 MUST 在其响应中为每个 profile URI/token 对包含一个 Link 标头([RFC8288])。 每个 Link 标头 MUST 使用 Link Target "http://www.w3.org/ns/dx/prof/Profile" 并且 MUST 包含以下 Target Attribute

目标属性 目标属性值
rel "type"
token 映射到 anchor 属性中配置文件 URI 的令牌
anchor 映射到 token 属性中令牌的配置文件 URI

示例 11 给出了用于传达 token/URI 映射的 Link 标头示例。

示例 11:使用 Link 属性“token”将配置文件 URI 链接到 令牌
# The profile URI in the "anchor" element is linked to the token "igsn-r1"

# Further, the relation "type" is used to inform
# that the anchor resource is of type "dcterms:Standard"

Link: <http://www.w3.org/ns/dx/prof/Profile>;
  rel="type";
  token="igsn-r1";
  anchor=<http://schema.igsn.org/description/1.0>

服务器 MAY 在 token/URI 映射旁边向 Link 标头添加更多属性, 例如备用表示数据模型内容。 示例 12 展示了带有多个属性的 Link 标头中的令牌。

示例 12:使用“token”参数进行配置文件 URI / 令牌映射的 HTTP 标头
# The Profile with URI urn:example:profile:marc21-dnb is mapped to the token "dnb"
# and the Profile with URI http://example.org/profiles/marc21-loc is mapped to the token "loc"

HEAD /resource/a HTTP/1.1
Accept: text/turtle
[more request headers]

---

HTTP/1.1 200 OK
Content-Type: text/turtle
Content-Location: http://example.org/resource/a.profx.ttl
Link: <urn:example:profile:x>; rel="profile"
Link:
  <http://www.w3.org/ns/dx/prof/Profile>; rel="type"; token="dnb"; anchor=<urn:example:profile:marc21-dnb>,
  <http://www.w3.org/ns/dx/prof/Profile>; rel="type"; token="loc"; anchor=<http://example.org/profiles/marc21-loc>,
  <http://example.org/resource/a.profdnb.ttl>; rel="canonical"; type="text/turtle"; formats="urn:example:profile:marc21-dnb",
  <http://example.org/resource/a.profloc.ttl>; rel="alternate"; type="text/turtle"; formats="http://example.org/profiles/marc21-loc",
  <http://example.org/resource/a.profdnb.xml>; rel="alternate"; type="application/xml"; formats="urn:example:profile:marc21-dnb",
  <http://example.org/resource/a.profloc.xml>; rel="alternate"; type="application/xml"; formats="http://example.org/profiles/marc21-loc",
  <http://example.org/resource/a.html>; rel="alternate"; type="text/html"
[more response headers]

8.2.2 按配置文件获取资源

获取符合特定配置文件的资源表示,是通过针对该资源发出 HTTP GET 请求,并在 Accept-Profile 标头中指定 所需的配置文件 URI 来完成的。

实现基于配置文件内容协商的服务器 MUST 使用包含 一个 Link 标头的 HTTP 响应标头作出响应, 该标头带有 rel="profile",指示返回的配置文件。

请求和响应中的 URI 均 MUST 用尖括号 “<”和“>”括起来。

可以提供一组可接受的配置文件 URI;如果提供,则它们 MUST 由逗号分隔, 或者位于单独的 Accept-Profile 标头中。

客户端 MAY 使用质量指示符 (q 值)作为排序机制来指示偏好,该指示符 与 URI 之间用分号“;”分隔。带 q 值的 URI(本例中为 URN)的示例是 <urn:example:profile:x>;q=1.0,,其中 URI 为 <urn:example:profile:x>,q 值为 q=1.0

示例 13 展示了一个针对 资源 /resource/a 的简单请求,该请求偏好按 URI(本例中为 URN)urn:example:profile:xurn:example:profile:y 标识的配置文件生成表示,其中“q”值表示对前者的更高偏好。 服务器返回的响应通过在带有 rel="profile"Link HTTP 标头中包含 该标识符,指示其符合 urn:example:profile:x

示例 13: 使用 HTTP 标头请求符合特定配置文件的资源表示
GET /resource/a HTTP/1.1
Accept: text/turtle;q=0.8, application/xml;q=0.5
Accept-Profile: <urn:example:profile:x>;q=1.0,<urn:example:profile:y>;q=0.6
[more request headers]

---

HTTP/1.1 200 OK
Content-Type: text/turtle
Link: <urn:example:profile:x>; rel="profile"
[more response headers]

在执行内容协商并返回资源表示后,RECOMMENDED 服务器还包含一个 Link 标头,指示以其他媒体类型编码并符合其他配置文件的备用资源 的可用性,如 8.2.1 列出配置文件所述。

8.3 URL 查询字符串参数

8.3.1 QSA 功能配置文件描述

虽然 HTTP 标头功能配置文件的配置文件协商方式支持完全自动化的 基于配置文件的内容协商,但本规范的动机用例包括人类可操作的协商。 此外,如 6. 相关工作中所述,以往和 现有系统已经允许通过多种手段进行人类可操作的 基于配置文件内容协商。

为了既允许人类可操作的基于配置文件内容协商,又展示与 现有系统类似的机制如何满足本规范抽象模型的所有方面,本节 展示了一个抽象 模型的查询字符串参数(QSA)功能配置文件。 该功能配置文件在功能上等价于 HTTP 标头功能配置文件,因为抽象模型所要求的所有功能均受支持; 但它并不与 HTTP 或任何其他功能配置文件相互排斥:本规范的一个实现可以 同时符合其多个功能配置文件,以便在多个环境中或在同一环境中以不同方式实现 基于配置文件的内容协商功能。

不同于 HTTP 标头功能配置文件(它也是一个独立 IETF 文档的主题 [PROF-IETF]), QSA 功能配置文件在此处完整规定。 本文给出了此 QSA 方法的两种形式:第一种是 固定关键字“QSA 功能配置文件”,第二种是 “QSA 备用关键字功能配置文件”,根据后者, 服务器可以实现其选择的任意关键字。这些不同的功能配置文件 均在 8.1 本规范的功能配置文件中标识。

一个系统对这些功能配置文件中的任一个或多个的一致性,可以按照 A.3 演示系统对功能配置文件的一致性来证明。注意,并不 要求系统(例如服务器)指示 其符合本规范中描述的一个或多个功能配置文件,因为并非所有系统都会 这样做。系统也可以通过多种方式展示对 功能配置文件的一致性,例如服务目录中的带注释条目。
8.3.1.1 QSA URI 描述

查询字符串是 URL 的一部分,用于为指定参数赋值。QSA 通常由人类在 Web 浏览器中使用,也用于其他 客户端/服务器场景中, 用于向 服务器传递额外信息。查询字符串键/值对通过 问号符号 ? 与 URI 的方案、授权部分和路径分隔, 并由用等号 = 连接的键/值对组成,各个键/值对之间由与号 & 分隔,如 [RFC3986] 所述。

示例 14 展示了一个使用 QSA 实现基于配置文件内容协商的资源请求 URI。

示例 14:使用 QSA 实现基于配置文件内容协商的资源请求 URI 示例
http://example.com/path/to/resource/a?_profile=prof-01

示例 14中,请求的资源表示所用配置文件由 令牌 prof-01 指示,该令牌 MUST 作为查询字符串参数追加到资源 URI。 按照本规范 7.3.1 列出 配置文件的许可,此处使用 令牌来标识 配置文件——prof-01——但该令牌 MUST 能够在某个特定 客户端/服务器会话中映射到 URI,相关机制如下所述。

可以通过使用附加 QSA 或 任何其他技术(例如 HTTP 标头)在此类 URI 中包含内容协商的其他方面; 但如果包含这些内容,它们 MUST NOT 改变 基于配置文件内容协商请求的行为。为了展示一种可接受的包含方式,如果 使用 示例 14 中 URI 的客户端希望指示其偏好请求内容 按 Turtle [TURTLE] 规范序列化为 RDF, 它可以使用 IANA 媒体类型列表中 Turtle 的令牌,即 text/turtle,并按 示例 15 构造 URI,这符合 URI 构造要求 [RFC3986]。

示例 15:包含基于配置文件和媒体 类型内容协商的 QSA URI 示例
http://example.com/path/to/resource/a?_profile=prof-01&_mediatype=text/turtle
: URL 的最大长度
如果查询字符串参数使用 URI(或 URL)来传达重要信息,实现者 应确保 包含使用 URI/URL 的 QSA 的完整请求 URI 的总长度不超过 长度限制。[RFC9110] 的 §4.1 建议 发送方和 接收方支持至少 8,000 个八位字节的请求行。然而,一些客户端和服务器 实现不能接受超过 2,000 个字符的 URL,例如 Sitemap 协议中 URL 的长度限制为 2,048 个字符。关于 URL 长度相关问题的更长讨论,可参见 Stack Overflow 上的这个问题
8.3.1.2 键命名

本规范包含两个不同的功能配置文件,供使用查询 字符串参数的人类客户端使用;它们根据 QSA 键命名要求而区分。两个 配置文件分别是“QSA 功能配置文件”和“QSA 备用关键字功能配置文件”,前者 是后者的一个配置文件。这是因为前者关于如何实现本规范所要求功能的 一致性规则更加严格 (“更窄”的规则)。 这些功能配置文件在 8.1 本规范的功能配置文件中标识和定义。

为符合“QSA 功能配置文件”,QSA_profile MUST 用于指示 配置文件令牌或 URI,而键 _mediatype SHOULD 用于 指示资源表示的媒体 类型。

当符合“QSA 备用 关键字功能配置文件”时,可以使用 [RFC3986] 规范中可接受的任何键值 来指示所需配置文件。 然而,符合该功能配置文件的服务器还 MUST 提供一种机制,允许客户端 发现所使用的值,如下文 8.3.4 QSA 键发现中详述。

8.3.2 列出配置文件

为符合“QSA 功能配置文件”, 服务器 SHOULD 支持 _profile QSA 键, 以允许 客户端发出列出配置文件 请求。对于此 请求,SHOULD 使用保留令牌 alt,例如 _profile=alt

为符合“QSA 备用关键字功能 配置文件”,可以使用其他键/值对 MAY,例如 _view=alternates,但实现服务器随后 MUST 提供 一种发现该键的方法, 如 8.3.4 QSA 键发现所述。

服务器列出 配置文件 请求响应 SHOULD 是呈现它所支持的、可用于该资源表示的所有配置文件列表, 并且可选地也呈现这些表示所支持的媒体类型。

服务器 SHOULD 按照 HTTP 标头功能配置文件 (使用 Link 标头),在 响应的 HTTP 标头中表示备用配置文件信息; 并且它 MAY 也在响应正文中表示该信息,以替代资源的默认配置文件表示。 允许正文内容的目的是让人类 能够在 Web 浏览器中轻松阅读资源的备用符合配置文件表示选项, 而不必查看较低层级的 HTTP 信息。

当服务器确实在 HTTP 正文中提供备用配置文件信息时,服务器 MAY 允许客户端 使用与下方按配置文件获取资源功能相同的媒体类型协商方法, 协商响应的特定媒体类型。

一个用于请求以 JSON 格式将某 资源的备用配置文件表示 作为 HTTP 正文内容以及 HTTP 标头内容交付的 请求示例可以如 示例 16

示例 16:通过 QSA 请求“列出配置文件”,同时返回 HTTP 标头和正文响应
GET /resource/a?_profile=alt&_mediatype=application/json HTTP/1.1

---

# The response shows that representations of the resource can be delivered according
# to two profiles identified by the tokens profile-x & profile-y
# and that profile-x-conformant representations are available in XML & JSON
# where as profile-y-conformant representations are only available in XML

# The content in the JSON body of the response is equivalent to that of the Link header
# and can easily be mapped to the Alternate Representations Data Model, just as the Link
# information is in Figure 3.

# Both the Link header and the JSON body include profile URI/token mappings

HTTP/1.1 200 OK
Content-Type: application/json
Link: <http://www.w3.org/ns/dx/connegp/profile/qsa>; rel="profile",
      <http://example.org/resource/a?_profile=profile-x&_mediatype=application/json>;
          rel="canonical";
          type="application/json";
          formats="http://otherexample.org/profile/x",
      <http://example.org/resource/a?_profile=profile-x&_mediatype=application/xml>;
          rel="alternate";
          type="application/xml";
          formats="http://otherexample.org/profile/x",
      <http://example.org/resource/a?_profile=profile-y&_mediatype=application/xml>;
          rel="alternate";
          type="application/xml";
          formats="http://otherexample.org/profile/y"

{
    "resource": "http://example.org/resource/a",
    "profiles": [
        {
            "token": "profile-x",
            "uri": "http://otherexample.org/profile/x",
            "media_types": ["application/json", "application/xml"]
        },
        {
            "token": "profile-y",
            "uri": "http://otherexample.org/profile/y",
            "media_types": ["application/xml"]
        }
    ]
}
8.3.2.1 QSA 备用 表示数据模型实现

按照 QSA 功能配置文件实现本规范的实现 MUST 按照备用表示数据模型传达其 备用表示信息。它们 MAY 按照 HTTP 标头功能配置文件使用 HTTP Link 标头来实现,也 MAY 使用其他方式。

如 [RFC8288](Web Linking)引言中所述,HTML 和 一些其他数据模型具有 “定义良好的链接概念”,因此 QSA 实现者 MAY 通过 HTTP 正文内容来实现备用 表示数据模型信息的传达,可能采用 HTML 或其他数据 模型/格式。这可以帮助使用 QSA 实现的人类 客户端 用户,使其可在 Web 浏览器中或在可下载文件中看到这些信息。

示例 10Link 标头信息的一种可能 HTML 表达,见下方 示例 17。注意,上方的 示例 16 给出了根据备用 表示数据模型对 Link 标头信息进行 JSON 格式表达的一种可能形式。

示例 17:上一示例中 Link 标头信息的 HTML 表达
# Link headers from previous example with one altered to show Blank Node v.
# absolute URIs for altp:Representation class instance
# (<http://example.org/resource/a>; → <http://example.org/resource/different>;)
Link:
  <http://example.org/resource/a>;
          rel="canonical";
          type="text/turtle";
          formats="urn:example:profile:x",
  <http://example.org/resource/a>;
          rel="alternate";
          type="text/turtle";
          formats="urn:example:profile:y",
  <http://example.org/resource/a>;
          rel="alternate";
          type="application/xml";
          formats="urn:example:profile:x",
  <http://example.org/resource/different>;
          rel="alternate";
          type="application/xml";
          formats="urn:example:profile:y",
  <http://example.org/resource/a>;
          rel="alternate";
          type="text/html"

# Link headers above represented HTML, assuming the Alternate Profile's rdfs:Resource
# is known from the request that generated this response and not given in the HTML
# content
<h3>Alternate Representations</h3>
<table>
  <thead>
    <tr>
      <th>Link to Representation</th>
      <th>Profile</th>
      <th>Media Type</th>
      <th>Is Default?</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a href="?_profile=x">Profile X, RDF</a></td>
      <td><code>urn:example:profile:x</code></td>
      <td><a href="https://w3id.org/mediatype/text/turtle">RDF (turtle)</a></td>
      <td>yes</td>
    </tr>
    <tr>
      <td><a href="?_profile=y&_mediatype=text/turtle">Profile Y, RDF</a></td>
      <td><code>urn:example:profile:y</code></td>
      <td><a href="https://w3id.org/mediatype/text/turtle">RDF (turtle)</a></td>
      <td>-</td>
    </tr>
    <tr>
      <td><a href="?_profile=x&_mediatype=application/xml">Profile X, XML</a></td>
      <td><code>urn:example:profile:x</code></td>
      <td><a href="https://w3id.org/mediatype/application/xml">XML</a></td>
      <td>-</td>
    </tr>
    <tr>
      <td><a href="http://example.org/resource/different?_mediatype=application/xml">Profile Y, XML</a></td>
      <td><code>urn:example:profile:y</code></td>
      <td><a href="https://w3id.org/mediatype/application/xml">XML</a></td>
      <td>-</td>
    </tr>
    <tr>
      <td><a href="?_mediatype=text/html">No Profile, HTML</a></td>
      <td>-</td>
      <td><a href="https://w3id.org/mediatype/text/html">HTML</a></td>
      <td>-</td>
    </tr>
  </tbody>
</table>
8.3.2.2 令牌映射

目前,HTTP 按媒体类型进行内容协商的惯例使用媒体类型令牌, 例如 text/htmlapplication/ld+json,这些令牌注册在 IANA 媒体类型列表中;基于 配置文件内容协商系统的实现者 SHOULD 对媒体 类型标识符使用该列表中的令牌,并遵循其他内容协商维度 (语言等)标识符的 HTTP 内容协商最佳实践。

:媒体类型使用 URI
已有若干计划基于 IANA 的令牌为媒体类型创建 URI, 例如 conneg.info。这些 URI 可用于指示媒体类型。

这里没有提议创建一个中央配置文件登记表,因为这些 作者认为,鉴于可能建立的配置文件数量以及配置文件很可能具有社区 特定性质(各个社区会为自身需求创建配置文件, 而这些配置文件不会 具有广泛相关性),这种做法从长期来看是 不可持续的。

按照 7.2 配置文件 标识,所有配置文件 MUST 由 URI 标识,因为 URI 具有全局唯一性, 因此不需要注册即可避免标识符重复。然而,符合本规范任一 QSA 功能配置文件的系统, 在客户端/服务器交互期间可以不使用 URI 来标识配置文件, 而是 MAY 使用未注册且非全局唯一的令牌来标识 配置文件;但如果这样做,它们 MUST 提供一种方式, 让客户端发现配置文件 token/URI 映射。

希望向客户端提供配置文件 URI 令牌的 QSA 服务器 SHOULD 遵循 8.2.1.2 令牌映射中为 HTTP 标头功能配置文件提供的说明。

8.3.2.3 资源 URL

正在进行基于 QSA 的配置文件协商的资源 URL SHOULD NOT 本身成为任何基于 QSA 的系统中其他资源 URI 的 QSA 值。这类机制可以在内部使用,且遗留系统也用于 配置文件协商,但最好对 客户端隐藏, 以使这些 QSA 配置文件的一致性更容易识别。 示例 18展示了这一点。

示例 18:资源 URL 本身不应作为其他 URL 的参数
For the representation of Resource X, according to Profile Y, in Media Type Z:

Rather than:
GET /single/endpoint \
            ?resource=http://example.org/resource/X \
            &_profile=Y \
            &_mediatype=Z HTTP/1.1

Use:
GET /resource/X?_profile=Y&_mediatype=Z HTTP/1.1

8.3.3 按配置文件获取资源

为符合本规范的“QSA 功能配置文件” 配置文件, 服务器 MUST 允许 客户端根据其用 _profile 查询 字符串标识的配置文件请求资源。 由于可以使用 令牌或 URI 来标识配置文件,服务器 MUST 接受任一种。服务器 MAY 接受编码和未编码的 URI,但 MAY 也可以只接受其中一种。 URI MUST 用 尖括号“<”和“>”括起来。

为符合本规范的“QSA 备用关键字 功能配置文件”配置文件, 服务器 MUST 允许客户端根据它们用 服务器实现者所选择的键标识的配置文件请求资源,但服务器随后 MUST 还提供一种发现该键的方法,如 8.3.4 QSA 键发现所述。

实现按配置文件获取资源QSA 服务器 SHOULD 允许客户端指示 对资源表示按多个配置文件之一生成的偏好。这类请求 MUST 通过在用于标识配置文件的 QSA 键/值对的值中包含 有序配置文件标识符(URI 或令牌)列表来指示配置文件偏好。 例如,客户端按偏好顺序更偏好 profile-z,然后是 http://example.org/profile/y,最后是 profile-x 的资源表示,可以发出如下请求:

GET /resource/a?_profile=profile-z,<http://example.org/profile/y>,profile-x

服务器 MUST 通过在响应中包含带有 rel="profile"Link HTTP 标头来指示实际返回的配置文件,并且 MAY 也以其他 方式指示返回的配置文件。服务器 SHOULD 支持转义 URI,并 MAY 也支持标识配置文件的未转义 URI,或同时支持两者。

为其资源表示实现多个媒体类型格式的服务器 SHOULD 允许客户端 以类似方式为这些格式指定偏好顺序。

8.3.4 QSA 键发现

此功能仅适用于声称符合本规范“QSA 备用关键字 功能配置文件”配置文件的服务器。

声称符合“QSA 备用 关键字功能配置文件”的服务器 MUST 实现方法, 允许客户端发现用于替代 “QSA 功能配置文件”的 _profileQSA 键, 以及等价于 _profile=alt 的内容;该内容要求由任何键/值 组合实现。这允许对服务器了解很少的客户端发现如何创建 列出配置文件按配置文件获取资源请求。

服务器 SHOULD 还允许客户端发现用于指示媒体类型和其他内容 协商维度的 QSA 键。

对支持“QSA 备用关键字功能配置文件”的资源的任何请求作出响应时, 服务器 SHOULD 包含按 HTTP 功能配置文件指示备用配置文件和 媒体类型的 HTTP 标头。它们 MAY 改为,或另外,提供指示相同 信息的 HTTP 正文内容。如果这样做,此类信息 SHOULD 出现在对 URI 请求的默认 响应中,即在 对不带任何 QSA 的请求的响应中。 示例 19 给出了一系列 示例请求。

示例 19:用于 QSA 键发现的示例请求和响应
# A client makes a request for Resource A not knowing if any Content
# Negotiation by Profile is supported. It supplies an Accept-Profile
# header just in case. For extra efficiency, the client could have
# made a HEAD request instead of a GET

GET /resource/a HTTP/1.1
Accept-Profile: <http://example.org/profile/x>

# The server does not understand the HTTP Get Resource By Profile
# request (doesn't support the HTTP Headers Functional Profile) but is
# able to supply an HTTP Link header indicating alternate resource
# representations. It can be seen from the Link header that keys other
# than _profile & _mediatype are in use - view & format - thus this is
# QSA Alt, not a QSA Functional Profile-conformant system

# The resource representations available conform to profile-x & profile-y.
# The profile-x-conformant representation is available in HTML & Turtle,
# the profile-y-conformant representation is available only in XML

HTTP/1.1 200 OK
Link:
  <http://example.org/resource/a?view=profile-x&format=text/html>;
          rel="canonical";
          type="text/html";
          formats="http://otherexample.org/profile/x",
  <http://example.org/resource/a?view=profile-x&format=text/turtle>;
          rel="alternate";
          type="text/turtle";
          formats="http://otherexample.org/profile/x",
  <http://example.org/resource/a?view=profile-y&format=application/xml>;
          rel="alternate";
          type="application/xml";
          formats="http://otherexample.org/profile/y"

# Note that here the server does not directly indicate the profile served
# (there is no Link header with rel="profile" present) but this can be inferred
# by the link header with rel="canonical"

虽然上方 示例 19中的 Link 标头 传达了列出配置文件请求所传达的所有信息, 但它不能直接在 Web 浏览器中看到。示例 16 展示了一对 请求/响应,其中包含等价的 Link 标头和 HTTP 正文信息来列出 配置文件;后者可在浏览器中看到,但构造此请求的客户端 依赖于它知道 QSA 键/值对 _profile=alt 用于触发该响应,而不是 服务器的默认资源表示。

为了向客户端传达在符合“QSA 备用 关键字功能配置文件”时,用于列出配置文件QSA 键/值对,服务器 SHOULD 按照上文 用于 列出配置文件通信的方法,指示该资源存在一个表示, 该表示符合由 URI http://www.w3.org/ns/dx/conneg/altr 标识的 备用配置文件数据模型。此点在 示例 20 中展示; 它是 示例 19 的扩展。

示例 20:上一示例的扩展,展示符合备用配置文件数据 模型的响应
GET /resource/a HTTP/1.1
Accept-Profile: <http://example.org/profile/x>

--

HTTP/1.1 200 OK
Link:
  <http://example.org/resource/a?view=profile-x&format=text/html>;
          rel="canonical";
          type="application/html";
          formats="http://otherexample.org/profile/x",
  <http://example.org/resource/a?view=profile-x&format=text/turtle>;
          rel="alternate";
          type="text/turtle";
          formats="http://otherexample.org/profile/x",
  <http://example.org/resource/a?view=profile-y&format=application/xml>;
          rel="alternate";
          type="application/xml";
          formats="http://otherexample.org/profile/y"
  <http://example.org/resource/a?view=altrep&format=application/ld+json>;
          rel="alternate";
          type="application/ld+json";
          formats="http://www.w3.org/ns/dx/connegp/altr"

[default response content]

示例 20 表明,对于 资源 /resource/a,存在它的一个表示, 该表示符合规范/配置文件 http://www.w3.org/ns/dx/connegp/altr;该 URI 标识 7.4 备用 表示数据模型中定义的备用 配置文件 数据模型。

该示例还显示,QSA view=altrep 可用于构造一个请求,以获取符合备用 配置文件数据模型的响应。因而,解引用 http://example.org/resource/a?view=altrep 将生成一个响应,该响应还会产生与 示例 20Link 标头内容等价的内容,而不是 /resource/a 的默认表示。

10. 测试套件

用于评估系统对本规范一致性的软件,由在线代码 仓库管理:https://github.com/w3c/conneg-prof-testing

11. 实现

本节为非规范性内容。

本文档中给出的功能配置文件实现及其一致性 测试结果,见基于配置文件的内容协商实现报告。 该报告还包含一致性测试工具的描述,并提供其代码访问方式。

12. 致谢

本节为非规范性内容。

编辑们衷心感谢数据集 交换 工作组所有成员对本文档作出的贡献,尤其是 Annette Greiner 和 Antoine Isaac。

编辑们还要感谢以下非工作组人士提供的意见,这些意见 被用于改进本文档:Erik Wilde、Gregg Kellogg 和 Irene Polikoff。

特别感谢 Kam Hay Fung,他提出了最为详尽的评论和建议,帮助我们发现并 修复问题。

最后,编辑们感谢数据集交换工作组主席:Peter Winstanley 和 Karen Coyle。

13. 变更

本节为非规范性内容。

13.1 自上一草案以来的变更

自本规范的第 2 份公开工作草案,2019 年 4 月 30 日以来的变更包括:

13.2 风险特性

本版本中的以下特性被认为存在风险

14. 安全和隐私

本节为非规范性内容。

使用 HTTP 进行协商和传输意味着,与该协议相关的所有隐私和安全问题 也与配置文件协商相关。例如, 用户代理、accept 标头、IP 地址等信息可能被用作 标识信息,特别是 IP 地址会增加有关地理位置 和机构成员身份的信息。 此外,在协商过程开始时提供可接受配置文件列表 可能会泄露有关用户兴趣的信息, 这些信息可被用于将此类信息添加到用户画像中。

有关这些问题的更完整视图,参见 此交付物的隐私和安全 调查问卷

A. 附录

A.1 逐项需求

为展示对本规范中功能配置文件的一致性而需要满足的要求, 按功能配置文件列在下方。

测试或展示对本规范一致性的系统,应引用此处给出的 需求 ID。例如,在展示对 QSA 功能 配置文件的一致性时,必须满足需求 R.2.1.a,其需求文本为 资源表示所符合的配置文件由令牌指示,该令牌 MUST 作为 查询字符串参数追加到资源 URI。,并且服务器对该需求的实现必须 可被证明。

A.1.1 HTTP 标头 功能配置文件

R.1.1.a
来自 8.2.1 列出 配置文件
实现基于配置文件的内容协商的服务器 SHOULD 返回一个 HTTP Link 标头,其中包含关于该 资源的默认表示和任何备用表示的信息, 包括它们所符合的配置文件。
R.1.1.b
来自 8.2.1 列出 配置文件
默认表示——即在未请求特定表示时将返回的表示—— SHOULDrel="canonical" 标识,其他 表示由 rel="alternate" 标识
R.1.2.a
来自 8.2.2 按 配置文件获取资源
实现基于配置文件内容协商的服务器 MUST 使用包含 Link 标头的 HTTP 响应标头作出响应, 该标头带有 rel="profile",指示返回的配置文件。
R.1.2.b
来自 8.2.2 按 配置文件获取资源
Accept-Profile 标头中引用的 URI MUST 用 尖括号“<”和“>”括起来。
R.1.2.c
来自 8.2.2 按 配置文件获取资源
可以提供一组可接受的配置文件 URI MAY;如果提供, 它们 MUST 由逗号分隔,或者 位于单独的 Accept-Profile 标头中。
R.1.2.d
来自 8.2.2 按 配置文件获取资源
客户端 MAY 使用质量指示符 (q 值)作为排序机制来指示偏好,该指示符 与 URI 之间用分号“;”分隔。带 q 值的 URI(本例中为 URN)的示例是 <urn:example:profile:x>;q=1.0,,其中 URI 为 <urn:example:profile:x>,q 值为 q=1.0

A.1.2 查询字符串 参数功能配置文件

R.2.1.a
来自 8.3.1.1 QSA URI 描述
资源表示所符合的配置文件由令牌指示,该令牌 MUST 作为查询字符串参数追加到资源 URI。
R.2.1.b
来自 8.3.2.3 资源 URL
正在进行基于 QSA 的配置文件协商的资源 URL SHOULD NOT 本身成为任何基于 QSA 的系统中其他资源 URI 的 QSA 值。
R.2.1.c
来自 8.3.1.1 QSA URI 描述
[该]令牌 MUST 能够在一个特定 客户端/服务器会话中映射到 URI
R.2.1.d
来自 8.3.1.1 QSA URI 描述
可以通过使用附加 QSA 或任何其他 技术(例如 HTTP 标头)在此类 URI 中包含内容协商的其他方面; 但如果包含这些内容,它们 MUST NOT 改变基于配置文件内容协商请求的行为。
R.2.2.a
来自 8.3.1.2 键 命名
为符合“QSA 功能配置文件”,QSA_profile MUST 用于指示配置文件令牌
R.2.2.b
来自 8.3.1.2 键 命名
_mediatype SHOULD 用于指示资源 表示的媒体类型
R.2.2.c
来自 8.3.2.2 令牌 映射
IANA 媒体类型 列表中注册的令牌 SHOULD 被用作媒体类型标识符的令牌
R.2.3.a
来自 8.3.2 列出 配置文件
服务器 SHOULD 支持 QSA 键/值对 _profile=alt,以允许客户端发出 列出配置文件请求
R.2.3.b
来自 8.3.2 列出 配置文件
服务器对列出配置文件请求的响应 SHOULD 是呈现它所支持的、可用于该资源表示的所有配置文件列表, 并且可选地也呈现这些表示所支持的媒体类型。
R.2.3.c
来自 8.3.2 列出 配置文件
服务器 SHOULD 按照 HTTP 标头功能配置文件 (使用 Link 标头),在响应的 HTTP 标头中表示备用配置文件信息
R.2.3.d
来自 8.3.2 列出 配置文件
[服务器] MAY 也在响应正文中表示该信息, 以替代资源的默认配置文件表示
R.2.3.e
来自 8.3.2 列出 配置文件
当服务器确实在 HTTP 正文中提供备用配置文件信息时,服务器 MAY 允许客户端使用与按配置文件获取资源 功能相同的媒体类型协商方法,来协商响应的特定媒体类型
R.2.4.a
来自 8.3.2.1 QSA 备用表示数据模型 实现
按照 QSA 功能配置文件实现本规范的实现 MUST 按照备用表示数据模型传达其备用表示信息
R.2.4.b
来自 8.3.2.1 QSA 备用表示数据模型 实现
它们 MAY 按照 HTTP 标头功能配置文件使用 HTTP Link 标头来实现, 也 MAY 使用其他方式。
R.2.4.c
来自 8.3.2.1 QSA 备用表示数据模型 实现
它们可以通过 HTTP 正文内容来实现,可能采用 HTML 或其他数据模型/格式

A.1.3 查询字符串参数备用关键字功能配置文件

R.3.1.a
来自 8.3.1.1 QSA URI 描述
为资源表示请求的配置文件由[一个]令牌指示……该令牌 MUST 作为查询字符串参数追加到资源 URI。
R.3.1.b
来自 8.3.2.3 资源 URL
正在进行基于 QSA 的配置文件协商的资源 URL SHOULD NOT 本身成为任何基于 QSA 的系统中其他资源 URI 的 QSA 值。
R.3.1.c
来自 8.3.1.1 QSA URI 描述
[该]令牌 MUST 能够在一个特定 客户端/服务器会话中映射到[配置文件] URI
R.3.1.d
来自 8.3.1.1 QSA URI 描述
可以通过使用附加 QSA 或任何其他 技术(例如 HTTP 标头)在此类 URI 中包含内容协商的其他方面; 但如果包含这些内容,它们 MUST NOT 改变基于配置文件内容协商请求的行为。
R.3.2.a
来自 8.3.1.2 键 命名
QSAMUST 用于 指示配置文件令牌
R.3.2.b
来自 8.3.4 QSA 键发现
[服务器] MUST 实现方法,允许客户端发现 用于替代“QSA 功能配置文件”的 _profileQSA
R.3.2.c
来自 8.3.1.2 键 命名
QSASHOULD 用于 指示资源表示的媒体类型
R.3.2.d
来自 8.3.4 QSA 键发现
如果实现了指示资源表示媒体类型的 QSA 键,则服务器 MUST 实现方法,允许客户端发现用于替代“QSA 功能配置文件”的 _mediatypeQSA
R.3.2.e
来自 8.3.2.2 令牌 映射
IANA 媒体类型 列表中注册的令牌 SHOULD 被用作媒体类型标识符的令牌
R.3.3.a
来自 8.3.2 列出 配置文件
QSA 键/值对 x=y, 其中 x 是服务器中等价于 _profile 的内容,y 是 服务器中等价于 alt 的内容, SHOULD 由服务器支持, 以允许客户端发出列出配置文件请求
R.3.2.b
来自 8.3.4 QSA 键发现
服务器 MUST 实现方法,允许客户端发现 用于替代“QSA 功能配置文件”的 _profile=altQSA 键/值对
R.3.3.c
来自 8.3.2 列出 配置文件
服务器对列出配置文件请求的响应 SHOULD 是呈现它所支持的、可用于该资源表示的所有配置文件列表, 并且可选地也呈现这些表示所支持的媒体类型。
R.3.3.d
来自 8.3.2 列出 配置文件
服务器 SHOULD 按照 HTTP 标头功能配置文件 (使用 Link 标头),在响应的 HTTP 标头中表示备用配置文件信息
R.3.3.e
来自 8.3.2 列出 配置文件
[服务器] MAY 也在响应正文中表示该信息, 以替代资源的默认配置文件表示
R.3.3.f
来自 8.3.2 列出 配置文件
当服务器确实在 HTTP 正文中提供备用配置文件信息时,服务器 MAY 允许客户端使用与按配置文件获取资源 功能相同的媒体类型协商方法,来协商响应的特定媒体类型
R.3.4.a
来自 8.3.2.1 QSA 备用表示数据模型 实现
按照 QSA 功能配置文件实现本规范的实现 MUST 按照备用表示数据模型传达其备用表示信息
R.3.4.b
来自 8.3.2.1 QSA 备用表示数据模型 实现
它们 MAY 按照 HTTP 标头功能配置文件使用 HTTP Link 标头来实现, 也 MAY 使用其他方式。
R.3.4.c
来自 8.3.2.1 QSA 备用表示数据模型 实现
[它们可以] 通过 HTTP 正文内容来实现,可能采用 HTML 或其他数据模型/格式

A.2 本规范功能配置文件的 Profiles Vocabulary 描述

本规范包含若干不同的 功能配置文件,这些配置文件在 8.1 本规范的功能 配置文件中以文字形式标识和描述。本附录根据 Profiles Vocabulary [DX-PROF],给出这些功能 配置文件及其 相互关系的描述。

代码清单 1中的 RDF(turtle 语法)代码将基于配置文件的内容 协商定义为 dcterms:Standard, 它在 [DX-PROF] 中的定义与本文档中 规范的定义相匹配。注意,由于本文档描述的是行为, 本规范是一项功能 规范。按照常规 PROF 建模,它的 4 个配置文件 随后被称为 prof:Profiles。这 4 个功能配置文件以层次结构呈现,其中配置文件要么 直接 配置文件化该标准,要么在 QSA 功能配置文件的情况下,配置文件化另一个随后 配置文件化该标准的配置文件。代码 清单下方的 4也以图形方式展示了这一点。

代码清单 1中给出的代码也可在 RDF 文件 profiles.ttl中获得。

QSA 功能配置文件建模为 配置文件化 QSA 备用关键字 功能配置文件的原因是,QSA 功能配置文件是比 QSA 备用关键字功能配置文件更受约束的 基于配置文件的内容协商“更窄” 规范;任何符合 QSA 功能 配置文件的内容,必然符合 QSA 备用关键字功能配置文件, 因而满足 [DX-PROF] 关于某物成为另一物配置文件的含义。

代码清单 1:使用 Profiles Vocabulary 描述本规范及其配置文件, 如 8.1 本规范的功能配置文件中所列。
PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX prof: <http://www.w3.org/ns/dx/prof/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX cnpr: <http://www.w3.org/ns/dx/connegp/profile/> <https://www.w3.org/TR/dx-connegp/> a dcterms:Standard ; rdfs:label "Content Negotiation by Profile" ; rdfs:comment "W3C Recommendation (a standard) for Content Negotiation by Profile"@en . cnpr:http a prof:Profile ; prof:isProfileOf <https://www.w3.org/TR/dx-connegp/> ; rdfs:label "HTTP Headers Functional Profile" ; rdfs:comment "For conformance with the functional profile of Content Negotiation by Profile presented in § 7.2 Hypertext Transfer Protocol Headers."@en ; skos:scopeNote "To be used if a resource conforms to the HTTP Headers functional profile"@en . cnpr:qsa a prof:Profile ; prof:isProfileOf cnpr:qsa-alt ; rdfs:label "QSA Functional Profile"@en ; rdfs:comment "For conformance with the functional profile of Content Negotiation by Profile presented in § 7.3 URL Query String Arguments."@en ; skos:scopeNote "To be used if a resource conforms to the QSA Functional Profile using the Query String Arguments _profile and _mediatype as per the recommendations in § 7.3 URL Query String Arguments."@en . cnpr:qsa-alt a prof:Profile ; prof:isProfileOf <https://www.w3.org/TR/dx-connegp/> ; rdfs:label "QSA Alternate Keywords Functional Profile" ; rdfs:comment "For conformance with the functional profile of Content Negotiation by Profile presented in § 7.3 URL Query String Arguments."@en ; skos:scopeNote "To be used if a resource conforms to the QSA Functional Profile but uses alternate keywords for the Query String Arguments _profile and _mediatype, as allowed by the recommendations in § 7.3 URL Query String Arguments."@en . cnpr:rrd a prof:Profile ; prof:isProfileOf <https://www.w3.org/TR/dx-connegp/> ; rdfs:label "Resource Representation Description Profile"@en ; rdfs:comment "For conformance with Content Negotiation by Profile § 6.3.2 get resource by profile."@en ; skos:scopeNote "To be used if a resource representation is able to indicate which profile(s) it conforms to, in its appropriate functional profile, as per the abstract specification in § 6.3.2 get resource by profile."@en .
Profiles hierarchy of this specification
4 在 [[PROF] profiles 层次结构中展示的本基于配置文件的内容协商标准的规范和配置文件。

A.3 演示系统对功能配置文件的一致性

通过 8.1 本规范的功能 配置文件中给出的本规范功能配置文件标识,以及 本附录中使用 Profiles Vocabulary [DX-PROF] 描述的它们之间的关系, 系统可以使用 [DX-PROF] 机制 展示其对本规范或其任何功能配置文件的一致性。 这是通过使用 [DCTERMS] 谓词 dcterms:conformsTo 来完成的;例如,一个以 URI <http://example.org/system/a> 标识的系统 声称 符合由 URI <SPEC_OR_PROFILE_URI> 标识的规范或功能配置文件时,可以 这样表示:

<http://example.com/system/a> dcterms:conformsTo <SPEC_OR_PROFILE_URI> .

<SPEC_OR_PROFILE_URI> 可以是本规范的 URI, https://www.w3.org/TR/dx-connegp/,但最佳情况下,应为 8.1 本规范的功能配置文件中列出的某个配置文件 URI,或另一个功能 配置文件的 URI; 因为引用功能配置文件 URI 时,它们的范围比整个规范更窄, 因而更清楚地表明所符合的对象。

希望声称符合多个一致性目标的系统——该规范或其 功能配置文件——可以多次使用 dcterms:conformsTo 来实现。

代码清单 2中的代码展示了一个虚构的 Web 服务,该服务使用 [VOCAB-DCAT-2] 记录, 并借用了其示例中的部分内容,例如 示例 49。 其中包含按 [VOCAB-DCAT-2] 和 [DX-PROF] 使用的谓词 dcterms:conformsTo。 此处声称符合的是 QSA 备用关键字 功能配置文件,它由 URI http://www.w3.org/ns/dx/connegp/profile/qsa-alt 指示,并按 8.1 本规范的功能 配置文件进行标识。

代码清单 2:一个示例 Web 服务, 声称符合本规范的 QSA 备用关键字 功能配置文件
<http://example.com/service/xx> a dcat:DataService ; dcterms:title "Web Service XX" ; dcterms:description "A dummy Web Service claiming conformance to a profile of the Content Negotiation by Profile specification also annotated with other DCAT-2 recommended properties."@en ; # URI for the QSA Alternate Keywords Functional Profile dcterms:conformsTo <http://www.w3.org/ns/dx/connegp/profile/qsa-alt> ; # it's a public service dcterms:accessRights <http://publications.europa.eu/resource/authority/access-right/PUBLIC> # where the service actually is, online dcat:endpointURL <http://example.com/service/v2/xx> ; # a human- and machine-readable documentation endpoint for the service using the # Swagger UI system dcat:endpointDescription <http://example.com/service/v2/xx/swagger> ;

A.4 备用 表示数据模型 - 详细信息

7.4 备用表示数据模型 给出了一个抽象模型,也就是没有在任何具体建模 系统中实现的模型。本附录给出了该模型在 OWL [OWL2-OVERVIEW] 中的一种实现, 以及建议在特定场景中使用的 模型扩展。

A.4.1 实现

下方 代码清单 3给出了 7.4 备用表示数据模型中数据模型的 Web Ontology Language [OWL2-OVERVIEW] 实现。它也可在文件 altr.ttl中获得。

代码清单 3:作为 OWL 本体的 Alternate Profiles 数据模型
PREFIX altr: <http://www.w3.org/ns/dx/connegp/altr#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX sdo: <https://schema.org/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> <http://www.w3.org/ns/dx/connegp/altr> a owl:Ontology ; rdfs:label "Alternative Profiles Ontology" ; rdfs:comment """This ontology allows for the description of representations of Internet resources. Representations may conform to prof:Profile instances and may have the format of a particular dcterms:MediaType."""@en ; dcterms:created "2019-08-07"^^xsd:date ; dcterms:modified "2024-02-07"^^xsd:date ; dcterms:creator [ a sdo:Person ; sdo:affiliation <https://kurrawong.ai> ; sdo:email <mailto:nick@kurrawong.ai> ; sdo:identifier <http://orcid.org/0000-0002-8742-7730> ; sdo:name "Nicholas J. Car" ; ] ; . <https://kurrawong.ai> a sdo:Organization ; sdo:name "KurrawongAI" ; sdo:url "https://kurrawong.ai"^^xsd:anyURI ; . dcterms:conformsTo a owl:ObjectProperty ; rdfs:label "conforms to" ; dcterms:source dcterms:conformsTo ; skos:scopeNote "Use this property to indicate a dcterms:Standard that a altr:Representation conforms to." ; . altr:hasRepresentation a owl:ObjectProperty ; rdfs:label "has representation" ; skos:definition "Indicates a Representation of a Resource."@en ; rdfs:domain rdfs:Resource ; rdfs:range altr:Representation ; skos:scopeNote "Use this property to indicate a the HTTP-delivered representation of a resource." ; . altr:hasDefaultRepresentation a owl:ObjectProperty ; rdfs:label "has default representation" ; skos:definition "Indicates the default Representation of a Resource."@en ; rdfs:domain altr:Representation ; rdfs:subPropertyOf altr:hasRepresentation ; skos:scopeNote "Use this property to indicate the default HTTP-delivered representation of a resource that is obtained when no further instructions are given to a server to obtain a resource's representation other than the identification (URI) of the resource" ; . rdfs:Resource a owl:Class ; rdfs:label "Resource" ; skos:definition "The class resource, everything."@en ; dcterms:source "http://www.w3.org/2000/01/rdf-schema#Resource" ; skos:scopeNote "In the context of the Alternative Profiles Ontology, rdfs:Resource instances are used to identify Internet resources, that is items identified by a URI." ; . altr:Representation a owl:Class ; rdfs:label "Representation" ; skos:definition "An abstraction of the current or desired state of a thing in HTTP communications."@en ; dcterms:source <https://httpwg.org/specs/rfc7230.html> ; rdfs:isDefinedBy <http://www.w3.org/ns/dx/connegp/altr> ; skos:scopeNote "Use this class to indicate instances of representations of resources" ; . dcterms:Standard a owl:Class ; rdfs:label "Standard" ; skos:definition "A basis for comparison; a reference point against which other things can be evaluated."@en ; dcterms:source "http://purl.org/dc/terms/Standard" ; skos:scopeNote "In the context of the Alternative Profiles Ontology, use this class to indicate instances of information models that representations of resources can conform to." ; .

A.4.2 扩展

备用配置文件数据模型可以扩展,以包含在 基于配置文件内容协商情形中有用的附加信息。一个显然有用的扩展是纳入 其他内容协商维度的信息,尤其是媒体类型。代码清单 4 包含 Dublin Core Terms 的 [DCTERMS] dcterms:format 属性和 dcterms:MediaType 类的 RDF 定义,用于可添加到数据 模型中的媒体类型指示, 如 代码清单 4中的 OWL 所表示。示例 22 给出了该 扩展模型的使用示例,该示例接续 示例 23中的内容。

代码清单 4:本规范备用配置文件数据模型在 OWL 中的建议 扩展,用于处理媒体类型表示
PREFIX ex: <http://example.org/> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> dcterms:format a owl:ObjectProperty ; rdfs:label "format" ; skos:definition "The file format, physical medium, or dimensions of the resource."@en ; dcterms:source dcterms:format ; rdfs:range dcterms:MediaType ; skos:scopeNote "Use this property to indicate an IANA Media Type of a resource's representation " . ex:defaultFormat a owl:DataTypeProperty ; rdfs:label "default format" ; skos:definition "Indicates the default Representation of a Resource for the specified Standard."@en ; rdfs:domain rdfs:range xsd:boolean ; skos:scopeNote "Use this property to indicate which of more than one resource representations that conforms to a profile is the default for get resource by profile requests." . dcterms:MediaType a owl:Class ; rdfs:label "Media Type" ; skos:definition "A file format or physical medium."@en ; dcterms:source "http://purl.org/dc/terms/MediaType" ; skos:scopeNote "In the context of this mode, use this class to indicate the IANA Media Type of a resource's representation." .
示例 22: 在 RDF(turtle)中实现 Alternative Profiles 数据模型的扩展实现,展示媒体 类型信息
PREFIX altr: <http://www.w3.org/ns/dx/connegp/altr#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

# This Resource A has 5 Representations, the 3rd of which is the default.
# Some of the Representations conform to the same Standard but are formatted
# according to different Media Types. Some Representations contain no Media
# Type information.
<http://example.org/resource/a>
    a rdfs:Resource ;
    rdfs:label "Resources A" ;
    altr:hasRepresentation :rep-1 , :rep-2 , :rep-3 , :rep-4 , :rep-5 ;
    altr:hasDefaultRepresentation :rep-3 .

:rep-1
    a altr:Representation ;
    dcterms:conformsTo <http://otherexample.org/profile/x> ;
    dcterms:format "application/xml" .

:rep-2
    a altr:Representation ;
    dcterms:conformsTo <http://otherexample.org/profile/y> .

# This representation is the default for the set of representations
# that conform to <http://otherexample.org/profile/z>
:rep-3
    a altr:Representation ;
    dcterms:conformsTo <http://otherexample.org/profile/z> .
    dcterms:format "text/html" ;
    ex:isProfilesDefault "true" .

:rep-4
    a altr:Representation ;
    dcterms:conformsTo <http://otherexample.org/profile/z> ;
    dcterms:format "text/turtle" .

:rep-5
    a altr:Representation ;
    dcterms:conformsTo <http://otherexample.org/profile/z> ;
    dcterms:format "application/ld+json" .

A.4.3 模型使用示例

示例 23 是一个按照 Alternative Profiles Data Model 的 OWL 实现创建的 RDF 数据实例,随后 示例 24 以多种格式展示相同内容。

示例 23: 在 RDF(turtle)中实现 Alternative Profiles 数据模型
PREFIX altr: <http://www.w3.org/ns/dx/connegp/altr#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

# This Resource A has 3 Representations, the 3rd of which is the default
<http://example.org/resource/a>
    a rdfs:Resource ;
    rdfs:label "Resources A" ;
    altr:hasRepresentation :rep-1 , :rep-2 , :rep-3 ;
    altr:hasDefaultRepresentation :rep-3 .

# Each Representation and the Standard each conforms to, X, Y & Z
:rep-1
    a altr:Representation ;
    dcterms:conformsTo <http://otherexample.org/profile/x> .

:rep-2
    a altr:Representation ;
    dcterms:conformsTo <http://otherexample.org/profile/y> .

:rep-3
    a altr:Representation ;
    dcterms:conformsTo <http://otherexample.org/profile/z> .
示例 24:上一示例内容的多格式实现
# The content of the previous example expressed as in an HTTP Link header
# as per the HTTP Application Profile of this Specification with the
# default Representation indicated by the use of rel="canonical". Note the
# Representations are seen, one per Link result comma-separated, identified
# only by the combination of the Resource URI, the URI of the Standard to
# which they conform and the rel attribute - they do not have individual
# identifiers
Link:
  <http://example.org/resource/a>;
          rel="alternate";
          formats="http://otherexample.org/profile/x",
  <http://example.org/resource/a>;
          rel="alternate";
          formats="http://otherexample.org/profile/y",
  <http://example.org/resource/a>;
          rel="canonical";
          formats="http://otherexample.org/profile/z"

---

# The content of the previous example expressed as in table form
# such as could potentially be expressed in the HTML body of an HTTP
# response. The Resource URIs include Query String Arguments that,
# when specified, allow the individual Representations to be returned,
# as per the QSA Application Profile below.
---------------------------------------------------------------------------------------
| Shortened Resource URI                | URI of profile conformed to       | Default |
---------------------------------------------------------------------------------------
| http://.../resource/a?_profile=prof-x | http://otherexample.org/profile/x |         |
| http://.../resource/a?_profile=prof-y | http://otherexample.org/profile/y |         |
| http://.../resource/a?_profile=prof-z | http://otherexample.org/profile/z | Yes     |
---------------------------------------------------------------------------------------

A.5 描述 DCAT 分发对基于配置文件的内容协商的支持

DCAT [VOCAB-DCAT-2] dcat:Dataset 可以通过 dcat:DataService 访问,并且该服务可以 支持本规范的一个或多个功能配置文件。在这种情况下,应通过服务使用谓词 dcterms:conformsTo 引用相关功能配置文件来声明 支持,如 代码清单 5所示。

注意,DCAT 2 没有提供规范方式来指定数据服务是否允许 按标识符访问其所提供访问的数据集中的单个数据项,因此此示例涉及 作为整体分发的数据集。不过,dcterms:conformsTo 的使用仍适用于 声明了访问单个项目机制的数据服务。该机制可以通过 dcat:endpointDescription 标识。

代码清单 5:描述一个支持基于配置文件的内容协商的 DCAT 数据 服务
PREFIX ex: <http://example.org#> PREFIX dcat: <http://www.w3.org/ns/dcat#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX prof: <http://www.w3.org/ns/dx/prof/> # A Dataset has a Distribution :aDataset dcat:distribution :aDatasetDistribution . # A data profile that the Distribution conforms to ex:someDataProfile a prof:Profile ; # profile details . # A Distribution that can be accessed by a DataService that support Content # Negotiation by Profile. The Distribution's content conforms to the Profile above :aDatasetDistribution a dcat:Distribution ; dcterms:conformsTo ex:someDataProfile ; dcat:accessService ex:connegDataAccessService . # The Service used to access the Dataset's Distribution. The Service itself conforms # to two functional profiles of Content Negotiation by Profile ex:connegDataAccessService a dcat:DataService ; dcterms:conformsTo <http://www.w3.org/ns/dx/connegp/profile/http> , <http://www.w3.org/ns/dx/connegp/profile/qsa> ; # Declare that the Dataset may be invoked by URI, its id, using Content # Negotiation by Profile dcat:endPointURL :aDataset .

B. 参考文献

B.1 规范性引用

[DCTERMS]
DCMI Metadata Terms。DCMI Usage Board。DCMI。2020 年 1 月 20 日。DCMI 推荐标准。URL:https://www.dublincore.org/specifications/dublin-core/dcmi-terms/
[OWL2-OVERVIEW]
OWL 2 Web Ontology Language Document Overview (Second Edition)。W3C OWL Working Group。W3C。2012 年 12 月 11 日。W3C 推荐标准。URL:https://www.w3.org/TR/owl2-overview/
[PROF-IETF]
Indicating, Discovering, Negotiating, and Writing Profiled Representations。L. Svensson;R. Verborgh;H. Van de Sompel。2021-03-09。IETF 互联网草案。URL:https://datatracker.ietf.org/doc/draft-svensson-profiled-representations/01/
[RFC2119]
Key words for use in RFCs to Indicate Requirement Levels。S. Bradner。IETF。1997 年 3 月。最佳当前实践。URL:https://www.rfc-editor.org/info/rfc2119/
[RFC3986]
Uniform Resource Identifier (URI): Generic Syntax。T. Berners-Lee;R. Fielding;L. Masinter。IETF。2005 年 1 月。互联网 标准。URL:https://www.rfc-editor.org/info/rfc3986/
[RFC8174]
Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words。B. Leiba。IETF。2017 年 5 月。最佳当前实践。URL:https://www.rfc-editor.org/info/rfc8174/
[RFC8288]
Web Linking。M. Nottingham。IETF。 2017 年 10 月。提议标准。URL:https://httpwg.org/specs/rfc8288.html
[RFC9110]
HTTP Semantics。R. Fielding,编辑; M. Nottingham,编辑;J. Reschke,编辑。IETF。2022 年 6 月。互联网标准。URL:https://httpwg.org/specs/rfc9110.html
[VOCAB-DCAT-2]
Data Catalog Vocabulary (DCAT) - Version 2。Riccardo Albertoni;David Browning;Simon Cox;Alejandra Gonzalez Beltran; Andrea Perego;Peter Winstanley。W3C。2024 年 8 月 22 日。W3C 推荐标准。URL:https://www.w3.org/TR/vocab-dcat-2/

B.2 资料性引用

[ARK]
The ARK Identifier Scheme。2023-04-25。互联网草案。URL:https://datatracker.ietf.org/doc/draft-kunze-ark/37/
[CSW]
Catalogue Services 3.0 - General Model。Douglas Nebert;Uwe Voges;Lorenzo Bigagli。OGC。2016 年 6 月 10 日。URL:http://www.opengeospatial.org/standards/cat
[DC11]
Dublin Core Metadata Element Set, Version 1.1。DCMI。2012 年 6 月 14 日。DCMI 推荐标准。URL:http://dublincore.org/documents/dces/
[DCAT-AP]
DCAT Application Profile for data portals in Europe。European Commission。2025 年 7 月 10 日。URL:https://interoperable-europe.ec.europa.eu/collection/semic-support-centre/solution/dcat-application-profile-data-portals-europe
[DX-PROF]
The Profiles Vocabulary。Nicholas Car。 W3C。2019 年 12 月 18 日。W3C 工作组说明。URL:https://www.w3.org/TR/dx-prof/
[GeoDCAT-AP]
GeoDCAT-AP: A geospatial extension for the DCAT application profile for data portals in Europe。European Commission。 2020 年 12 月 23 日。URL:https://semiceu.github.io/GeoDCAT-AP/releases/
[ISO-19115]
Geographic information -- Metadata。ISO/TC 211。ISO。2003。国际标准。URL:https://www.iso.org/standard/26020.html
[OAI-PMH]
The Open Archives Initiative Protocol for Metadata Harvesting。Carl Lagoze;Herbert Van de Sompel; Michael Nelson;Simeon Warner。OAI。2015 年 1 月 8 日。URL:http://www.openarchives.org/OAI/openarchivesprotocol.html
[PROF-GUIDANCE]
Profile Guidance。2019-04-24。W3C 编辑草案。URL:https://w3c.github.io/dxwg/profiles/
[RFC6906]
The 'profile' Link Relation Type。E. Wilde。IETF。2013 年 3 月。资料性。URL:https://www.rfc-editor.org/info/rfc6906/
[RFC7240]
Prefer Header for HTTP。J. Snell。IETF。2014 年 6 月。提议标准。URL:https://www.rfc-editor.org/info/rfc7240/
[STATDCAT-AP]
StatDCAT-AP – DCAT Application Profile for description of statistical datasets. Version 1.0.1。European Commission。2019 年 5 月 28 日。URL:https://joinup.ec.europa.eu/solution/statdcat-application-profile-data-portals-europe
[TURTLE]
RDF 1.1 Turtle。Eric Prud'hommeaux;Gavin Carothers。W3C。2014 年 2 月 25 日。W3C 推荐标准。URL:https://www.w3.org/TR/turtle/
[VOCAB-DATA-CUBE]
The RDF Data Cube Vocabulary。 Richard Cyganiak;Dave Reynolds。W3C。2014 年 1 月 16 日。W3C 推荐标准。URL:https://www.w3.org/TR/vocab-data-cube/
[VOCAB-DCAT]
Data Catalog Vocabulary (DCAT)。Fadi Maali;John Erickson。W3C。2020 年 2 月 4 日。W3C 推荐标准。URL:https://www.w3.org/TR/vocab-dcat/
[VOID]
Describing Linked Datasets with the VoID Vocabulary。Keith Alexander;Richard Cyganiak;Michael Hausenblas;Jun Zhao。W3C。 2011 年 3 月 3 日。W3C 工作组说明。URL:https://www.w3.org/TR/void/
[WFS]
Web Feature Service 2.0 Interface Standard。Panagiotis (Peter) A. Vretanos。OGC。2014 年 7 月 10 日。OGC 接口 标准。URL:http://www.opengeospatial.org/standards/wfs
[WMS]
Web Map Service Implementation Specification。Jeff de la Beaujardiere。OGC。2006 年 3 月 15 日。OpenGIS 实现标准。URL:http://www.opengeospatial.org/standards/wms