protected XPathType getTypeForTag(XmlTag tag, String attribute) {
    String tagName = tag.getLocalName();
    if ("select".equals(attribute)) {
      if ("copy-of".equals(tagName) || "for-each".equals(tagName) || "apply-templates".equals(tagName)) {
        return XPathType.NODESET;
      } else if ("value-of".equals(tagName) || "sort".equals(tagName)) {
        return XPathType.STRING;
      }
      return XPathType.ANY;
    } else if ("test".equals(attribute)) {
      if ("if".equals(tagName) || "when".equals(tagName)) {
        return XPathType.BOOLEAN;
      }
    } else if ("number".equals(attribute)) {
      if ("value".equals(tagName)) {
        return XPathType.NUMBER;
      }
    }
    return XPathType.UNKNOWN;
  }
protected XPathType getTypeForTag(XmlTag tag, String attribute)