/** Save the modifications */
  public static String dumpNode(Node written) {
    Transformer transformer = null;
    try {
      transformer = ScilabTransformerFactory.newInstance().newTransformer();
    } catch (TransformerConfigurationException e1) {
      System.err.println("Cannot dump xml");
      return "";
    } catch (TransformerFactoryConfigurationError e1) {
      System.err.println("Cannot dump xml");
      return "";
    }
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");

    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    StreamResult result = new StreamResult(new BufferedOutputStream(stream));
    DOMSource source = new DOMSource(written);
    String str = "";
    try {
      transformer.transform(source, result);
      str = stream.toString();
    } catch (TransformerException e) {
      System.err.println("Cannot dump xml");
      return str;
    } finally {
      try {
        stream.close();
      } catch (Exception e) {
      }
    }

    return str;
  }
  /** Save the modifications */
  public static void writeDocument(String filename, Node written) {
    Transformer transformer = null;
    try {
      transformer = ScilabTransformerFactory.newInstance().newTransformer();
    } catch (TransformerConfigurationException e1) {
      System.err.println(ERROR_WRITE + filename);
      return;
    } catch (TransformerFactoryConfigurationError e1) {
      System.err.println(ERROR_WRITE + filename);
      return;
    }
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");

    StreamResult result = new StreamResult(new File(filename));
    DOMSource source = new DOMSource(written);
    try {
      transformer.transform(source, result);
    } catch (TransformerException e) {
      System.err.println(ERROR_WRITE + filename);
      return;
    }

    // Invalidate the current document
    if (filename.equals(USER_CONFIG_FILE)) {
      doc = null;
    }
  }