MyHost (@NotNull PsiFile file) { if (!(file instanceof XmlFile)) return null; final XmlDocument document = ((XmlFile)file).getDocument(); if (document == null) return null; XmlTag rootTag = document.getRootTag(); XmlNSDescriptor nsDescriptor = rootTag == null ? null : rootTag.getNSDescriptor(rootTag.getNamespace(), false); if (nsDescriptor instanceof Validator) { MyHost host = new MyHost(); ((Validator<XmlDocument>)nsDescriptor).validate(document, host); return host; } return null; }