Re: Possible bug with null document in libyaml
Osamu TAKEUCHI <
osamu@...>
2009-11-21 09:35:52 GMT
Ingy,
> In addition, I point out that any empty string should not
> be encoded into empty nodes in YAML 1.1 document in any sense
> because it will not be compatible with YAML 1.2. In YAML 1.2 spec,
> an empty node represents a null object.
>
>
> To put a finer point on it, an empty node parses as a plain, (unquoted)
> empty string, scalar event. YAML loaders are encouraged (but not
> required) to construct a null object from this event.
>
> To be honest, I was not aware that this changed between 1.1 and 1.2. Can
> you point me to the appropriate part of the spec that says this?
According to the spec, this change was done for JSON compatibility.
A YAML 1.2 processor seems to be required to construct a null object
from an empty node.
In this point, YAML 1.2 is completely incompatible from YAML 1.1.
Please compare example 7.3 in YAML 1.2 spec with example 8.13 in
YAML 1.1 spec.
*** YAML 1.2 spec
Status of this Document
http://www.yaml.org/spec/1.2/spec.html
>>> this is a minor revision.
>>> ...
>>>
>>> We have removed unique implicit typing rules and have updated
>>> these rules to align them with JSON's productions.
7.2. Empty Nodes
http://www.yaml.org/spec/1.2/spec.html#id2786563
>>> Nodes with empty content are interpreted as if they were plain
>>> scalars with an empty value. Such nodes are commonly resolved
>>> to a "null" value.
Example 7.3. Completely Empty Flow Nodes
>>> {
>>> ? foo :,
>>> : bar,
>>> }
>>> %YAML 1.2
>>> ---
>>> !!map {
>>> ? !!str "foo" : !!null "",
>>> ? !!null "" : !!str "bar",
>>> }
10.2.1.1. Null
http://www.yaml.org/spec/1.2/spec.html#id2803362
>>> Note that a null is different from an empty string.
*** YAML 1.1 spec
8.5.1. Flow Nodes
http://yaml.org/spec/1.1/#id902924
>>> A node with empty content is considered to be an empty plain scalar.
Example 8.13. Completely Empty Flow Nodes
>>> {
>>> ? foo :,
>>> ? : bar,
>>> }
>>> %YAML 1.1
>>> ---
>>> !!map {
>>> ? !!str "foo"
>>> : !!str "",
>>> ? !!str "",
>>> : !!str "bar",
>>> }
Both the spec says an empty node is considered to be an empty plain scalar.
This seems to be the excuse how the spec describe YAML 1.2 is almost always
compatible to YAML 1.1. However, an empty plain scalar is considered as an
empty string in YAML 1.1 but as a null object in YAML 1.2.
Actually, in the type repository for _YAML1.1_ also specifies an empty
plain scalar value to be resolved as !!null type. It seems incompatible
to the YAML 1.1 spec. I imagine this is due to some historical reason.
*** Null Language-Independent Type for YAML Version 1.1
http://yaml.org/type/null.html
>>> Shorthand:
>>>
>>> !!null
>>>
>>> Regexp:
>>>
>>> ~ # (canonical)
>>> |null|Null|NULL # (English)
>>> | # (Empty)
This point was more clearly stated in this mailing list.
http://sourceforge.net/mailarchive/forum.php?thread_name=1248226963.15646.1326179237%40webmail.messagingengine.com&forum_name=yaml-core
I think it's better to point out this incompatibility more clearly in the
YAML 1.2 spec as well.
Best,
Osamu Takeuchi
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july