private XmlDocument createXmlDocument(final @NonNls CharSequence text, final @NonNls String fileName, FileType fileType) {
    PsiFile fileFromText = PsiFileFactory.getInstance(myProject).createFileFromText(fileName, fileType, text);

    XmlFile xmlFile;
    if (fileFromText instanceof XmlFile) {
      xmlFile = (XmlFile)fileFromText;
    }
    else {
      xmlFile = (XmlFile)fileFromText.getViewProvider().getPsi(((LanguageFileType)fileType).getLanguage());
      assert xmlFile != null;
    }
    XmlDocument document = xmlFile.getDocument();
    assert document != null;
    return document;
  }
private XmlDocument createXmlDocument(final @NonNls CharSequence text, final @NonNls String fileName, FileType fileType)