public static void write(Database model, Writer output) {
    try {
      output.write("<?xml version=\"1.0\"?>\n<!DOCTYPE database SYSTEM \"" + DTD_PREFIX + "\">\n");
      output.write("<database name=\"" + model.getName() + "\"");
      if (model.getCatalog() != null) {
        output.write(" catalog=\"" + model.getCatalog() + "\"");
      }
      if (model.getSchema() != null) {
        output.write(" schema=\"" + model.getSchema() + "\"");
      }
      if (model.getIdMethod() != null) {
        output.write(" defaultIdMethod=\"" + model.getIdMethod() + "\"");
      }
      output.write(">\n");

      for (Table table : model.getTables()) {
        write(table, output);
      }
      output.write("</database>\n");
    } catch (IOException e) {
      throw new IoException(e);
    }
  }