Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Ben-Kiki O.YAML ain't markup language.V1.1.pdf
Скачиваний:
8
Добавлен:
23.08.2013
Размер:
1.06 Mб
Скачать

Processing YAML Information

Figure 3.4. Serialization Model

3.2.2.1. Keys Order

In the representation model, mapping keys do not have an order. To serialize a mapping, it is necessary to impose an ordering on its keys. This order is a serialization detail and should not be used when composing the representation graph (and hence for the preservation of important data). In every case where node order is significant, a sequence must be used. For example, an ordered mapping can be represented as a sequence of mappings, where each mapping is a single key: value pair. YAML provides convenient compact notation for this case.

3.2.2.2. Anchors and Aliases

In the representation graph, a node may appear in more than one collection. When serializing such data, the first occurrence of the node is identified by an anchor and each subsequent occurrence is serialized as an alias node which refers back to this anchor. Otherwise, anchor names are a serialization detail and are discarded once composing is completed. When composing a representation graph from serialized events, an alias node refers to the most recent node in the serialization having the specified anchor. Therefore, anchors need not be unique within a serialization. In addition, an anchor need not have an alias node referring to it. It is therefore possible to provide an anchor for all nodes in serialization.

3.2.3. Presentation Stream

A YAML presentation is a stream of Unicode characters making use of of styles, formats, comments, directives and other presentation details to present a YAML serialization in a human readable way. Although a YAML processor may provide these details when parsing, they should not be reflected in the resulting serialization. YAML allows several serializations to be contained in the same YAML character stream as a series of documents separated by document boundary markers.

15

XSLFO

RenderX

Processing YAML Information

Documents appearing in the same stream are independent; that is, a node must not appear in more than one serialization tree or representation graph.

Figure 3.5. Presentation Model

3.2.3.1. Node Styles

Each node is presented in some style, depending on its kind. The node style is a presentation detail and is not reflected in the serialization tree or representation graph. There are two groups of styles, block and flow. Block styles use indentation to denote nesting and scope within the document. In contrast, flow styles rely on explicit indicators to denote nesting and scope.

YAML provides a rich set of scalar styles. Block scalar styles include the literal style and the folded style; flow scalar styles include the plain style and two quoted styles, the single quoted style and the double quoted style. These styles offer a range of trade-offs between expressive power and readability.

Normally, the content of block collections begins on the next line. In most cases, YAML also allows block collections to start in-line for more compact notation when nesting block sequences and block mappings inside each other. When nesting flow collections, a flow mapping with a single key: value pair may be specified directly inside a flow sequence, allowing for a compact “ordered mapping” notation.

16

XSLFO

RenderX

Соседние файлы в предмете Электротехника