private Document generateTemplate() throws Exception {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = dbf.newDocumentBuilder();
    Document doc = docBuilder.newDocument();
    doc.appendChild(doc.createProcessingInstruction(
        "xml-stylesheet", "type=\"text/xsl\" href=\"configuration.xsl\""));

    doc.appendChild(doc.createComment("""
        
           Licensed to the Apache Software Foundation (ASF) under one or more
           contributor license agreements.  See the NOTICE file distributed with
           this work for additional information regarding copyright ownership.
           The ASF licenses this file to You under the Apache License, Version 2.0
           (the "License"); you may not use this file except in compliance with
           the License.  You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
        """));

    Element root = doc.createElement("configuration");
    doc.appendChild(root);

    root.appendChild(doc.createComment(
        " WARNING!!! This file is auto generated for documentation purposes ONLY! "));
    root.appendChild(doc.createComment(
        " WARNING!!! Any changes you make to this file will be ignored by Hive.   "));
    root.appendChild(doc.createComment(
        " WARNING!!! You must make your changes in hive-site.xml instead.         "));

    root.appendChild(doc.createComment(" Hive Execution Parameters "));

    Thread.currentThread().setContextClassLoader(ShimLoader.class.getClassLoader());
    for (HiveConf.ConfVars confVars : HiveConf.ConfVars.values()) {
      if (confVars.isExcluded()) {
        // thought of creating template for each shims, but I couldn't generate proper mvn script
        continue;
      }
      Element property = appendElement(root, "property", null);
      appendElement(property, "name", confVars.varname);
      appendElement(property, "value", confVars.getDefaultExpr());
      appendElement(property, "description", normalize(confVars.getDescription()));
      // wish to add new line here.
    }
    return doc;
  }
Generates hive-default.xml.template from HiveConf.ConfVars
common/src/java/org/apache/hadoop/hive/ant/GenHiveTemplate.java