docs: private ERERelation toRelation(final Element xml, final String docid) {
      relations++;
      final String id = generateID(XMLUtils.requiredAttribute(xml, "id"), docid);
      final String type = XMLUtils.requiredAttribute(xml, "type");
      final String subtype = XMLUtils.requiredAttribute(xml, "subtype");
  
      ERERelation.Builder builder = ERERelation.builder(id, type, subtype);
  
      // read in relation mentions
      for (Node child = xml.getFirstChild(); child != null; child = child.getNextSibling()) {
        if (child instanceof Element) {
          Element e = (Element) child;
          if (e.getTagName().equals("relation_mention")) {
            builder.withRelationMention(toRelationMention(e, docid));
          }
        }
      }
  
      ERERelation relation = builder.build();
      idMap.put(id, relation);
      return relation;
    }