private void writeToFile(File template, Document document) throws Exception {
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    DOMSource source = new DOMSource(document);
    StreamResult result = new StreamResult(template);
    transformer.transform(source, result);
  }
Generates hive-default.xml.template from HiveConf.ConfVars
common/src/java/org/apache/hadoop/hive/ant/GenHiveTemplate.java