@Override
    public void validate(final @NotNull XmlTag tag, @NotNull ValidationHost host) {
      if (!isFromSchemaNs(tag)) return;
      final boolean hasRefAttribute = tag.getAttributeValue(REF_ATTR_NAME) != null;

      if (hasRefAttribute) {
        for (XmlAttribute attr : tag.getAttributes()) {
          final String name = attr.getName();

          if (name.indexOf(':') == -1 &&
              !MIN_OCCURS_ATTR_NAME.equals(name) &&
              !MAX_OCCURS_ATTR_NAME.equals(name) &&
              !ID_ATTR_NAME.equals(name) &&
              !REF_ATTR_NAME.equals(name)) {
            host.addMessage(
              attr.getNameElement(),
              XmlPsiBundle.message("xml.schema.validation.attr.not.allowed.with.ref", name),
              ValidationHost.ErrorType.ERROR
            );
          }
        }
      }

      final String minOccursValue = tag.getAttributeValue("minOccurs");
      final String maxOccursValue = tag.getAttributeValue(MAX_OCCURS_ATTR_VALUE);

      if (minOccursValue != null && maxOccursValue != null) {
        try {
          final int minOccurs = Integer.parseInt(minOccursValue);
          final int maxOccurs = Integer.parseInt(maxOccursValue);
          if (maxOccurs < minOccurs) {
            host.addMessage(
              tag.getAttribute(MAX_OCCURS_ATTR_VALUE, null).getValueElement(),
              XmlPsiBundle.message("xml.schema.validation.max.occurs.should.be.not.less.than.min.occurs"),
              ValidationHost.ErrorType.ERROR
            );
          }
        }
        catch (NumberFormatException e) {
          // this schema will be reported by xerces validation
        }
      }

      if (!hasRefAttribute && tag.getAttributeValue(NAME_ATTR_NAME) == null) {
        host.addMessage(
          tag,
          XmlPsiBundle.message("xml.schema.validation.name.or.ref.should.present"),
          ValidationHost.ErrorType.ERROR
        );
      }
    }
@Override
    public void validate(final @NotNull XmlTag tag, @NotNull ValidationHost host)