code: protected void compareDocument(Document control, Document test, 
                                     DifferenceListener listener, ElementQualifier elementQualifier) 
          throws DifferenceFoundException {
          DocumentType controlDoctype = control.getDoctype();
          DocumentType testDoctype = test.getDoctype();
          compare(getNullOrNotNull(controlDoctype), 
                  getNullOrNotNull(testDoctype), 
                  controlDoctype, testDoctype, listener, 
                  HAS_DOCTYPE_DECLARATION);
          if (controlDoctype!=null && testDoctype!=null) {
              compareNode(controlDoctype, testDoctype, listener, elementQualifier);
          }
      }
docs: Compare two Documents for doctype and then element differences
  @param control
  @param test
  @param listener
  @param elementQualifier
  @throws DifferenceFoundException