Escape the XML Configuration Hell

In “The XML Configuration HellMatthieu Riou complains about using XML as a configuration file format. A clear disadvantage lies in XML’s verbosenes, although the original author forgets to mention it advantages: splitting of files using entities (a feature seldom used in practice), formal declaration and validation of structure with DTD and Schema, standard parsing utilities, XML support in most editors and so on.

Nevertheless I, personally, hate to write XML configuration files. Take Jetty [] as an example. Jetty is a java servlet engine and webserver that uses XML as it’s configuration format. Quickly commenting out a line to disable debug logging — a common task for any sysadmin — is just not possible because of the nature of XML. Any “linebased” file format has a clear advantage in this respect.

On the other side, the idea behind jetty’s xml configuration is nice, basically it’s a kind of xml-java scripting language. It provides a set of tags to instanciate objects (HTTPListeners, WebContext, Logger), to set properties on them and so on. It should be rather simple to throw the XML stuff away and replace it with a groovy configuration builder.

A short note to a comment from Gavin on the referenced article who claims that groovy would be much more verbose than a XML configuration: I doubt that this is true because of groovy’s NodeBuilder feature. This makes the following possible, which is not bigger then a comparable xml configuration:

server.config {
  log() {
    level(default: 'info')
    level(session: 'debug')

  webapps(basedir: '/usr/share/webapps/', hotredeploy: false) {
    webapp(path: '/opt/webapps/confluence.war')

{ Comments are closed! }