Workaround for weird behaviour of the MarkupBuilder.

Nodes don't get created if an variable with the same name exists.
To work around this, I moved the whole xml generation code into
a static method.