Re: Possible bug with null document in libyaml

Ingy dot Net <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
On Fri, Nov 20, 2009 at 8:22 PM, Osamu TAKEUCHI <[email protected]> wrote:

> Bill and Ingy,
>
> Thanks Ingy. I finally understood the importance of providing a way to
> serialize zero objects by reading your post. Before that, I was thinking as
> the same as Bill.
>
> Then, according to the spec, a YAML serializer can encode an empty string
> (in YAML 1.1 document) or a null object (in YAML 1.2 document) as an empty
> node in all the cases except for the one where the whole YAML stream becomes
> empty.
> I think an explicit warning should be given in the spec to clarify this
> point with some explanation of the
> importance of providing a way to serialize zero objects.
> It will be very much helpful.
>
> 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?

--Ingy


> So, anyways, all the YAML 1.1 serializers should be patched to encode all
> the empty strings in quoted styles "" or ''.
>
>
> BTW, I do not think a YAML 1.1 library will accept "x" as a valid YAML
> stream if the library strictly implements the specification. In YAML 1.1, a
> plain scalar node must be followed by s-l-comments that contains at least
> one line break. So, "x\n" is a valid document but "x" is not.
>
> This is the same problem pointed out for YAML 1.2 spec, first by Joshua
> Choi,
>
>
> http://sourceforge.net/mailarchive/forum.php?thread_name=200e06280904252219i1da33755h200bdac14058ba36%40mail.gmail.com&forum_name=yaml-core
>
> and then by me.
>
>
> http://sourceforge.net/mailarchive/forum.php?thread_name=1254356424.5043.224.camel%40nero&forum_name=yaml-core
>
> Probably, most of the real implementations ignore the spec to be compatible
> with hand-written documents possibly without a line break at the end. But,
> at least, a YAML serializer should not output a YAML document without a line
> break at the end.
>
> 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

_______________________________________________
Yaml-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/yaml-core
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.