Sean mentioned the idea of using YAML for MapServer configuration files instead of XML. I wholeheartedly agree. The most important thing for a configuration file is that it is easily readable and editable. YAML’s simpler syntax and conciseness is a big win in this case.

After reading his article, a brilliant idea occurred to me (well, at least I thought it was brilliant!) – use YAML to serialize RDF. RDF’s graph data model maps poorly onto XML’s hierarchical model, making RDF’s XML serialization format more complicated than RDF itself. This complexity has been the subject of endless debates and has led to a number of alternative syntaxes over the years, such as Notationm3, Turtle, RPV, etc. Yet none of them have have been widely adopted.

XML’s main advantages, compared to other serialization formats, are its extensibility, strong internationalization support and strong tool support.

A quick look at the YAML specification shows it supports UTF8 and UTF16 encodings, so its internationalization support looks good (I haven’t done any testing to see if the reality is different). YAML’s tool support is also good – you can find YAML parsers for Ruby, Python, PHP, JavaScript (using the JSON subset) and other languages as well.

Just like with XML, you can serialize custom vocabularies using YAML. However, YAML lacks a schema language. But if you’re using RDF and require a schema, then clearly you will use RDF schema. RDF schema reuses the RDF XML serialization format, so I would take the same approach with YAML and use it to both encode RDF and RDF schemas.

Curious to see what work has been done in this area, I did a quick search. It turns out that Micah Dubinko suggested using YAML for RDF more than three years ago on the xml-dev mailing list.

As far as implementations, the only example I could find was a Perl module
hasn’t bee updated since 2003. Now that some of the hype around XML has died own, and YAML has established itself as a legitimate format, it seems like a good time to revisit this idea.

  1. Bruce
    July 31, 2006

    Actually, N3 *is* widely used and supported in RDF tools. It seems to me intuitively wrong to use YAML in this case when N3 is good, designed based on similar broad principle as YAML, but expressly for RDF. Can you even do QNames in YAML?

  2. Charlie Savage –
    July 31, 2006

    Hi Bruce,

    Thanks for letting me know that N3 is more widely used than I thought. I’d agree that there isn’t any benefit switching from N3 to YAML, I was more interested in avoiding RDF’s xml serialization format.

    As far as QNames, I think you could achieve similar functionality via YAML’s [tags](http://yaml.org/spec/current.html#id2503753) – see why’s [post](http://redhanded.hobix.com/inspect/yamlOnePointOneWorkingDraft.html) for a bit more background.