void (SAXParseException ex, PsiFile file, Document document, ValidationMessageConsumer consumer) { final String systemId = ex.getSystemId(); if (LOG.isDebugEnabled()) { LOG.debug("RNG Schema error: " + ex.getMessage() + " [" + systemId + "]"); } if (systemId != null) { final VirtualFile virtualFile = findVirtualFile(systemId); if (!Comparing.equal(virtualFile, file.getVirtualFile())) { return; } } final PsiElement at; final int line = ex.getLineNumber(); if (line > 0) { final int column = ex.getColumnNumber(); final int startOffset = document.getLineStartOffset(line - 1); if (column > 0) { if (file.getFileType() == RncFileType.getInstance()) { final PsiElement e = file.findElementAt(startOffset + column); if (e == null) { at = e; } else { at = file.findElementAt(startOffset + column - 1); } } else { at = file.findElementAt(startOffset + column - 2); } } else { final PsiElement e = file.findElementAt(startOffset); at = e != null ? PsiTreeUtil.nextLeaf(e) : null; } } else { final XmlDocument d = ((XmlFile)file).getDocument(); assert d != null; final XmlTag rootTag = d.getRootTag(); assert rootTag != null; at = rootTag.getFirstChild(); } final PsiElement host; if (file instanceof RncFile) { host = at; } else { host = PsiTreeUtil.getParentOfType(at, XmlAttribute.class, XmlTag.class); } if (at != null && host != null) { consumer.onMessage(host, ex.getLocalizedMessage()); } else { consumer.onMessage(file, ex.getLocalizedMessage()); } }