Re: YAML document design.

William Spitzak <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
The second I think is better. I asked the same question earlier and got 
pretty much the same answer. In your first example also it would be 
impossible (or at least not consistent with yaml spec) to have a type 
with the name "data" or "children" or any or field name.

I may have cheated because I am preserving the "anchor/tag" values and 
using them as a name. Also I kept the types very short because I 
consider the "!" to make it clear it is a type. So the equivalent in my 
syntax is:

---
- !a &MyA
   data: data for a
   children:
   - !x &MyX {}
   - !y &MyY
   - !z &MyZ
- !b &MyB
...

You may have to alter the library you are using to match the newest YAML 
spec, which allows pretty much any printing character in the anchor/tag 
names. Also note that the order of the ! and & fields can be reversed 
and that libyaml produces them in the opposite order when writing.

Also the above example shows two possibilities for the "empty" x,y,z 
objects with no data fields. The first with {} is what libyaml produces 
if told to write an empty list (but if you look at the code, it goes 
through a good deal of trouble to do this). The second is what is 
produced if an empty scalar value is written instead of an empty list, 
and I am considering changing my program to use this syntax instead, 
mostly because it makes a lot more sense if yaml is supposed to be 
hand-editable.

Rob Mensching wrote:
> I've done plenty of work in XML. Now I'm looking into YAML to see how it 
> can make the same sort of content more approachable to humans. Given 
> that I'm relatively new to YAML, I'm hoping some people here can give me 
> some general guidance which designs are more "YAML-like" and not "too 
> much like XML". :)
> 
> Note: I'm also experimenting with YAML via Python so if things look "too 
> much like Python" then please set me straight there as well.
> 
> This style seems to be most YAML-like:
> 
> ---
> - a: MyA
>   data: data for a
>   children:
>   - x: MyX
>   - y: MyY
>   - z: MyZ
> - b: MyB
> ...
> 
> But this style was serializing better:
> 
> ---
> - !ObjectA
>   name: MyA
>   data: data for a
>   children:
>     - !ObjectX
>       name: MyX
>     - !ObjectY
>       name: MyY
>     - !ObjectZ
>       name: MyZ
> - !ObjectB
>   name: MyB
> ...
> 
> Any recommendations?
> 
> virtually, 
>    Rob Mensching
>    http://RobMensching.com LLC <http://RobMensching.com>
> 
> 
> ------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Yaml-core mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/yaml-core

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
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.