@SuppressWarnings("unused")
  @Override
  public Document createDocument(final Database db, final String doctype) {
    IDocumentDefinition def = getDocumentDefinitions().get(doctype);
    if (def == null) return null;
    Document result = db.createDocument();
    result.replaceItemValue("$$SchemaType", doctype);
    result.replaceItemValue("form", def.getName());
    Map<String, IItemDefinition> itemDefs = def.getItemDefinitions();
    for (String key : itemDefs.keySet()) {
      IItemDefinition itemDef = itemDefs.get(key);
      Item item = itemDef.createDefaultItem(result, def);
    }

    return result;
  }
  @Override
  public boolean validateDocument(final Document doc) {
    String doctype = doc.getItemValueString("$$SchemaType");
    IDocumentDefinition def = getDocumentDefinitions().get(doctype);
    if (def == null) return true;

    boolean result = true;
    Map<String, IItemDefinition> itemDefs = def.getItemDefinitions();
    for (String key : itemDefs.keySet()) {
      @SuppressWarnings("unused")
      IItemDefinition itemDef = itemDefs.get(key);
      // TODO NTF
    }

    return result;
  }