class XmlUsageCounter {

  private final Map<String,Integer> map = new HashMap<>();

  private void countElementsAndAttributes(InputStream in) throws XMLStreamException {
    XMLInputFactory inputFactory = XMLInputFactory.newInstance();
    XMLEventReader eventReader = inputFactory.createXMLEventReader(in);
    while (eventReader.hasNext()) {
      XMLEvent event = eventReader.nextEvent();
      if (event.isStartElement()) {
        String elementName = event.asStartElement().getName().getLocalPart();
        add(elementName);
        Iterator attributes = event.asStartElement().getAttributes();
        while (attributes.hasNext()) {
          Attribute att = (Attribute) attributes.next();
          add(elementName + "/" + att.getName());
        }
      }
    }
  }

  private void add(String name) {<FILL_FUNCTION_BODY>}

  private void printResult() {
    List<ElemCount> elemCounts = new ArrayList<>();
    for (Map.Entry<String, Integer> entry : map.entrySet()) {
      elemCounts.add(new ElemCount(entry.getKey(), entry.getValue()));
    }
    Collections.sort(elemCounts, (ec1, ec2) -> ec2.count - ec1.count);
    for (ElemCount elemCount : elemCounts) {
      System.out.println(elemCount.count + " " + elemCount.elem);
    }
  }

  public static void main(String[] args) throws XMLStreamException {
    XmlUsageCounter counter = new XmlUsageCounter();
    Set<String> countedFiles = new HashSet<>();
    for (Language language : Languages.get()) {
      List<String> ruleFileNames = language.getRuleFileNames();
      //comment in this to count disambiguation files instead:
      //List<String> ruleFileNames = Collections.singletonList(ResourceDataBroker.RESOURCE_DIR + "/" +
      //        language.getShortCode() + "/" + "disambiguation.xml");
      for (String ruleFileName : ruleFileNames) {
        if (countedFiles.contains(ruleFileName)) {
          continue;
        }
        System.err.println("Counting elements for " + ruleFileName);
        InputStream ruleStream = XmlUsageCounter.class.getResourceAsStream(ruleFileName);
        if (ruleStream == null) {
          System.err.println("Not found, ignoring: " + ruleFileName);
          continue;
        }
        counter.countElementsAndAttributes(ruleStream);
        countedFiles.add(ruleFileName);
      }
    }
    counter.printResult();
  }

  static class ElemCount {
    String elem;
    Integer count;
    ElemCount(String elem, Integer count) {
      this.elem = elem;
      this.count = count;
    }
  }
}

    if (map.containsKey(name)) {
      int oldCount = map.get(name);
      map.put(name, oldCount+1);
    } else {
      map.put(name, 1);
    }
  
<no_super_class>