@Override
  @Nullable
  public @Nls String generateDoc(PsiElement element, @Nullable PsiElement originalElement) {
    final XmlElement c = PsiTreeUtil.getParentOfType(originalElement, XmlTag.class, XmlAttribute.class);
    if (c != null && c.getManager() == null) {
      LOG.warn("Invalid context element passed to generateDoc()", new Throwable("<stack trace>"));
      return null;
    }
    if (c instanceof XmlTag xmlElement) {
      final XmlElementDescriptor descriptor = xmlElement.getDescriptor();
      if (descriptor instanceof CompositeDescriptor d) {
        final StringBuilder sb = new StringBuilder();
        final DElementPattern[] patterns = d.getElementPatterns();
        final Set<PsiElement> elements = new ReferenceOpenHashSet<>();
        for (DElementPattern pattern : patterns) {
          final PsiElement psiElement = d.getDeclaration(pattern.getLocation());
          if (psiElement instanceof XmlTag && elements.add(psiElement)) {
            if (sb.length() > 0) {
              sb.append("<hr>");
            }
            sb.append(getDocumentationFromTag((XmlTag)psiElement, xmlElement.getLocalName(), "Element"));
          }
        }
        return makeDocumentation(sb);
      } else if (descriptor instanceof RngElementDescriptor) {
        final PsiElement declaration = descriptor.getDeclaration();
        if (declaration instanceof XmlTag) {
          return makeDocumentation(getDocumentationFromTag((XmlTag)declaration, xmlElement.getLocalName(), "Element"));
        }
      }
    } else if (c instanceof XmlAttribute attribute) {
      final XmlAttributeDescriptor descriptor = attribute.getDescriptor();
      if (descriptor instanceof RngXmlAttributeDescriptor) {
        final StringBuilder sb = new StringBuilder();
        final Collection<PsiElement> declaration = new ReferenceOpenHashSet<>(descriptor.getDeclarations());
        for (PsiElement psiElement : declaration) {
          if (psiElement instanceof XmlTag) {
            if (sb.length() > 0) {
              sb.append("<hr>");
            }
            sb.append(getDocumentationFromTag((XmlTag)psiElement, descriptor.getName(), "Attribute"));
          }
        }
        return makeDocumentation(sb);
      }
    } else if (element instanceof XmlTag) {
      return makeDocumentation(getDocumentationFromTag((XmlTag)element, ((XmlTag)element).getLocalName(), "Element"));
    }
    return null;
  }
@Override
  @Nullable
  public @Nls String generateDoc(PsiElement element, @Nullable PsiElement originalElement)