@Override
  @NotNull
  public XPathType getExpectedType(XPathExpression expr) {
    final XmlTag tag = PsiTreeUtil.getContextOfType(expr, XmlTag.class, true);
    if (tag != null && XsltSupport.isXsltTag(tag)) {
      final XsltElement element = XsltElementFactory.getInstance().wrapElement(tag, XsltElement.class);
      if (element instanceof XsltVariable) {
        return ((XsltVariable)element).getType();
      } else {
        final XmlAttribute attr = PsiTreeUtil.getContextOfType(expr, XmlAttribute.class, true);
        if (attr != null) {
          if (element instanceof XsltWithParam) {
            final XmlAttribute nameAttr = tag.getAttribute("name", null);
            if (nameAttr != null) {
              final XmlAttributeValue valueElement = nameAttr.getValueElement();
              if (valueElement != null) {
                final PsiReference[] references = valueElement.getReferences();
                for (PsiReference reference : references) {
                  final PsiElement psiElement = reference.resolve();
                  if (psiElement instanceof XsltVariable) {
                    return ((XsltVariable)psiElement).getType();
                  }
                }
              }
            }
          } else {
            final String name = attr.getName();
            return getTypeForTag(tag, name);
          }
        }
      }
    }
    return XPathType.UNKNOWN;
  }
@Override
  @NotNull
  public XPathType getExpectedType(XPathExpression expr)