PsiElement () { final String prefix = getCanonicalText(); XmlTag tag = PsiTreeUtil.getParentOfType(getElement(), XmlTag.class); while (tag != null) { if (tag.getLocalNamespaceDeclarations().containsKey(prefix)) { final XmlAttribute attribute = tag.getAttribute("xmlns:" + prefix, ""); final TextRange textRange = TextRange.from("xmlns:".length(), prefix.length()); return new SchemaPrefix(attribute, textRange, prefix); } tag = tag.getParentTag(); } return null; }