class XmlFile {

  public static XmlElement parseElements(ByteSource source, ToIntFunction<String> filterFn) {
    ArgChecker.notNull(source, "source");
    ArgChecker.notNull(filterFn, "filterFn");
    ToIntFunction<String> safeFilterFn = name -> Math.max(filterFn.applyAsInt(name), 0);
    return Unchecked.wrap(() -> {
      try (InputStream in = source.openBufferedStream()) {
        XMLStreamReader xmlReader = XML_FACTORY.createXMLStreamReader(in);
        try {
          return parseElements(xmlReader, safeFilterFn, Integer.MAX_VALUE);
        } finally {
          xmlReader.close();
        }
      }
    });
  }

  private  XmlFile(XmlElement root, Map<String, XmlElement> refs);

}