From: <in...@tt...> - 2004-02-24 22:57:37
|
On 24/02/04 09:39 +0100, Brano Tich? wrote: > > > --- > > > ? : value of nothing > > > ... > > > correct? > > > > This actually is invalid YAML. When the explicit key indicator '?' is > > used, the ':' must be on a separate line and in the same column. > > > > --- > > ? > > : value of nothing > > ... > > > > oh, right, i missed this one. > > > The answer you are seeking is a little bit tricky, but is key to > > understanding the essence of YAML. An empty string is not really a null > > per se. It is an empty "scalar" that also has an empty "tag". YAML's > > type repository encourages this combination to be loaded into memory as > > a Python None or a Ruby null or a Perl undef. But (in the absence of a > > schema) a YAML loader can load it as anything. In fact, loaders are > > also encouraged to load all untagged scalars as strings. So how can they > > be encouraged to do both? It depends on how the application using YAML > > would like empty values served up. > > > > In other words, if there is no "schema" or "contract", two different > > loaders will probably load the same document in different ways. And this > > is perfectly OK. It all depends on the application that is using YAML. > > On the specific use case. > > > > You cannot take a random YAML document from Perl, pass it through Ruby, > > and expect it (beyond a shadow of a doubt) to come back intact. *Unless* > > there is a schema associated with the document. Or unless the classes in > > Perl and in Python have been designed to work with each other. Which is > > really a different form of a "schema" or "contract". > > > > Hope this helps. > > > > yes, this helps a lot. thank you. > i found several schema proposals at > http://yaml.freepan.org/index.cgi?SchemaProposals, > but is there any plans to have standard way to attach schema to document? > or is this again application specific? There will most likely be conventions that arise, and that YAML-core endorses. Take a sample document: --- !ingy.net,2004/floozle date: 1/2/2004 name: Duck Soup It is possible that a schema document could live at http://ingy.net/floozle/ Or perhaps an index lives there that points to a schema location. I'm sure Clark and Oren have ideas on how this might work. Cheers, Brian |