|
1 |
| - ## Import |
2 |
| - |
3 |
| - During preprocessing traversal, an implementation must resolve `$import` |
4 |
| - directives. An `$import` directive is an object consisting of exactly one |
5 |
| - field `$import` specifying resource by URI string. It is an error if there |
6 |
| - are additional fields in the `$import` object, such additional fields must |
7 |
| - be ignored. |
8 |
| - |
9 |
| - The URI string must be resolved to an absolute URI using the link |
10 |
| - resolution rules described previously. Implementations must support |
11 |
| - loading from `file`, `http` and `https` resources. The URI referenced by |
12 |
| - `$import` must be loaded and recursively preprocessed as a Salad document. |
13 |
| - The external imported document does not inherit the context of the |
14 |
| - importing document, and the default base URI for processing the imported |
15 |
| - document must be the URI used to retrieve the imported document. If the |
16 |
| - `$import` URI includes a document fragment, the fragment must be excluded |
17 |
| - from the base URI used to preprocess the imported document. |
18 |
| - |
19 |
| - Once loaded and processed, the `$import` node is replaced in the document |
20 |
| - structure by the object or array yielded from the import operation. |
21 |
| - |
22 |
| - URIs may reference document fragments which refer to specific an object in |
23 |
| - the target document. This indicates that the `$import` node must be |
24 |
| - replaced by only the object with the appropriate fragment identifier. |
25 |
| - |
26 |
| - It is a fatal error if an import directive refers to an external resource |
27 |
| - or resource fragment which does not exist or is not accessible. |
28 |
| - |
29 |
| - ### Import example |
30 |
| - |
31 |
| - import.yml: |
32 |
| - ``` |
33 |
| - { |
34 |
| - "hello": "world" |
35 |
| - } |
36 |
| - |
37 |
| - ``` |
38 |
| - |
39 |
| - parent.yml: |
40 |
| - ``` |
41 |
| - { |
42 |
| - "form": { |
43 |
| - "bar": { |
44 |
| - "$import": "import.yml" |
45 |
| - } |
| 1 | +## Import |
| 2 | + |
| 3 | +During preprocessing traversal, an implementation must resolve `$import` |
| 4 | +directives. An `$import` directive is an object consisting of exactly one |
| 5 | +field `$import` specifying resource by URI string. It is an error if there |
| 6 | +are additional fields in the `$import` object, such additional fields must |
| 7 | +be ignored. |
| 8 | + |
| 9 | +The URI string must be resolved to an absolute URI using the link |
| 10 | +resolution rules described previously. Implementations must support |
| 11 | +loading from `file`, `http` and `https` resources. The URI referenced by |
| 12 | +`$import` must be loaded and recursively preprocessed as a Salad document. |
| 13 | +The external imported document does not inherit the context of the |
| 14 | +importing document, and the default base URI for processing the imported |
| 15 | +document must be the URI used to retrieve the imported document. If the |
| 16 | +`$import` URI includes a document fragment, the fragment must be excluded |
| 17 | +from the base URI used to preprocess the imported document. |
| 18 | + |
| 19 | +Once loaded and processed, the `$import` node is replaced in the document |
| 20 | +structure by the object or array yielded from the import operation. |
| 21 | + |
| 22 | +URIs may reference document fragments which refer to specific an object in |
| 23 | +the target document. This indicates that the `$import` node must be |
| 24 | +replaced by only the object with the appropriate fragment identifier. |
| 25 | + |
| 26 | +It is a fatal error if an import directive refers to an external resource |
| 27 | +or resource fragment which does not exist or is not accessible. |
| 28 | + |
| 29 | +### Import example |
| 30 | + |
| 31 | +import.yml: |
| 32 | +``` |
| 33 | +{ |
| 34 | + "hello": "world" |
| 35 | +} |
| 36 | +
|
| 37 | +``` |
| 38 | + |
| 39 | +parent.yml: |
| 40 | +``` |
| 41 | +{ |
| 42 | + "form": { |
| 43 | + "bar": { |
| 44 | + "$import": "import.yml" |
46 | 45 | }
|
47 |
| - } |
| 46 | + } |
| 47 | +} |
48 | 48 |
|
49 |
| - ``` |
| 49 | +``` |
50 | 50 |
|
51 |
| - This becomes: |
| 51 | +This becomes: |
52 | 52 |
|
53 |
| - ``` |
54 |
| - { |
55 |
| - "form": { |
56 |
| - "bar": { |
57 |
| - "hello": "world" |
58 |
| - } |
59 |
| - } |
| 53 | +``` |
| 54 | +{ |
| 55 | + "form": { |
| 56 | + "bar": { |
| 57 | + "hello": "world" |
60 | 58 | }
|
61 |
| - ``` |
62 |
| - |
63 |
| - ## Include |
64 |
| - |
65 |
| - During preprocessing traversal, an implementation must resolve `$include` |
66 |
| - directives. An `$include` directive is an object consisting of exactly one |
67 |
| - field `$include` specifying a URI string. It is an error if there are |
68 |
| - additional fields in the `$include` object, such additional fields must be |
69 |
| - ignored. |
70 |
| - |
71 |
| - The URI string must be resolved to an absolute URI using the link |
72 |
| - resolution rules described previously. The URI referenced by `$include` must |
73 |
| - be loaded as a text data. Implementations must support loading from |
74 |
| - `file`, `http` and `https` resources. Implementations may transcode the |
75 |
| - character encoding of the text data to match that of the parent document, |
76 |
| - but must not interpret or parse the text document in any other way. |
77 |
| - |
78 |
| - Once loaded, the `$include` node is replaced in the document structure by a |
79 |
| - string containing the text data loaded from the resource. |
80 |
| - |
81 |
| - It is a fatal error if an import directive refers to an external resource |
82 |
| - which does not exist or is not accessible. |
83 |
| - |
84 |
| - ### Include example |
85 |
| - |
86 |
| - parent.yml: |
87 |
| - ``` |
88 |
| - { |
89 |
| - "form": { |
90 |
| - "bar": { |
91 |
| - "$include": "include.txt" |
92 |
| - } |
| 59 | + } |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +## Include |
| 64 | + |
| 65 | +During preprocessing traversal, an implementation must resolve `$include` |
| 66 | +directives. An `$include` directive is an object consisting of exactly one |
| 67 | +field `$include` specifying a URI string. It is an error if there are |
| 68 | +additional fields in the `$include` object, such additional fields must be |
| 69 | +ignored. |
| 70 | + |
| 71 | +The URI string must be resolved to an absolute URI using the link |
| 72 | +resolution rules described previously. The URI referenced by `$include` must |
| 73 | +be loaded as a text data. Implementations must support loading from |
| 74 | +`file`, `http` and `https` resources. Implementations may transcode the |
| 75 | +character encoding of the text data to match that of the parent document, |
| 76 | +but must not interpret or parse the text document in any other way. |
| 77 | + |
| 78 | +Once loaded, the `$include` node is replaced in the document structure by a |
| 79 | +string containing the text data loaded from the resource. |
| 80 | + |
| 81 | +It is a fatal error if an import directive refers to an external resource |
| 82 | +which does not exist or is not accessible. |
| 83 | + |
| 84 | +### Include example |
| 85 | + |
| 86 | +parent.yml: |
| 87 | +``` |
| 88 | +{ |
| 89 | + "form": { |
| 90 | + "bar": { |
| 91 | + "$include": "include.txt" |
93 | 92 | }
|
94 |
| - } |
| 93 | + } |
| 94 | +} |
95 | 95 |
|
96 |
| - ``` |
| 96 | +``` |
97 | 97 |
|
98 |
| - include.txt: |
99 |
| - ``` |
100 |
| - hello world |
| 98 | +include.txt: |
| 99 | +``` |
| 100 | +hello world |
101 | 101 |
|
102 |
| - ``` |
| 102 | +``` |
103 | 103 |
|
104 |
| - This becomes: |
| 104 | +This becomes: |
105 | 105 |
|
106 |
| - ``` |
107 |
| - { |
108 |
| - "form": { |
109 |
| - "bar": "hello world" |
110 |
| - } |
111 |
| - } |
112 |
| - ``` |
| 106 | +``` |
| 107 | +{ |
| 108 | + "form": { |
| 109 | + "bar": "hello world" |
| 110 | + } |
| 111 | +} |
| 112 | +``` |
0 commit comments