Beispiel #1
0
  public boolean match(String search, Tag child, Tag mapping) {
    String target = child.getName();
    String sn = null;
    String tn = null;

    if (search.equals("*")) return true;

    int s = search.indexOf(':');
    if (s > 0) {
      sn = search.substring(0, s);
      search = search.substring(s + 1);
    }
    int t = target.indexOf(':');
    if (t > 0) {
      tn = target.substring(0, t);
      target = target.substring(t + 1);
    }

    if (!search.equals(target)) // different tag names
    return false;

    if (mapping == null) {
      return tn == sn || (sn != null && sn.equals(tn));
    } else {
      String suri =
          sn == null ? mapping.getAttribute("xmlns") : mapping.getAttribute("xmlns:" + sn);
      String turi =
          tn == null
              ? child.findRecursiveAttribute("xmlns")
              : child.findRecursiveAttribute("xmlns:" + tn);
      return turi == suri || (turi != null && suri != null && turi.equals(suri));
    }
  }