Re: Possible bug with null document in libyaml

William Spitzak <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
Ok, sounds reasonable.

In that case the bug is that libyaml output when told to write a single 
"" scalar, does not write the correct thing, instead writing text that 
looks the same as an empty document.

It is true that if you ask for document-start to be written it fixes it 
but there does not seem to be a requirement for that, and in fact I 
would prefer not to as the documents I am writing are so short that the 
extra 8 bytes are a significant fraction.

> It has always been the intent of YAML, that a Stream may contain zero or 
> more Documents. This implies that there needs to be a way to serialize 
> zero objects.
> 
> BTW, a stream containing just comments is another example of something 
> that will parse as having zero documents.
> 
> It may not be written like this in the spec, but one way to think of it 
> is as follows:
> 
>    1. Every YAML Document in a YAML Stream begins with '---'.
>    2. If the first thing a parser sees in a stream, after skipping all
>       ignorable whitespace (including comments), is not '---', nor a
>       YAML directive, the parser should assume it saw "---\n".
>    3. If, after skipping all ignorable whitespace, the parser reaches
>       the End Of Stream, it should report an STREAM_END event, without
>       reporting any documents.
> 
> Being able to serialize zero documents is important. For a real use 
> case, imagine a service listening for YAML documents over a web socket. 
> If the socket is closed after receiving no data, the service should 
> *not* parse that as one document containing an empty string.
> 
> After testing all these cases against libyaml, IMHO it gets things right 
> every time.
> 
> Cheers, Ingy
>  
> 
>     Thanks
>     Bill Spitzak
>     Rhythm & Hues software department.
> 
>     ------------------------------------------------------------------------------
>     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] <mailto:[email protected]>
>     https://lists.sourceforge.net/lists/listinfo/yaml-core
> 
> 

------------------------------------------------------------------------------
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
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.