private static @Nullable XmlNSDescriptor getDescriptor(@NotNull XmlTag tag,
                                                         @Nullable XmlFile currentFile,
                                                         @NotNull String fileLocation,
                                                         @Nullable String namespace) {
    XmlNSDescriptor descriptor = getImplicitNamespaceDescriptor(tag, fileLocation);
    if (descriptor != null) {
      return descriptor;
    }

    if (currentFile == null) {
      final XmlDocument document = XmlUtil.getContainingFile(tag).getDocument();
      if (document != null) {
        String uri = XmlUtil.getDtdUri(document);
        if (uri != null) {
          XmlFile containingFile = XmlUtil.getContainingFile(document);
          XmlFile xmlFile = XmlUtil.findNamespace(containingFile, uri);
          XmlDocument xmlDocument = xmlFile == null ? null : xmlFile.getDocument();
          descriptor = (XmlNSDescriptor)(xmlDocument == null ? null : xmlDocument.getMetaData());
        }

        // We want to get fixed xmlns attr from dtd and check its default with requested namespace
        if (descriptor instanceof com.intellij.xml.impl.dtd.XmlNSDescriptorImpl) {
          final XmlElementDescriptor elementDescriptor = descriptor.getElementDescriptor(tag);
          if (elementDescriptor != null) {
            final XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor("xmlns", tag);
            if (attributeDescriptor != null && attributeDescriptor.isFixed()) {
              final String defaultValue = attributeDescriptor.getDefaultValue();
              if (defaultValue != null && defaultValue.equals(namespace)) {
                return descriptor;
              }
            }
          }
        }
      }
    }
    PsiMetaOwner currentOwner = retrieveOwner(tag, currentFile, namespace);
    if (currentOwner != null) {
      return (XmlNSDescriptor)currentOwner.getMetaData();
    }
    return null;
  }
private static @Nullable XmlNSDescriptor getDescriptor(@NotNull XmlTag tag,
                                                         @Nullable XmlFile currentFile,
                                                         @NotNull String fileLocation,
                                                         @Nullable String namespace)