code: protected String getFullFormattedXml(final Node node, ComparisonType type, boolean formatXml) {
          StringBuilder sb = new StringBuilder();
          final Node nodeToConvert;
          if (type == ComparisonType.CHILD_NODELIST_SEQUENCE) {
              nodeToConvert = node.getParentNode();
          } else if (node instanceof Document) {
              Document doc = (Document)  node;
              appendFullDocumentHeader(sb, doc);
              return sb.toString();
          } else if (node instanceof DocumentType) {
              Document doc = node.getOwnerDocument();
              appendFullDocumentHeader(sb, doc);
              return sb.toString();
          } else if (node instanceof Attr) {
              nodeToConvert = ((Attr) node).getOwnerElement();
          } else if (node instanceof org.w3c.dom.CharacterData) {
              // in case of a simple text node, show the parent TAGs: "<a>xy</a>" instead "xy".
              nodeToConvert = node.getParentNode();
          } else {
              nodeToConvert = node;
          }
          sb.append(getFormattedNodeXml(nodeToConvert, formatXml));
          return sb.toString().trim();
      }
docs: Formats the node using a format suitable for the node type and comparison.
  
  <p>The implementation outputs the document prolog and start element for {@code Document} and {@code DocumentType}
  nodes and may elect to format the node's parent element rather than just the node depending on the node and
  comparison type. It delegates to {@link #appendFullDocumentHeader} or {@link #getFormattedNodeXml}.</p>
  
  @param node the node to format
  @param type the comparison type
  @param formatXml true if the Comparison was generated with {@link
  org.xmlunit.builder.DiffBuilder#ignoreWhitespace()} - this affects the indentation of the generated output
  @return the fomatted XML
  
  @since XMLUnit 2.4.0