Gunnar doesn’t like the idea of recommending XML for configuration files

, why do you need to be able to edit a XML-file with a non-XML-aware editor if you don’t like the raw syntax?

If you don’t like the raw syntax, use an editor that gives you a different representation. Or use some transformation. Write a tool that converts YAML to XML and back, if you like YAML better. (Btw, this is another reason to use a common library for configuration file handling - let people choose their configuration file formats!)

Writing XML in the raw with a good schema-aware editor with syntax highlighting is actually quite nice. Have you ever edited an XML file with eclipse? You really should do that… I once opened my Openbox (a rather minimalistic window manager) configuration file in eclipse. Guess what, it was giving me useful syntax completion! It had loaded and used the referenced schema file.

openbox configuration in eclipse

It’s not as if I think XML is the ultimate thing; (nor is Eclipse an editor I’d use for configuration files; startup takes years and it frequently crashes for me. vim also has some XML support…) IMHO there is a lot in XML that should be stripped (such as attributes); I like JSON syntax better, except it’s in turn lacking essential information such as character encoding, namespaces and schema information. I also don’t thin JSON allows comments. But when handling information from multiple sources (and multiple schemes), XML is really useful. It removes most of the quessing needed for handling other formats.

And that is what I’m precisely advocating: use standardized formats. Consider for example the apache configuration. Do you know of any tool that can parse the apache configuration files other than apache? Some parts look like SGML/XML, but they don’t have much more in common than using < and >. When you are in need of automating something with apache, you’ll be annoyed by this. If apache would be using something where you have a reliable parser ready for - that would be nice.

Have a look at the xchat.conf configuration file. It uses “key = value”, but they have these extra spaces there and don’t use quoting, this means the file can’t be loaded by many parsers, e.g. bash. Now lets use at buttons.conf - compeltely different syntax, “KEY value” blocks, separated by empty lines…

Btw, note that configuration handling with XML to me means also keeping comments somehow… most applications will nuke any comments in their configuration files; which is funny since most configuration syntaxes do have a notion of comments, but did you ever come across an application using sh-style configuration (i.e. that you could source in bash/dash/zsh), that keeps comments?

P.S. The YAML homepage is not YAML. It’s valid XHTML. Only if you strip out all the tags and attributes and use only the text content within the /html/body/pre tag, then you have something which probably is YAML. This compatibility with HTML is probably why XML was at all successful.