PsiFile (PsiFile baseFile, String location) { if (baseFile instanceof XmlFile) { XmlTag tag = ((XmlFile)baseFile).getRootTag(); if (tag != null) { XmlAttribute attribute = tag.getAttribute("schemaLocation", XmlUtil.XML_SCHEMA_INSTANCE_URI); if (attribute != null) { XmlAttributeValue element = attribute.getValueElement(); if (element != null) { PsiReference[] references = element.getReferences(); for (PsiReference reference : references) { if (location.equals(reference.getCanonicalText())) { PsiElement resolve = reference.resolve(); return resolve instanceof PsiFile ? (PsiFile)resolve : null; } } } } } } return null; }