Execute the task.
DOMElementWriter writer = new DOMElementWriter(!append);
OutputStream os = null;
try {
if (file != null) {
os = new FileOutputStream(file.getAbsolutePath(), append);
} else {
os = new LogOutputStream(this, Project.MSG_INFO);
}
Node n = getFragment().getFirstChild();
if (n == null) {
throw new BuildException(ERROR_NO_XML);
}
writer.write((Element) n, os);
} catch (BuildException e) {
throw e;
} catch (Exception e) {
throw new BuildException(e);
} finally {
FileUtils.close(os);
}