code: private Document getDocument() {
      Document document = new Document();
      Comment comment = new Comment(" generated on " + new Date() + " ");
      document.addContent(comment);
  
      Element rootElement = new Element(ROOT_ELEMENT_NAME);
      rootElement.setAttribute(MASTER_LANGUAGE_ATTRIBUTE_NAME, getMasterLanguage());
      for (Attribute attribute : additionalRootAttrs) {
        // need to set the attribute like a new attribute,
        // as the original one stored the parent element and cannot be set to a new parent
        rootElement.setAttribute(attribute.getName(), attribute.getValue(), attribute.getNamespace());
      }
      // set the namespace, this makes sure that it is written into the trema node
      for (Namespace namespace : additionalNamespaces) {
        rootElement.addNamespaceDeclaration(namespace);
      }
  
      for (ITextNode textNode : textNodeList) {
        String key = textNode.getKey();
        Element textElement = new Element(TEXT_ELEMENT_NAME);
        textElement.setAttribute(KEY_ATTRIBUTE_NAME, key);
  
        String context = textNode.getContext();
        Element contextElement = new Element(CONTEXT_ELEMENT_NAME);
        contextElement.setText(context);
        textElement.addContent(contextElement);
  
        IValueNode[] valueNodes = textNode.getValueNodes();
        for (IValueNode valueNode : valueNodes) {
          Element valueElement = new Element(VALUE_ELEMENT_NAME);
          valueElement.setAttribute(LANGUAGE_ATTRIBUTE_NAME, valueNode.getLanguage());
          valueElement.setAttribute(STATUS_ATTRIBUTE_NAME, valueNode.getStatus().getName());
          valueElement.setText(valueNode.getValue());
          textElement.addContent(valueElement);
        }
        rootElement.addContent(textElement);
      }
      document.setRootElement(rootElement);
      return document;
    }
docs: Creates a <code>Document</code> object for the current state of
  this xml database.
  @return a <code>Document</code> object.