public void createXmlFromTemplate(String templateFileName, String fileName, HashMap<String, String> hmap) {
        try {
            DocumentBuilder rBuilder = init();
            Document rDoc = rBuilder.parse(templateFileName);
            Element rRoot = rDoc.getDocumentElement();

            DocumentBuilder wBuilder = init();
            Document wDoc = wBuilder.newDocument();

            if (wDoc != null) {
                Element wRoot = iterativeCreateElement(rRoot, hmap, wDoc);
                wDoc.appendChild(wRoot);

                // transform wDoc to streamOutput
                ((org.apache.crimson.tree.XmlDocument)wDoc).write(new FileOutputStream(fileName));
                // TransformerFactory transformerFactory = TransformerFactory.newInstance();
                // Transformer transformer = transformerFactory.newTransformer();
                // DOMSource source = new DOMSource(wDoc);
                // StreamResult result = new StreamResult(new File(fileName));
                // transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
                // transformer.transform(source, result);
            }
        } catch (FileNotFoundException e) {
            System.out.println(e.getMessage());
        } catch (SAXException e) {
            System.out.println(e.getMessage());
        } catch (IOException e) {
            System.out.println(e.getMessage());
        } 
      //   catch (TransformerException e) {
      //       System.out.println(e.getMessage());
      // }
    }