public void writeXmlFile( TProject project, File file )
  {
    try
    {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance() ;

      DocumentBuilder builder = factory.newDocumentBuilder() ;
      org.w3c.dom.Document document = builder.newDocument() ; // Create from whole cloth

      // main node
      Element root = ( Element ) document.createElement( "project" ) ;

      root.setAttribute( "type", project.getTypeName() ) ;

      // call the TProject export methode
      project.exportToXML( root, document ) ;

      document.appendChild( root ) ;

//      root.appendChild( document.createTextNode( "Some text" ) ) ;

      document.getDocumentElement().normalize() ;

      // Prepare the DOM document for writing
      Source source = new DOMSource( document ) ;

      // Prepare the output file
//      File file = new File( filename ) ;
      Result result = new StreamResult( file ) ;

      // Write the DOM document to the file
      Transformer xformer = TransformerFactory.newInstance().newTransformer() ;
      xformer.setOutputProperty( OutputKeys.METHOD, "xml" ) ;
      xformer.setOutputProperty( OutputKeys.INDENT, "yes" ) ;

      // this could be buggy because the default xalan transformer can't handle
      // empty strings (like "") correctly
      xformer.transform( source, result ) ;
    }
    catch ( ParserConfigurationException pce )
    {
      // Parser with specified options can't be built
      pce.printStackTrace() ;
    }
    catch ( TransformerConfigurationException e )
    {
    }
    catch ( TransformerException e )
    {
    }
    catch ( NullPointerException npe )
    {
      // @see xformer.transform( source, result)
      // @see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4981389
      // ..Xalan fails to use xmlns="" to unset the default namespace for a
      // nested element;..
      System.out.println( "could not write the project-file correctly" ) ;
      System.out.println( "Please try Java >= 1.5" ) ;
    }
  }