code: private void transform(File file, Source transformSource)
      throws TransformerConfigurationException, IOException, SAXException, TransformerException,
      ParserConfigurationException {
  
          Transformer transformer = m_transformerFactory.newTransformer(transformSource);
          transformer.setOutputProperty(OutputKeys.ENCODING, "us-ascii");
          transformer.setOutputProperty(OutputKeys.INDENT, "yes");
          transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
          String configDirPath = m_configDir.getAbsolutePath();
          configDirPath = configDirPath.replaceFirst("[/\\\\]$", "");
          transformer.setParameter("configDir", configDirPath);
          XMLReader reader = m_parserFactory.newSAXParser().getXMLReader();
          reader.setEntityResolver(NO_ENTITY_RESOLVER);
  
          Source source;
  
          if (file.exists()) {
              source = new SAXSource(reader, new InputSource(file.getCanonicalPath()));
          } else {
              source = new SAXSource(reader, new InputSource(new ByteArrayInputStream(DEFAULT_XML.getBytes("UTF-8"))));
          }
  
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          Result target = new StreamResult(baos);
          transformer.transform(source, target);
          byte[] transformedConfig = baos.toByteArray();
          try (FileOutputStream output = new FileOutputStream(file)) {
              output.write(transformedConfig);
          }
      }
docs: Transforms a single configuration file using the given transformation source.
  
  @param file the configuration file
  @param transformSource the transform soruce
  
  @throws TransformerConfigurationException -
  @throws IOException -
  @throws SAXException -
  @throws TransformerException -
  @throws ParserConfigurationException -