|
702 | 702 | ]
|
703 | 703 | }]]>
|
704 | 704 | </artwork>
|
705 |
| - <postamble> |
706 |
| - The self links here should always include the root node id, |
707 |
| - followed by an immediate parent id if one exists, and always ending |
708 |
| - with the id of the node that is the context of the self link. |
709 |
| - The context node's id resolves with the standard process and |
710 |
| - does not appear in "hrefPointers". The root id is located |
711 |
| - using an absolute JSON Pointer, while the parent node |
712 |
| - uses a Relative JSON Pointer, going up two levels (one level up |
713 |
| - is the array of children, two levels up is the whole parent node). |
714 |
| - </postamble> |
715 | 705 | </figure>
|
| 706 | + <t> |
| 707 | + The self links here should always include the root node id, |
| 708 | + followed by an immediate parent id if one exists, and always ending |
| 709 | + with the id of the node that is the context of the self link. |
| 710 | + </t> |
| 711 | + <t> |
| 712 | + The context node's id resolves with the standard process and |
| 713 | + does not appear in "hrefPointers". The root id is located |
| 714 | + using an absolute JSON Pointer, while the parent node |
| 715 | + uses a Relative JSON Pointer, going up two levels (one level up |
| 716 | + is the array of children, two levels up is the whole parent node). |
| 717 | + </t> |
| 718 | + <t> |
| 719 | + This design never has more than three ids in the URI. Nodes |
| 720 | + along the path between the root and the immediate parent, |
| 721 | + if any, are omitted. This illustrates a limitation of JSON Schema: |
| 722 | + Producing a variable-length path URI to any arbitrary depth is |
| 723 | + not possible without redesigning the representation to make an |
| 724 | + array of path ids available in each node. |
| 725 | + </t> |
716 | 726 | <figure>
|
717 | 727 | <preamble>
|
718 | 728 | Given the following instance:
|
|
726 | 736 | "id": 2,
|
727 | 737 | "children": [ {
|
728 | 738 | "id": 3
|
729 |
| -} ] } ] } ] }]]> |
| 739 | + } ] |
| 740 | + } ] |
| 741 | + } ] |
| 742 | +}]]> |
730 | 743 | </artwork>
|
731 | 744 | </figure>
|
732 | 745 | <t>
|
733 | 746 | We get the following self links for each node in the instance as identifed
|
734 | 747 | by JSON Pointers:
|
735 | 748 | <list style="hanging">
|
736 | 749 | <t hangText='"" (the root node)'>/trees/0/0</t>
|
737 |
| - <t hangText='"/children/0/children/0"'>/trees/0/0/1</t> |
738 |
| - <t hangText='"/children/0/children/0/children/0"'>/trees/0/1/2</t> |
739 |
| - <t hangText='"/children/0/children/0/children/0/children/0"'>/trees/0/2/3</t> |
| 750 | + <t hangText='"/children/0"'>/trees/0/0/1</t> |
| 751 | + <t hangText='"/children/0/children/0"'>/trees/0/1/2</t> |
| 752 | + <t hangText='"/children/0/children/0/children/0"'>/trees/0/2/3</t> |
740 | 753 | </list>
|
741 | 754 | This shows the use of an absolute JSON Pointer to always resolve
|
742 | 755 | the root node from any depth, and a Relative JSON Pointer to always resolve
|
743 | 756 | the immediate parent, which cannot be identified with an absolute pointer.
|
| 757 | + </t> |
| 758 | + <t> |
744 | 759 | For the root node, there is no defined parent, so per URI Template resolution
|
745 | 760 | rules, that variable and the path component that it would produce are simply
|
746 | 761 | omitted, giving us the desired URI with two components after "/trees".
|
|
0 commit comments