YAML-노드 속성
각 프리젠 테이션 노드에는 anchor 과 tag. 노드 속성은 문자 스트림에서 생략 된 노드 내용으로 지정할 수 있습니다.
노드 표현의 기본 예는 다음과 같습니다.
%YAML 1.1
---
!!map {
? &A1 !!str "foo"
: !!str "bar",
? !!str &A2 "baz"
: *a1
}
노드 앵커
anchor 속성은 나중에 참조 할 수 있도록 노드를 나타냅니다. 노드에서 YAML 표현의 문자 스트림은ampersand (&) indicator. The YAML processor need not preserve the anchor name with the representation details composed in it. The following code explains this −
%YAML 1.1
---
!!map {
? !!str "First occurence"
: &A !!str "Value",
? !!str "Second occurence"
: *A
}
The output of YAML generated with anchor nodes is shown below −
---
!!map {
? !!str "First occurence"
: !!str "Value",
? !!str "Second occurence"
: !!str "Value",
}
Node Tags
The tag property represents the type of native data structure which defines a node completely. A tag is represented with the (!) indicator. Tags are considered as an inherent part of the representation graph. The following example of explains node tags in detail −
%YAML 1.1
---
!!map {
? !<tag:yaml.org,2002:str> "foo"
: !<!bar> "baz"
}
Node Content
Node content can be represented in a flow content or block format. Block content extends to the end of line and uses indentation to denote structure. Each collection kind can be represented in a specific single flow collection style or can be considered as a single block. The following code explains this in detail −
%YAML 1.1
---
!!map {
? !!str "foo"
: !!str "bar baz"
}
%YAML 1.1
---
!!str "foo bar"
%YAML 1.1
---
!!str "foo bar"
%YAML 1.1
---
!!str "foo bar\n"