
- •Table of Contents
- •Chapter 1. Introduction
- •1.1. Goals
- •1.2. Prior Art
- •1.3. Relation to XML
- •1.4. Terminology
- •Chapter 2. Preview
- •2.1. Collections
- •2.2. Structures
- •2.3. Scalars
- •2.4. Tags
- •2.5. Full Length Example
- •Chapter 3. Processing YAML Information
- •3.1. Processes
- •3.1.1. Represent
- •3.1.2. Serialize
- •3.1.3. Present
- •3.1.4. Parse
- •3.1.5. Compose
- •3.1.6. Construct
- •3.2. Information Models
- •3.2.1. Representation Graph
- •3.2.1.1. Nodes
- •3.2.1.2. Tags
- •3.2.1.3. Nodes Comparison
- •3.2.2. Serialization Tree
- •3.2.2.1. Keys Order
- •3.2.2.2. Anchors and Aliases
- •3.2.3. Presentation Stream
- •3.2.3.1. Node Styles
- •3.2.3.2. Scalar Formats
- •3.2.3.3. Comments
- •3.2.3.4. Directives
- •3.3. Loading Failure Points
- •3.3.1. Well-Formed and Identified
- •3.3.2. Resolved
- •3.3.3. Recognized and Valid
- •3.3.4. Available
- •Chapter 4. Syntax
- •4.1. Characters
- •4.1.1. Character Set
- •4.1.2. Character Encoding
- •4.1.3. Indicator Characters
- •4.1.4. Line Break Characters
- •4.1.5. Miscellaneous Characters
- •4.1.6. Escape Sequences
- •4.2. Syntax Primitives
- •4.2.1. Production Parameters
- •4.2.2. Indentation Spaces
- •4.2.3. Comments
- •4.2.4. Separation Spaces
- •4.2.5. Ignored Line Prefix
- •4.2.6. Line Folding
- •4.3. YAML Character Stream
- •4.3.1. Directives
- •4.3.1.2.1. Tag Prefixes
- •4.3.1.2.2. Tag Handles
- •4.3.2. Document Boundary Markers
- •4.3.3. Documents
- •4.3.4. Complete Stream
- •4.4. Nodes
- •4.4.1. Node Anchors
- •4.4.2. Node Tags
- •4.4.3. Node Content
- •4.4.4. Alias Nodes
- •4.4.5. Complete Nodes
- •4.4.5.1. Flow Nodes
- •4.4.5.2. Block Nodes
- •4.5. Scalar Styles
- •4.5.1. Flow Scalar Styles
- •4.5.1.1. Double Quoted
- •4.5.1.2. Single Quoted
- •4.5.1.3. Plain
- •4.5.2. Block Scalar Header
- •4.5.2.1. Block Style Indicator
- •4.5.2.2. Block Indentation Indicator
- •4.5.2.3. Block Chomping Indicator
- •4.5.3. Block Scalar Styles
- •4.5.3.1. Literal
- •4.5.3.2. Folded
- •4.6. Collection Styles
- •4.6.1. Sequence Styles
- •4.6.1.1. Flow Sequences
- •4.6.1.2. Block Sequences
- •4.6.2. Mapping Styles
- •4.6.2.1. Flow Mappings
- •4.6.2.2. Block Mappings
- •Terms Index

Syntax
4.4.4. Alias Nodes
Subsequent occurrences of a previously serialized node are presented as alias nodes, denoted by the “*” indicator. The first occurrence of the node must be marked by an anchor to allow subsequent occurrences to be presented as alias nodes. An alias node refers to the most recent preceding node having the same anchor. It is an error to have an alias node use an anchor that does not previously occur in the document. It is not an error to specify an anchor that is not used by any alias node. Note that an alias node must not specify any properties or content, as these were already specified at the first occurrence of the node.
[120] c-ns-alias-node ::= “*” ns-anchor-name
Example 4.47. Alias Nodes
First occurence: & anchor Value |
%YAML 1.1 |
|
Second occurence: *anchor |
--- |
|
!!map { |
||
|
||
Legend: |
? !!str "First occurence" |
|
: &A !!str "Value", |
||
c-ns-alias-node |
||
? !!str "Second occurence" |
||
ns-anchor-name |
||
: *A |
||
|
||
|
} |
4.4.5. Complete Nodes
4.4.5.1. Flow Nodes
A complete flow node is either an alias node presenting a second occurence of a previous node, or consists of the node properties followed by the node's content. A node with empty content is considered to be an empty plain scalar.
[121] ns-flow-node(n,c) ::= |
c-ns-alias-node | ns-flow-content(n,c) |
|
|
| ( c-ns-properties(n,c) |
|
|
( /* empty plain scalar content */ |
|
|
| ( s-separate(n,c) ns-flow-content(n,c) ) ) ) |
|
Example 4.48. Flow Nodes in Flow Context |
|
|
[ |
|
%YAML 1.1 |
Without properties , |
|
--- |
&anchor "Anchored" , |
|
!!seq [ |
|
!!str "Without properties", |
|
!!str 'Tagged' , |
|
|
|
&A !!str "Anchored", |
|
|
|
|
*anchor , # Alias node |
|
!!str "Tagged", |
!!str , # Empty plain scalar |
*A, |
] |
!!str "", |
|
] |
||
|
||
Legend: |
|
|
ns-flow-node(n,c) ns-flow-content(n,c) |
|
49
XSL• FO
RenderX

Syntax
Since both the node's properties and node content are optional, this allows for a completely empty node. Completely empty nodes are only valid when following some explicit indicator for their existance.
[122] e-empty-flow ::= /* empty plain scalar node */
In the examples, completely empty nodes are displayed as the glyph “°”. Note that this glyph corresponds to a position in the characters stream rather than to an actual character.
Example 4.49. Completely Empty Flow Nodes
{
? foo : °
, ?
°
: bar, ?
°
:
°
,
]
Legend:
e-empty-flow
%YAML 1.1
---
!!map {
?!!str "foo" : !!str "",
?!!str "",
:!!str "bar", ? !!str "",
:!!str ""
}
4.4.5.2. Block Nodes
A complete block node consists of the node's properties followed by the node's content. In addition, a block node may consist of a (possibly completely empty) flow node followed by a line break (with optional comments).
[123]ns-l+flow-in-block(n,c) ::= ns-flow-node(n+1,flow-out) s-l-comments
[124]ns-l+block-in-block(n,c) ::= ( c-ns-properties(n+1,c) s-separate(n+1,c) )?
c-l+block-content(n,c) ns-l+block-in-block(n,c)
| ns-l+flow-in-block(n,c)
[126] s-l+block-node(n,c) ::= s-separate(n+1,c) ns-l+block-node(n,c)
Example 4.50. Block Nodes
- ·
"flow in block"↓
- ·>
Block scalar↓
- ·!!map # Block collection foo : bar↓
Legend:
ns-l+flow-in-block(n,c)
ns-l+block-in-block(n,c)
s-l+block-node(n,c)
%YAML 1.1
---
!!seq [ !!str "", !!map {
?!!str "foo" : !!str "",
?!!str "",
:!!str "bar", ? !!str "",
:!!str ""
}
]
50
XSL• FO
RenderX