| 1 | <?xml version="1.0"?> |
|---|
| 2 | <!DOCTYPE article |
|---|
| 3 | PUBLIC "-//OASIS//DTD DocBook V4.2//EN" |
|---|
| 4 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> |
|---|
| 5 | |
|---|
| 6 | <article> |
|---|
| 7 | <articleinfo> |
|---|
| 8 | <title> |
|---|
| 9 | YAML Encoding Keys Language-Independent Type for |
|---|
| 10 | <trademark>YAML</trademark> Version 1.1 |
|---|
| 11 | </title> |
|---|
| 12 | |
|---|
| 13 | <subtitle> |
|---|
| 14 | Working Draft 2005-01-18 |
|---|
| 15 | </subtitle> |
|---|
| 16 | |
|---|
| 17 | <authorgroup> |
|---|
| 18 | <author> |
|---|
| 19 | <firstname>Oren</firstname> |
|---|
| 20 | <surname>Ben-Kiki</surname> |
|---|
| 21 | <email>oren@ben-kiki.org</email> |
|---|
| 22 | </author> |
|---|
| 23 | |
|---|
| 24 | <author> |
|---|
| 25 | <firstname>Clark</firstname> |
|---|
| 26 | <surname>Evans</surname> |
|---|
| 27 | <email>cce+yaml@clarkevans.com</email> |
|---|
| 28 | </author> |
|---|
| 29 | |
|---|
| 30 | <author> |
|---|
| 31 | <firstname>Brian</firstname> |
|---|
| 32 | <surname>Ingerson</surname> |
|---|
| 33 | <email>ingy@ttul.org</email> |
|---|
| 34 | </author> |
|---|
| 35 | </authorgroup> |
|---|
| 36 | |
|---|
| 37 | <copyright> |
|---|
| 38 | <year>2001-2005</year> |
|---|
| 39 | <holder>Oren Ben-Kiki<fo>, </fo></holder> |
|---|
| 40 | <holder>Clark Evans<fo>, </fo></holder> |
|---|
| 41 | <holder>Brian Ingerson</holder> |
|---|
| 42 | </copyright> |
|---|
| 43 | |
|---|
| 44 | <legalnotice> |
|---|
| 45 | This document may be freely copied provided it is not modified. |
|---|
| 46 | </legalnotice> |
|---|
| 47 | |
|---|
| 48 | <abstract> |
|---|
| 49 | <title>Status</title> |
|---|
| 50 | |
|---|
| 51 | <para> |
|---|
| 52 | This specification is a draft reflecting consensus reached by members of |
|---|
| 53 | the <ulink |
|---|
| 54 | url="http://lists.sourceforge.net/lists/listinfo/yaml-core">yaml-core |
|---|
| 55 | mailing list</ulink>. Any questions regarding this draft should be |
|---|
| 56 | raised on this list. |
|---|
| 57 | </para> |
|---|
| 58 | </abstract> |
|---|
| 59 | </articleinfo> |
|---|
| 60 | |
|---|
| 61 | <section> |
|---|
| 62 | <variablelist> |
|---|
| 63 | <varlistentry> |
|---|
| 64 | <term> |
|---|
| 65 | <para> |
|---|
| 66 | URI: |
|---|
| 67 | </para> |
|---|
| 68 | </term> |
|---|
| 69 | |
|---|
| 70 | <listitem> |
|---|
| 71 | <para> |
|---|
| 72 | <userinput>tag:yaml.org,2002:yaml</userinput> |
|---|
| 73 | </para> |
|---|
| 74 | </listitem> |
|---|
| 75 | </varlistentry> |
|---|
| 76 | |
|---|
| 77 | <varlistentry> |
|---|
| 78 | <term> |
|---|
| 79 | <para> |
|---|
| 80 | Shorthand: |
|---|
| 81 | </para> |
|---|
| 82 | </term> |
|---|
| 83 | |
|---|
| 84 | <listitem> |
|---|
| 85 | <para> |
|---|
| 86 | <userinput>!!yaml</userinput> |
|---|
| 87 | </para> |
|---|
| 88 | </listitem> |
|---|
| 89 | </varlistentry> |
|---|
| 90 | |
|---|
| 91 | <varlistentry> |
|---|
| 92 | <term> |
|---|
| 93 | <para> |
|---|
| 94 | Kind: |
|---|
| 95 | </para> |
|---|
| 96 | </term> |
|---|
| 97 | |
|---|
| 98 | <listitem> |
|---|
| 99 | <para> |
|---|
| 100 | Scalar. |
|---|
| 101 | </para> |
|---|
| 102 | </listitem> |
|---|
| 103 | </varlistentry> |
|---|
| 104 | |
|---|
| 105 | <varlistentry> |
|---|
| 106 | <term> |
|---|
| 107 | <para> |
|---|
| 108 | Canonical: |
|---|
| 109 | </para> |
|---|
| 110 | </term> |
|---|
| 111 | |
|---|
| 112 | <listitem> |
|---|
| 113 | <para> |
|---|
| 114 | N/A (single format). |
|---|
| 115 | </para> |
|---|
| 116 | </listitem> |
|---|
| 117 | </varlistentry> |
|---|
| 118 | |
|---|
| 119 | <varlistentry> |
|---|
| 120 | <term> |
|---|
| 121 | <para> |
|---|
| 122 | Regexp: |
|---|
| 123 | </para> |
|---|
| 124 | </term> |
|---|
| 125 | |
|---|
| 126 | <listitem> |
|---|
| 127 | <para> |
|---|
| 128 | <userinput>!|&|\*</userinput> |
|---|
| 129 | </para> |
|---|
| 130 | </listitem> |
|---|
| 131 | </varlistentry> |
|---|
| 132 | |
|---|
| 133 | <varlistentry> |
|---|
| 134 | <term> |
|---|
| 135 | <para> |
|---|
| 136 | Definition: |
|---|
| 137 | </para> |
|---|
| 138 | </term> |
|---|
| 139 | |
|---|
| 140 | <listitem> |
|---|
| 141 | <para> |
|---|
| 142 | Keys for encoding YAML in YAML. |
|---|
| 143 | </para> |
|---|
| 144 | |
|---|
| 145 | <para> |
|---|
| 146 | YAML encoding keys are used to denote YAML structure information. |
|---|
| 147 | The in-memory representation of these keys must be different from |
|---|
| 148 | any value in any other type family. Specifically, these in-memory |
|---|
| 149 | values must not be implemented as strings. Normally, the encoding |
|---|
| 150 | keys should not be used in serialized YAML documents; the encoded |
|---|
| 151 | YAML node is serialized instead. |
|---|
| 152 | </para> |
|---|
| 153 | |
|---|
| 154 | <para> |
|---|
| 155 | Encoding is useful when a YAML processor encounters a valid |
|---|
| 156 | YAML value of an unknown tag. For a schema-specific application, |
|---|
| 157 | this is not different from encountering any other valid YAML |
|---|
| 158 | document that does not satisfy the schema. Such an application may |
|---|
| 159 | safely use a processor that rejects any value of any unknown tag, |
|---|
| 160 | or discards the tag property with an appropriate warning and parses |
|---|
| 161 | the value as if the property was not present. |
|---|
| 162 | </para> |
|---|
| 163 | |
|---|
| 164 | <para> |
|---|
| 165 | For a schema-independent application (for example, a hypothetical |
|---|
| 166 | YAML pretty print application), this is not an option. Processors |
|---|
| 167 | used by such applications should encode the value instead. This may |
|---|
| 168 | be done by wrapping the value in a mapping containing encoding |
|---|
| 169 | keys. The <quote><userinput>!</userinput></quote> key denotes the |
|---|
| 170 | unsupported tag. In some cases it may be necessary to encode |
|---|
| 171 | anchors and alias nodes as well. The |
|---|
| 172 | <quote><userinput>&</userinput></quote> and |
|---|
| 173 | <quote><userinput>*</userinput></quote> keys are used for this |
|---|
| 174 | purpose. |
|---|
| 175 | </para> |
|---|
| 176 | |
|---|
| 177 | <para> |
|---|
| 178 | Encoding should be reversed on output, allowing the |
|---|
| 179 | schema-independent application to safely round-trip any valid YAML |
|---|
| 180 | document. In-memory, the encoded data may be accessed and |
|---|
| 181 | manipulated in a standard way using the three basic data types |
|---|
| 182 | (mapping, sequence and scalar), allowing limited processing to be |
|---|
| 183 | applied to arbitrary YAML data. |
|---|
| 184 | </para> |
|---|
| 185 | </listitem> |
|---|
| 186 | </varlistentry> |
|---|
| 187 | </variablelist> |
|---|
| 188 | |
|---|
| 189 | <example> |
|---|
| 190 | <title><userinput>!!yaml</userinput> Examples</title> |
|---|
| 191 | <programlisting> |
|---|
| 192 | # The following node should NOT be serialized this way. |
|---|
| 193 | encoded YAML node : |
|---|
| 194 | !!yaml '!' : '!type' |
|---|
| 195 | !!yaml '&' : 12 |
|---|
| 196 | !!value = : value |
|---|
| 197 | # The proper way to serialize the above node is as follows: |
|---|
| 198 | node : !type &12 value |
|---|
| 199 | </programlisting> |
|---|
| 200 | </example> |
|---|
| 201 | </section> |
|---|
| 202 | </article> |
|---|