If you want to add some declaration in you document, you can use next code:

def xml = new MarkupBuilder(writer)
xml.mkp.xmlDeclaration(version:"1.0", encoding:"UTF-8")
...