private static @Nullable XmlFile retrieveFile(final @Nullable XmlTag tag,
                                                final @NotNull String fileLocation,
                                                final @Nullable String version,
                                                String namespace,
                                                boolean nsDecl) {
    final String targetNs = XmlUtil.getTargetSchemaNsFromTag(tag);
    if (fileLocation.equals(targetNs)) {
      return null;
    }

    final XmlFile file = XmlUtil.getContainingFile(tag);
    if (file == null) return null;
    final PsiFile psiFile = ExternalResourceManager.getInstance().getResourceLocation(fileLocation, file, version);
    if (psiFile instanceof XmlFile) {
      return (XmlFile)psiFile;
    }

    return XmlNamespaceIndex.guessSchema(namespace, nsDecl ? null : tag.getLocalName(), version, fileLocation, file);
  }
private static @Nullable XmlFile retrieveFile(final @Nullable XmlTag tag,
                                                final @NotNull String fileLocation,
                                                final @Nullable String version,
                                                String namespace,
                                                boolean nsDecl)