code: private void writeTimeMLDocument(Document xmlDoc, String filename) {
  		// create output file handle
  		File outFile = new File(mOutputDir, filename+".tml"); 
  		
  		BufferedWriter bw = null;
  		try {
  			// create a buffered writer for the output file
  			bw = new BufferedWriter(new FileWriter(outFile));
  			
  			// prepare the transformer to convert from the xml doc to output text
  			Transformer transformer = TransformerFactory.newInstance().newTransformer();
  			// some pretty printing
  			transformer.setOutputProperty(OutputKeys.INDENT, "no");
  			DOMSource source = new DOMSource(xmlDoc);
  			StreamResult result = new StreamResult(bw);
  			
  			// transform
  			transformer.transform(source, result);
  		} catch (IOException e) { // something went wrong with the bufferedwriter
  			e.printStackTrace();
  			Logger.printError(component, "File "+outFile.getAbsolutePath()+" could not be written.");
  		} catch (TransformerException e) { // the transformer malfunctioned (call optimus prime)
  			e.printStackTrace();
  			Logger.printError(component, "XML transformer could not be properly initialized.");
  		} finally { // clean up for the bufferedwriter
  			try {
  				bw.close();
  			} catch(IOException e) {
  				e.printStackTrace();
  				Logger.printError(component, "File "+outFile.getAbsolutePath()+" could not be closed.");
  			}
  		}
  	}
docs: writes a populated DOM xml(timeml) document to a given directory/file
  @param xmlDoc xml dom object
  @param filename name of the file that gets appended to the set output path