PageRenderTime 72ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/JsonSchemaValidator/draft-04/JSON Hyper-Schema: Hypertext definitions for JSON Schema.html

https://bitbucket.org/nut_code_monkey/jsonschemavalidator
HTML | 1027 lines | 810 code | 85 blank | 132 comment | 0 complexity | d00bbaddfb818aa3ffc595bfc03924e7 MD5 | raw file
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html lang="en"><head><title>JSON Hyper-Schema: Hypertext definitions for JSON Schema</title>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  4. <meta name="description" content="JSON Hyper-Schema: Hypertext definitions for JSON Schema">
  5. <meta name="keywords" content="JSON, Schema, JavaScript, Object, Notation, Hyper Schema, Hypermedia">
  6. <meta name="generator" content="xml2rfc v1.36 (http://xml.resource.org/)">
  7. <style type='text/css'><!--
  8. body {
  9. font-family: verdana, charcoal, helvetica, arial, sans-serif;
  10. font-size: small; color: #000; background-color: #FFF;
  11. margin: 2em;
  12. }
  13. h1, h2, h3, h4, h5, h6 {
  14. font-family: helvetica, monaco, "MS Sans Serif", arial, sans-serif;
  15. font-weight: bold; font-style: normal;
  16. }
  17. h1 { color: #900; background-color: transparent; text-align: right; }
  18. h3 { color: #333; background-color: transparent; }
  19. td.RFCbug {
  20. font-size: x-small; text-decoration: none;
  21. width: 30px; height: 30px; padding-top: 2px;
  22. text-align: justify; vertical-align: middle;
  23. background-color: #000;
  24. }
  25. td.RFCbug span.RFC {
  26. font-family: monaco, charcoal, geneva, "MS Sans Serif", helvetica, verdana, sans-serif;
  27. font-weight: bold; color: #666;
  28. }
  29. td.RFCbug span.hotText {
  30. font-family: charcoal, monaco, geneva, "MS Sans Serif", helvetica, verdana, sans-serif;
  31. font-weight: normal; text-align: center; color: #FFF;
  32. }
  33. table.TOCbug { width: 30px; height: 15px; }
  34. td.TOCbug {
  35. text-align: center; width: 30px; height: 15px;
  36. color: #FFF; background-color: #900;
  37. }
  38. td.TOCbug a {
  39. font-family: monaco, charcoal, geneva, "MS Sans Serif", helvetica, sans-serif;
  40. font-weight: bold; font-size: x-small; text-decoration: none;
  41. color: #FFF; background-color: transparent;
  42. }
  43. td.header {
  44. font-family: arial, helvetica, sans-serif; font-size: x-small;
  45. vertical-align: top; width: 33%;
  46. color: #FFF; background-color: #666;
  47. }
  48. td.author { font-weight: bold; font-size: x-small; margin-left: 4em; }
  49. td.author-text { font-size: x-small; }
  50. /* info code from SantaKlauss at http://www.madaboutstyle.com/tooltip2.html */
  51. a.info {
  52. /* This is the key. */
  53. position: relative;
  54. z-index: 24;
  55. text-decoration: none;
  56. }
  57. a.info:hover {
  58. z-index: 25;
  59. color: #FFF; background-color: #900;
  60. }
  61. a.info span { display: none; }
  62. a.info:hover span.info {
  63. /* The span will display just on :hover state. */
  64. display: block;
  65. position: absolute;
  66. font-size: smaller;
  67. top: 2em; left: -5em; width: 15em;
  68. padding: 2px; border: 1px solid #333;
  69. color: #900; background-color: #EEE;
  70. text-align: left;
  71. }
  72. a { font-weight: bold; }
  73. a:link { color: #900; background-color: transparent; }
  74. a:visited { color: #633; background-color: transparent; }
  75. a:active { color: #633; background-color: transparent; }
  76. p { margin-left: 2em; margin-right: 2em; }
  77. p.copyright { font-size: x-small; }
  78. p.toc { font-size: small; font-weight: bold; margin-left: 3em; }
  79. table.toc { margin: 0 0 0 3em; padding: 0; border: 0; vertical-align: text-top; }
  80. td.toc { font-size: small; font-weight: bold; vertical-align: text-top; }
  81. ol.text { margin-left: 2em; margin-right: 2em; }
  82. ul.text { margin-left: 2em; margin-right: 2em; }
  83. li { margin-left: 3em; }
  84. /* RFC-2629 <spanx>s and <artwork>s. */
  85. em { font-style: italic; }
  86. strong { font-weight: bold; }
  87. dfn { font-weight: bold; font-style: normal; }
  88. cite { font-weight: normal; font-style: normal; }
  89. tt { color: #036; }
  90. tt, pre, pre dfn, pre em, pre cite, pre span {
  91. font-family: "Courier New", Courier, monospace; font-size: small;
  92. }
  93. pre {
  94. text-align: left; padding: 4px;
  95. color: #000; background-color: #CCC;
  96. }
  97. pre dfn { color: #900; }
  98. pre em { color: #66F; background-color: #FFC; font-weight: normal; }
  99. pre .key { color: #33C; font-weight: bold; }
  100. pre .id { color: #900; }
  101. pre .str { color: #000; background-color: #CFF; }
  102. pre .val { color: #066; }
  103. pre .rep { color: #909; }
  104. pre .oth { color: #000; background-color: #FCF; }
  105. pre .err { background-color: #FCC; }
  106. /* RFC-2629 <texttable>s. */
  107. table.all, table.full, table.headers, table.none {
  108. font-size: small; text-align: center; border-width: 2px;
  109. vertical-align: top; border-collapse: collapse;
  110. }
  111. table.all, table.full { border-style: solid; border-color: black; }
  112. table.headers, table.none { border-style: none; }
  113. th {
  114. font-weight: bold; border-color: black;
  115. border-width: 2px 2px 3px 2px;
  116. }
  117. table.all th, table.full th { border-style: solid; }
  118. table.headers th { border-style: none none solid none; }
  119. table.none th { border-style: none; }
  120. table.all td {
  121. border-style: solid; border-color: #333;
  122. border-width: 1px 2px;
  123. }
  124. table.full td, table.headers td, table.none td { border-style: none; }
  125. hr { height: 1px; }
  126. hr.insert {
  127. width: 80%; border-style: none; border-width: 0;
  128. color: #CCC; background-color: #CCC;
  129. }
  130. --></style>
  131. </head>
  132. <body>
  133. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  134. <table summary="layout" width="66%" border="0" cellpadding="0" cellspacing="0"><tr><td><table summary="layout" width="100%" border="0" cellpadding="2" cellspacing="1">
  135. <tr><td class="header">Internet Engineering Task Force</td><td class="header">G. Luff, Ed.</td></tr>
  136. <tr><td class="header">Internet-Draft</td><td class="header">&nbsp;</td></tr>
  137. <tr><td class="header">Intended status: Informational</td><td class="header">K. Zyp</td></tr>
  138. <tr><td class="header">Expires: August 4, 2013</td><td class="header">SitePen (USA)</td></tr>
  139. <tr><td class="header">&nbsp;</td><td class="header">G. Court</td></tr>
  140. <tr><td class="header">&nbsp;</td><td class="header">January 31, 2013</td></tr>
  141. </table></td></tr></table>
  142. <h1><br />JSON Hyper-Schema: Hypertext definitions for JSON Schema<br />json-schema-hypermedia</h1>
  143. <h3>Abstract</h3>
  144. <p>
  145. JSON Schema is a JSON based format for defining the structure of JSON data.
  146. This document specifies hyperlink- and hypermedia-related keywords of JSON Schema.
  147. </p>
  148. <h3>Status of This Memo</h3>
  149. <p>
  150. This Internet-Draft is submitted in full
  151. conformance with the provisions of BCP&nbsp;78 and BCP&nbsp;79.</p>
  152. <p>
  153. Internet-Drafts are working documents of the Internet Engineering
  154. Task Force (IETF). Note that other groups may also distribute
  155. working documents as Internet-Drafts. The list of current
  156. Internet-Drafts is at http://datatracker.ietf.org/drafts/current/.</p>
  157. <p>
  158. Internet-Drafts are draft documents valid for a maximum of six months
  159. and may be updated, replaced, or obsoleted by other documents at any time.
  160. It is inappropriate to use Internet-Drafts as reference material or to cite
  161. them other than as &ldquo;work in progress.&rdquo;</p>
  162. <p>
  163. This Internet-Draft will expire on August 4, 2013.</p>
  164. <h3>Copyright Notice</h3>
  165. <p>
  166. Copyright (c) 2013 IETF Trust and the persons identified as the
  167. document authors. All rights reserved.</p>
  168. <p>
  169. This document is subject to BCP 78 and the IETF Trust's Legal
  170. Provisions Relating to IETF Documents
  171. (http://trustee.ietf.org/license-info) in effect on the date of
  172. publication of this document. Please review these documents
  173. carefully, as they describe your rights and restrictions with respect
  174. to this document. Code Components extracted from this document must
  175. include Simplified BSD License text as described in Section 4.e of
  176. the Trust Legal Provisions and are provided without warranty as
  177. described in the Simplified BSD License.</p>
  178. <a name="toc"></a><br /><hr />
  179. <h3>Table of Contents</h3>
  180. <p class="toc">
  181. <a href="#anchor1">1.</a>&nbsp;
  182. Introduction<br />
  183. <a href="#anchor2">2.</a>&nbsp;
  184. Conventions and Terminology<br />
  185. <a href="#anchor3">3.</a>&nbsp;
  186. Overview<br />
  187. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor4">3.1.</a>&nbsp;
  188. Design Considerations<br />
  189. <a href="#anchor5">4.</a>&nbsp;
  190. Schema keywords<br />
  191. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor6">4.1.</a>&nbsp;
  192. links<br />
  193. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor7">4.1.1.</a>&nbsp;
  194. Multiple links per URI<br />
  195. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor8">4.2.</a>&nbsp;
  196. fragmentResolution<br />
  197. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor9">4.2.1.</a>&nbsp;
  198. json-pointer fragment resolution<br />
  199. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor10">4.3.</a>&nbsp;
  200. media<br />
  201. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor11">4.3.1.</a>&nbsp;
  202. Properties of &quot;media&quot;<br />
  203. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor14">4.3.2.</a>&nbsp;
  204. Example<br />
  205. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor15">4.4.</a>&nbsp;
  206. readOnly<br />
  207. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor16">4.5.</a>&nbsp;
  208. pathStart<br />
  209. <a href="#anchor17">5.</a>&nbsp;
  210. Link Description Object<br />
  211. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#href">5.1.</a>&nbsp;
  212. href<br />
  213. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor18">5.1.1.</a>&nbsp;
  214. URI Templating<br />
  215. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor27">5.2.</a>&nbsp;
  216. rel<br />
  217. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor28">5.2.1.</a>&nbsp;
  218. Fragment resolution with &quot;root&quot; links<br />
  219. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor29">5.2.2.</a>&nbsp;
  220. Security Considerations for &quot;self&quot; links<br />
  221. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor30">5.3.</a>&nbsp;
  222. title<br />
  223. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor31">5.4.</a>&nbsp;
  224. targetSchema<br />
  225. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor32">5.4.1.</a>&nbsp;
  226. Security Considerations for &quot;targetSchema&quot;<br />
  227. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor33">5.5.</a>&nbsp;
  228. mediaType<br />
  229. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor34">5.5.1.</a>&nbsp;
  230. Security concerns for &quot;mediaType&quot;<br />
  231. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor35">5.6.</a>&nbsp;
  232. Submission Link Properties<br />
  233. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor36">5.6.1.</a>&nbsp;
  234. method<br />
  235. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor37">5.6.2.</a>&nbsp;
  236. encType<br />
  237. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor38">5.6.3.</a>&nbsp;
  238. schema<br />
  239. <a href="#anchor39">6.</a>&nbsp;
  240. IANA Considerations<br />
  241. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#anchor40">6.1.</a>&nbsp;
  242. Registry of Link Relations<br />
  243. <a href="#rfc.references1">7.</a>&nbsp;
  244. References<br />
  245. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#rfc.references1">7.1.</a>&nbsp;
  246. Normative References<br />
  247. &nbsp;&nbsp;&nbsp;&nbsp;<a href="#rfc.references2">7.2.</a>&nbsp;
  248. Informative References<br />
  249. <a href="#anchor43">Appendix&nbsp;A.</a>&nbsp;
  250. Change Log<br />
  251. </p>
  252. <br clear="all" />
  253. <a name="anchor1"></a><br /><hr />
  254. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  255. <a name="rfc.section.1"></a><h3>1.&nbsp;
  256. Introduction</h3>
  257. <p>
  258. JSON Schema is a JSON based format for defining the structure of JSON data.
  259. This document specifies hyperlink- and hypermedia-related keywords of JSON Schema.
  260. </p>
  261. <p>
  262. The term JSON Hyper-Schema is used to refer to a JSON Schema that uses these keywords.
  263. </p>
  264. <p>
  265. This specification will use the terminology defined by the JSON Schema core
  266. specification. It is advised that readers have a copy of this specification.
  267. </p>
  268. <a name="anchor2"></a><br /><hr />
  269. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  270. <a name="rfc.section.2"></a><h3>2.&nbsp;
  271. Conventions and Terminology</h3>
  272. <p>
  273. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
  274. "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
  275. interpreted as described in <a class='info' href='#RFC2119'>RFC 2119<span> (</span><span class='info'>Bradner, S., &ldquo;Key words for use in RFCs to Indicate Requirement Levels,&rdquo; March&nbsp;1997.</span><span>)</span></a> [RFC2119].
  276. </p>
  277. <p>
  278. The terms "schema", "instance", "property" and "item" are to be interpreted as defined in the JSON Schema core definition [FIXME_LINK].
  279. </p>
  280. <a name="anchor3"></a><br /><hr />
  281. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  282. <a name="rfc.section.3"></a><h3>3.&nbsp;
  283. Overview</h3>
  284. <p>
  285. This document describes how JSON Schema can be used to define hyperlinks on instance data. It also defines how to provide additional information required to interpret JSON data as rich multimedia documents.
  286. </p>
  287. <p>
  288. Just as with the core JSON schema keywords, all the keywords described in the "Schema Keywords" section are optional.
  289. </p>
  290. <p>Here is an example JSON Schema defining hyperlinks, and providing a multimedia interpretation for the "imgData" property:
  291. </p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  292. {
  293. "title": "Written Article",
  294. "type": "object",
  295. "properties": {
  296. "id": {
  297. "title": "Article Identifier",
  298. "type": "number"
  299. },
  300. "title": {
  301. "title": "Article Title",
  302. "type": "string"
  303. },
  304. "authorId": {
  305. "type": "integer"
  306. },
  307. "imgData": {
  308. "title": "Article Illustration (small)",
  309. "type": "string",
  310. "media": {
  311. "binaryEncoding": "base64",
  312. "type": "image/png"
  313. }
  314. }
  315. },
  316. "required" : ["id", "title", "authorId"],
  317. "links": [
  318. {
  319. "rel": "full",
  320. "href": "{id}"
  321. },
  322. {
  323. "rel": "author",
  324. "href": "/user?id={authorId}"
  325. }
  326. ]
  327. }
  328. </pre></div>
  329. <p>
  330. This example schema defines the properties of the instance.
  331. For the "imgData" property, it specifies that that it should be base64-decoded and the resulting binary data treated as a PNG image.
  332. It also defines link relations for the instance, with URIs incorporating values from the instance.
  333. </p>
  334. <p>An example of a JSON instance described by the above schema might be:
  335. </p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  336. {
  337. "id": 15,
  338. "title": "Example data",
  339. "authorId": 105,
  340. "imgData": "iVBORw...kJggg=="
  341. }
  342. </pre></div>
  343. <p>The base-64 data has been abbreviated for readability.
  344. </p>
  345. <a name="anchor4"></a><br /><hr />
  346. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  347. <a name="rfc.section.3.1"></a><h3>3.1.&nbsp;
  348. Design Considerations</h3>
  349. <p>
  350. The purpose of this document is to define keywords for the JSON Schema that allow JSON data to be understood as hyper-text.
  351. </p>
  352. <p>
  353. JSON data on its own requires special knowledge from the client about the format in order to be interpretable as hyper-text.
  354. This document proposes a way to describe the hyper-text and hyper-media interpretation of such JSON formats, without defining reserved keywords or otherwise restricting the structure of the JSON data.
  355. </p>
  356. <a name="anchor5"></a><br /><hr />
  357. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  358. <a name="rfc.section.4"></a><h3>4.&nbsp;
  359. Schema keywords</h3>
  360. <a name="anchor6"></a><br /><hr />
  361. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  362. <a name="rfc.section.4.1"></a><h3>4.1.&nbsp;
  363. links</h3>
  364. <p>
  365. The "links" property of schemas is used to associate Link Description Objects with instances. The value of this property MUST be an array, and the items in the array must be Link Description Objects, as defined below.
  366. </p>
  367. <p>An example schema using the "links" keyword could be:
  368. </p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  369. {
  370. "title": "Schema defining links",
  371. "links": [
  372. {
  373. "rel": "full",
  374. "href": "{id}"
  375. },
  376. {
  377. "rel": "parent",
  378. "href": "{parent}"
  379. }
  380. ]
  381. }
  382. </pre></div>
  383. <a name="anchor7"></a><br /><hr />
  384. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  385. <a name="rfc.section.4.1.1"></a><h3>4.1.1.&nbsp;
  386. Multiple links per URI</h3>
  387. <p>
  388. A single URI might have more than one role with relation to an instance. This is not a problem - the same URI can be used in more than one Link Description Object.
  389. </p>
  390. <p>
  391. For example, this schema describes a format for blog posts, accessed via HTTP.
  392. The links describe how to access the comments for the post, how to search the comments, and how to submit new comments, all with the same URI:
  393. </p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  394. {
  395. "title": "News post",
  396. ...
  397. "links": [
  398. {
  399. "rel": "comments",
  400. "href": "/{id}/comments"
  401. },
  402. {
  403. "rel": "search",
  404. "href": "/{id}/comments",
  405. "schema": {
  406. "type": "object",
  407. "properties": {
  408. "searchTerm": {
  409. "type": "string"
  410. },
  411. "itemsPerPage": {
  412. "type": "integer",
  413. "minimum": 10,
  414. "multipleOf": 10,
  415. "default": 20
  416. }
  417. },
  418. "required": ["searchTerm"]
  419. }
  420. },
  421. {
  422. "title": "Post a comment",
  423. "rel": "create",
  424. "href": "/{id}/comments",
  425. "method": "POST",
  426. "schema": {
  427. "type": "object",
  428. "properties": {
  429. "message": {
  430. "type": "string"
  431. }
  432. },
  433. "required": ["message"]
  434. }
  435. }
  436. ]
  437. }
  438. </pre></div>
  439. <p>
  440. If the client follows the first link, the URI might be expanded to "/15/comments".
  441. For the second link, the method is "GET" (the default for HTTP) so a client following this link would add the parameters to the URL to produce something like: "/15/comments?searchTerm=JSON&amp;itemsPerPage=50".
  442. The third link defines a possible interaction where a client would POST to a URI (such as "/15/comments"), where the post-data was a JSON representation of the new comment, for example:
  443. </p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  444. {
  445. "message": "This is an example comment"
  446. }
  447. </pre></div>
  448. <a name="anchor8"></a><br /><hr />
  449. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  450. <a name="rfc.section.4.2"></a><h3>4.2.&nbsp;
  451. fragmentResolution</h3>
  452. <p>
  453. When addressing a JSON document, the fragment part of the URI may be used to refer to a particular instance within the document.
  454. </p>
  455. <p>
  456. This keyword indicates the method to use for finding the appropriate instance within a document, given the fragment part.
  457. The default fragment resolution protocol is "json-pointer", which is defined below.
  458. Other fragment resolution protocols MAY be used, but are not defined in this document.
  459. </p>
  460. <p>
  461. If the instance is described by a schema providing the a link with "root" relation, or such a link is provided in using the <a class='info' href='#RFC5988'>HTTP Link header<span> (</span><span class='info'>Nottingham, M., &ldquo;Web Linking,&rdquo; October&nbsp;2010.</span><span>)</span></a> [RFC5988], then the target of the "root" link should be considered the document root for the purposes of all fragment resolution methods that use the document structure (such as "json-pointer").
  462. The only exception to this is the resolution of "root" links themselves.
  463. </p>
  464. <a name="anchor9"></a><br /><hr />
  465. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  466. <a name="rfc.section.4.2.1"></a><h3>4.2.1.&nbsp;
  467. json-pointer fragment resolution</h3>
  468. <p>
  469. The "json-pointer" fragment resolution protocol uses a <a class='info' href='#json-pointer'>JSON Pointer<span> (</span><span class='info'>Bryan, P. and K. Zyp, &ldquo;JSON Pointer,&rdquo; October&nbsp;2011.</span><span>)</span></a> [json&#8209;pointer] to resolve fragment identifiers in URIs within instance representations.
  470. </p>
  471. <a name="anchor10"></a><br /><hr />
  472. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  473. <a name="rfc.section.4.3"></a><h3>4.3.&nbsp;
  474. media</h3>
  475. <p>
  476. The "media" property indicates that this instance contains non-JSON data encoded in a JSON string. It describes the type of content and how it is encoded.
  477. </p>
  478. <p>
  479. The value of this property MUST be an object, and SHOULD be ignored for any instance that is not a string.
  480. </p>
  481. <a name="anchor11"></a><br /><hr />
  482. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  483. <a name="rfc.section.4.3.1"></a><h3>4.3.1.&nbsp;
  484. Properties of &quot;media&quot;</h3>
  485. <p>
  486. The value of the "media" keyword MAY contain any of the following properties:
  487. </p>
  488. <a name="anchor12"></a><br /><hr />
  489. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  490. <a name="rfc.section.4.3.1.1"></a><h3>4.3.1.1.&nbsp;
  491. binaryEncoding</h3>
  492. <p>
  493. If the instance value is a string, this property defines that the string SHOULD be interpreted as binary data and decoded using the encoding named by this property.
  494. <a class='info' href='#RFC2045'>RFC 2045, Sec 6.1<span> (</span><span class='info'>Freed, N. and N. Borenstein, &ldquo;Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies,&rdquo; November&nbsp;1996.</span><span>)</span></a> [RFC2045] lists the possible values for this property.
  495. </p>
  496. <a name="anchor13"></a><br /><hr />
  497. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  498. <a name="rfc.section.4.3.1.2"></a><h3>4.3.1.2.&nbsp;
  499. type</h3>
  500. <p>
  501. The value of this property must be a media type, as defined by <a class='info' href='#RFC2046'>RFC 2046<span> (</span><span class='info'>Freed, N. and N. Borenstein, &ldquo;Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types,&rdquo; November&nbsp;1996.</span><span>)</span></a> [RFC2046].
  502. This property defines the media type of instances which this schema defines.
  503. </p>
  504. <p>
  505. If the "binaryEncoding" property is not set, but the instance value is a string, then the value of this property SHOULD specify a text document type, and the character set SHOULD be the character set into which the JSON string value was decoded (for which the default is Unicode).
  506. </p>
  507. <a name="anchor14"></a><br /><hr />
  508. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  509. <a name="rfc.section.4.3.2"></a><h3>4.3.2.&nbsp;
  510. Example</h3>
  511. <p>Here is an example schema, illustrating the use of "media":
  512. </p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  513. {
  514. "type": "string",
  515. "media": {
  516. "binaryEncoding": "base64",
  517. "type": "image/png"
  518. }
  519. }
  520. </pre></div>
  521. <p>Instances described by this schema should be strings, and their values should be interpretable as base64-encoded PNG images.
  522. </p>
  523. <p>Another example:
  524. </p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  525. {
  526. "type": "string",
  527. "media": {
  528. "mediaType": "text/html"
  529. }
  530. }
  531. </pre></div>
  532. <p>Instances described by this schema should be strings containing HTML, using whatever character set the JSON string was decoded into (default is Unicode).
  533. </p>
  534. <a name="anchor15"></a><br /><hr />
  535. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  536. <a name="rfc.section.4.4"></a><h3>4.4.&nbsp;
  537. readOnly</h3>
  538. <p>
  539. If it has a value of boolean true, this keyword indicates that the instance property SHOULD NOT be changed, and attempts by a user agent to modify the value of this property are expected to be rejected by a server.
  540. </p>
  541. <p>
  542. The value of this keyword MUST be a boolean.
  543. The default value is false.
  544. </p>
  545. <a name="anchor16"></a><br /><hr />
  546. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  547. <a name="rfc.section.4.5"></a><h3>4.5.&nbsp;
  548. pathStart</h3>
  549. <p>
  550. This property is a URI that defines what the instance's URI MUST start with in order to validate.
  551. The value of the "pathStart" property MUST be resolved relative to the closest URI Resolution Scope (as defined in the core specification [FIXME link]), using the rules from <a class='info' href='#RFC3986'>RFC 3986, Sec 5<span> (</span><span class='info'>Berners-Lee, T., Fielding, R., and L. Masinter, &ldquo;Uniform Resource Identifier (URI): Generic Syntax,&rdquo; January&nbsp;2005.</span><span>)</span></a> [RFC3986].
  552. </p>
  553. <p>
  554. When multiple schemas have been referenced for an instance, the user agent can determine if this schema is applicable for a particular instance by determining if the URI of the instance begins with the the value of the "pathStart" property.
  555. If the URI of the instance does not start with this URI, or if another schema specifies a starting URI that is longer and also matches the instance, this schema SHOULD NOT be considered to describe the instance.
  556. Any schema that does not have a pathStart property SHOULD be considered applicable to all the instances for which it is referenced.
  557. </p>
  558. <a name="anchor17"></a><br /><hr />
  559. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  560. <a name="rfc.section.5"></a><h3>5.&nbsp;
  561. Link Description Object</h3>
  562. <p>
  563. A Link Description Object (LDO) is used to describe a single link relation.
  564. In the context of a schema, it defines the link relations of the instances of the schema, and can be parameterized by the instance values.
  565. A Link Description Object (LDO) must be an object.
  566. </p>
  567. <p>
  568. The link description format can be used without JSON Schema, and use of this format can be declared by referencing the normative link description schema as the schema for the data structure that uses the links.
  569. The URI of the normative link description schema is: <a href='http://json-schema.org/links'>http://json-schema.org/links</a> (latest version) or <a href='http://json-schema.org/draft-04/links'>http://json-schema.org/draft-04/links</a> (draft-04 version).
  570. </p>
  571. <p>
  572. "Form"-like functionality can be defined by use of the "schema" keyword, which supplies a schema describing the data to supply to the server.
  573. </p>
  574. <a name="href"></a><br /><hr />
  575. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  576. <a name="rfc.section.5.1"></a><h3>5.1.&nbsp;
  577. href</h3>
  578. <p>
  579. The value of the "href" link description property is a template used to determine the target URI of the related resource.
  580. The value of the instance property SHOULD be resolved as a URI-Reference per <a class='info' href='#RFC3986'>RFC 3986<span> (</span><span class='info'>Berners-Lee, T., Fielding, R., and L. Masinter, &ldquo;Uniform Resource Identifier (URI): Generic Syntax,&rdquo; January&nbsp;2005.</span><span>)</span></a> [RFC3986] and MAY be a relative reference to a URI.
  581. The base URI to be used for relative URI resolution SHOULD be the URI used to retrieve the instance object (not the schema).
  582. </p>
  583. <p>
  584. The base URI to be used for relative URI resolution SHOULD is defined as follows:
  585. </p>
  586. <blockquote class="text">
  587. <p>if the data has a link defined, with a relation of "self", then the "href" value of that link is used, unless the relation of the link being resolved is also "self"
  588. </p>
  589. <p>otherwise, the URI should be resolved against the link with relation "self" belonging to the closest parent node in the JSON document, if it exists
  590. </p>
  591. <p>otherwise, the URI used to fetch the document should be used.
  592. </p>
  593. </blockquote><p>
  594. </p>
  595. <p>This property is not optional.
  596. </p>
  597. <a name="anchor18"></a><br /><hr />
  598. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  599. <a name="rfc.section.5.1.1"></a><h3>5.1.1.&nbsp;
  600. URI Templating</h3>
  601. <p>
  602. The value of "href" is to be used as a URI Template, as defined in <a class='info' href='#RFC6570'>RFC 6570<span> (</span><span class='info'>Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, &ldquo;URI Template,&rdquo; March&nbsp;2012.</span><span>)</span></a> [RFC6570]. However, some special considerations apply:
  603. </p>
  604. <a name="anchor19"></a><br /><hr />
  605. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  606. <a name="rfc.section.5.1.1.1"></a><h3>5.1.1.1.&nbsp;
  607. Pre-processing</h3>
  608. <p>
  609. The <a class='info' href='#RFC6570'>URI Template specification<span> (</span><span class='info'>Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, &ldquo;URI Template,&rdquo; March&nbsp;2012.</span><span>)</span></a> [RFC6570] restricts the set of characters available for variable names.
  610. Property names in JSON, however, can be any UTF-8 string.
  611. </p>
  612. <p>
  613. To allow the use of any JSON property name in the template, before using the value of "href" as a URI Template, the following pre-processing rules MUST be applied, in order:
  614. </p>
  615. <a name="anchor20"></a><br /><hr />
  616. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  617. <a name="rfc.section.5.1.1.1.1"></a><h3>5.1.1.1.1.&nbsp;
  618. Bracket escaping</h3>
  619. <p>
  620. The purpose of this step is to allow the use of brackets to percent-encode variable names inside curly brackets.
  621. Variable names to be escaped are enclosed within rounded brackets, with the close-rounded-bracket character ")" being escaped as a pair of close-rounded-brackets "))".
  622. Since the empty string is not a valid variable name in RFC 6570, an empty pair of brackets is replaced with "%65mpty".
  623. </p>
  624. <p>
  625. The rules are as follows:
  626. </p>
  627. <p>
  628. Find the largest possible sections of the text such that:
  629. </p>
  630. <blockquote class="text">
  631. <p>do not contain an odd number of close-rounded-bracket characters ")" in sequence in that section of the text
  632. </p>
  633. <p>are surrounded by a pair of rounded brackets: ( ), where
  634. </p>
  635. <p>the surrounding rounded brackets are themselves contained within a pair of curly brackets: { }
  636. </p>
  637. </blockquote><p>
  638. </p>
  639. <p>
  640. Each of these sections of the text (including the surrounding rounded brackets) MUST be replaced, according to the following rules:
  641. </p>
  642. <blockquote class="text">
  643. <p>If the brackets contained no text (the empty string), then they are replaced with "%65mpty" (which is "empty" with a percent-encoded "e")
  644. </p>
  645. <p>Otherwise, the enclosing brackets are removed, and the inner text used after the following modifications
  646. </p>
  647. <blockquote class="text">
  648. <p>all pairs of close-brackets "))" are replaced with a single close bracket
  649. </p>
  650. <p>after that, the text is replaced with its percent-encoded equivalent, such that the result is a valid RFC 6570 variable name (note that this requires encoding characters such as "*" and "!")
  651. </p>
  652. </blockquote>
  653. </blockquote><p>
  654. </p>
  655. <a name="anchor21"></a><br /><hr />
  656. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  657. <a name="rfc.section.5.1.1.1.2"></a><h3>5.1.1.1.2.&nbsp;
  658. Replacing $</h3>
  659. <p>
  660. After the above substitutions, if the character "$" (dollar sign) appears within a pair of curly brackets, then it MUST be replaced with the text "%73elf" (which is "self" with a percent-encoded "s").
  661. </p>
  662. <p>
  663. The purpose of this stage is to allow the use of the instance value itself (instead of its object properties or array items) in the URI Template, by the special value "%73elf".
  664. </p>
  665. <a name="anchor22"></a><br /><hr />
  666. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  667. <a name="rfc.section.5.1.1.1.3"></a><h3>5.1.1.1.3.&nbsp;
  668. Choice of special-case values</h3>
  669. <p>
  670. The special-case values of "%73elf" and "%65mpty" were chosen because they are unlikely to be accidentally generated by either a human or automated escaping.
  671. </p>
  672. <a name="anchor23"></a><br /><hr />
  673. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  674. <a name="rfc.section.5.1.1.1.4"></a><h3>5.1.1.1.4.&nbsp;
  675. Examples</h3>
  676. <p>
  677. <p>For example, here are some possible values for "href", followed by the results after pre-processing:
  678. </p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  679. Input Output
  680. -----------------------------------------
  681. "no change" "no change"
  682. "(no change)" "(no change)"
  683. "{(escape space)}" "{escape%20space}"
  684. "{(escape+plus)}" "{escape%2Bplus}"
  685. "{(escape*asterisk)}" "{escape%2Aasterisk}"
  686. "{(escape(bracket)}" "{escape%28bracket}"
  687. "{(escape))bracket)}" "{escape%29bracket}"
  688. "{(a))b)}" "{a%29b}
  689. "{(a (b)))}" "{a%20%28b%29}
  690. "{()}" "{%65mpty}
  691. "{+$*}" "{+%73elf*}
  692. "{+($)*}" "{+%24*}
  693. </pre></div>
  694. <p>
  695. Note that in the final example, because the "+" was outside the brackets, it remained unescaped, whereas in the fourth example the "+" was escaped.
  696. </p>
  697. <a name="anchor24"></a><br /><hr />
  698. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  699. <a name="rfc.section.5.1.1.2"></a><h3>5.1.1.2.&nbsp;
  700. Values for substitution</h3>
  701. <p>
  702. After pre-processing, the URI Template is filled out using data from the instance.
  703. To allow the use of any object property (including the empty string), array index, or the instance value itself, the following rules are defined:
  704. </p>
  705. <p>
  706. For a given variable name in the URI Template, the value to use is determined as follows:
  707. </p>
  708. <blockquote class="text">
  709. <p>If the variable name is "%73elf", then the instance value itself MUST be used.
  710. </p>
  711. <p>If the variable name is "%65mpty", then the instances's empty-string ("") property MUST be used (if it exists).
  712. </p>
  713. <p>If the instance is an array, and the variable name is a representation of a non-negative integer, then the value at the corresponding array index MUST be used (if it exists).
  714. </p>
  715. <p>Otherwise, the variable name should be percent-decoded, and the corresponding object property MUST be used (if it exists).
  716. </p>
  717. </blockquote><p>
  718. </p>
  719. <a name="anchor25"></a><br /><hr />
  720. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  721. <a name="rfc.section.5.1.1.2.1"></a><h3>5.1.1.2.1.&nbsp;
  722. Converting to strings</h3>
  723. <p>
  724. When any value referenced by the URI template is null, a boolean or a number, then it should first be converted into a string as follows:
  725. </p>
  726. <blockquote class="text">
  727. <p>null values SHOULD be replaced by the text "null"
  728. </p>
  729. <p>boolean values SHOULD be replaced by their lower-case equivalents: "true" or "false"
  730. </p>
  731. <p>numbers SHOULD be replaced with their original JSON representation.
  732. </p>
  733. </blockquote><p>
  734. </p>
  735. <p>
  736. In some software environments the original JSON representation of a number will not be available (there is no way to tell the difference between 1.0 and 1), so any reasonable representation should be used.
  737. Schema and API authors should bear this in mind, and use other types (such as string or boolean) if the exact representation is important.
  738. </p>
  739. <a name="anchor26"></a><br /><hr />
  740. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  741. <a name="rfc.section.5.1.1.3"></a><h3>5.1.1.3.&nbsp;
  742. Missing values</h3>
  743. <p>
  744. Sometimes, the appropriate values will not be available.
  745. For example, the template might specify the use of object properties, but the instance is an array or a string.
  746. </p>
  747. <p>
  748. If any of the values required for the template are not present in the JSON instance, then substitute values MAY be provided from another source (such as default values).
  749. Otherwise, the link definition SHOULD be considered not to apply to the instance.
  750. </p>
  751. <a name="anchor27"></a><br /><hr />
  752. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  753. <a name="rfc.section.5.2"></a><h3>5.2.&nbsp;
  754. rel</h3>
  755. <p>
  756. The value of the "rel" property indicates the name of the relation to the target resource.
  757. This property is not optional.
  758. </p>
  759. <p>
  760. The relation to the target SHOULD be interpreted as specifically from the instance object that the schema (or sub-schema) applies to, not just the top level resource that contains the object within its hierarchy.
  761. A link relation from the top level resource to a target MUST be indicated with the schema describing the top level JSON representation.
  762. </p>
  763. <p>
  764. Relationship definitions SHOULD NOT be media type dependent, and users are encouraged to utilize existing accepted relation definitions, including those in existing relation registries (see <a class='info' href='#RFC4287'>RFC 4287<span> (</span><span class='info'>Nottingham, M., Ed. and R. Sayre, Ed., &ldquo;The Atom Syndication Format,&rdquo; December&nbsp;2005.</span><span>)</span></a> [RFC4287]).
  765. However, we define these relations here for clarity of normative interpretation within the context of JSON Schema defined relations:
  766. </p>
  767. <blockquote class="text"><dl>
  768. <dt>self</dt>
  769. <dd>
  770. If the relation value is "self", when this property is encountered in the instance object, the object represents a resource and the instance object is treated as a full representation of the target resource identified by the specified URI.
  771. </dd>
  772. <dt>full</dt>
  773. <dd>
  774. This indicates that the target of the link is the full representation for the instance object.
  775. The instance that contains this link may not be the full representation.
  776. </dd>
  777. <dt>describedBy</dt>
  778. <dd>
  779. This indicates the target of the link is a schema describing the instance object.
  780. This MAY be used to specifically denote the schemas of objects within a JSON object hierarchy, facilitating polymorphic type data structures.
  781. </dd>
  782. <dt>root</dt>
  783. <dd>
  784. This relation indicates that the target of the link SHOULD be treated as the root or the body of the representation for the purposes of user agent interaction or fragment resolution.
  785. All other data in the document can be regarded as meta-data for the document.
  786. The URI of this link MUST refer to a location within the instance document, otherwise the link MUST be ignored.
  787. </dd>
  788. </dl></blockquote><p>
  789. </p>
  790. <p>
  791. The following relations are applicable for schemas (the schema as the "from" resource in the relation):
  792. </p>
  793. <blockquote class="text"><dl>
  794. <dt>instances</dt>
  795. <dd>
  796. This indicates the target resource that represents a collection of instances of a schema.
  797. </dd>
  798. <dt>create</dt>
  799. <dd>
  800. This indicates a target to use for creating new instances of a schema.
  801. This link definition SHOULD be a submission link with a non-safe method (like POST).
  802. </dd>
  803. </dl></blockquote><p>
  804. Links defined in the schema using these relation values SHOULD not require parameterization with data from the instance, as they describe a link for the schema, not the instances.
  805. </p>
  806. <p>For example, if a schema is defined:
  807. </p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  808. {
  809. "links": [{
  810. "rel": "self",
  811. "href": "{id}"
  812. }, {
  813. "rel": "up",
  814. "href": "{upId}"
  815. }, {
  816. "rel": "children",
  817. "href": "?upId={id}"
  818. }]
  819. }
  820. </pre></div>
  821. <p>And if a collection of instance resources were retrieved with JSON representation:
  822. </p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  823. GET /Resource/
  824. [{
  825. "id": "thing",
  826. "upId": "parent"
  827. }, {
  828. "id": "thing2",
  829. "upId": "parent"
  830. }]
  831. </pre></div>
  832. <p>
  833. This would indicate that for the first item in the collection, its own (self) URI would resolve to "/Resource/thing" and the first item's "up" relation SHOULD be resolved to the resource at "/Resource/parent".
  834. The "children" collection would be located at "/Resource/?upId=thing".
  835. </p>
  836. <p>
  837. Note that these relationship values are case-insensitive, consistent with their use in HTML and the <a class='info' href='#RFC5988'>HTTP Link header<span> (</span><span class='info'>Nottingham, M., &ldquo;Web Linking,&rdquo; October&nbsp;2010.</span><span>)</span></a> [RFC5988].
  838. </p>
  839. <a name="anchor28"></a><br /><hr />
  840. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  841. <a name="rfc.section.5.2.1"></a><h3>5.2.1.&nbsp;
  842. Fragment resolution with &quot;root&quot; links</h3>
  843. <p>
  844. The presence of a link with relation "root" alters what the root of the document is considered to be.
  845. For fragment resolution methods (such as JSON Pointer fragments) that navigate through the document, the target of the "root" link should be the starting point for such methods.
  846. </p>
  847. <p>
  848. The only exception is "root" links themselves.
  849. When calculating the target of links with relation "root", existing "root" links MUST NOT be taken into consideration.
  850. </p>
  851. <p>
  852. <p>For example, say we have the following schema:
  853. </p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  854. {
  855. "links": [{
  856. "rel": "root",
  857. "href": "#/myRootData"
  858. }]
  859. }
  860. </pre></div>
  861. <p>
  862. <p>And the following data, returned from the URI: "http://example.com/data/12345":
  863. </p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  864. {
  865. "myRootData": {
  866. "title": "Document title"
  867. },
  868. "metaData": {
  869. ...
  870. }
  871. }
  872. </pre></div>
  873. <p>
  874. To correctly resolve the URL "http://example.com/data/12345", we must take the "root" link into account. Here are some example URIs, along with the data they would resolve to:
  875. </p>
  876. <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  877. URI Data
  878. -----------------------------------------------------------------------
  879. http://example.com/data/12345 {"title": "Document title"}
  880. http://example.com/data/12345#/title "Document title"
  881. </pre></div><p>
  882. </p>
  883. <a name="anchor29"></a><br /><hr />
  884. <table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
  885. <a name="rfc.section.5.2.2"></a><h3>5.2.2.&nbsp;
  886. Security Considerations for &quot;self&quot; links</h3>
  887. <p>
  888. When link relation of "self" is used to denote a full representation of an object, the user agent SHOULD NOT consider the representation to be the authoritative representation of the resource denoted by the target URI if the target URI is not equivalent to or a sub-path of the the URI used to request the resource representation which contains the ta