PsiElementVisitor (@NotNull final ProblemsHolder holder, final boolean isOnTheFly) { if (!(holder.getFile() instanceof XmlFile)) return PsiElementVisitor.EMPTY_VISITOR; final XsltElementFactory xsltElementFactory = XsltElementFactory.getInstance(); return new XmlElementVisitor() { @Override public void visitXmlTag(@NotNull XmlTag tag) { if (XsltSupport.isTemplateCall(tag)) { final XsltCallTemplate call = xsltElementFactory.wrapElement(tag, XsltCallTemplate.class); checkTemplateInvocation(call, holder, isOnTheFly); } else if (XsltSupport.isApplyTemplates(tag)) { final XsltApplyTemplates call = xsltElementFactory.wrapElement(tag, XsltApplyTemplates.class); checkTemplateInvocation(call, holder, isOnTheFly); } } }; }