docs: private String genElementDefinition(StructureDefinition sd, ElementDefinition ed) {
      String id = ed.hasBase() ? ed.getBase().getPath() : ed.getPath();
      String shortId = id.substring(id.lastIndexOf(".") + 1);
      String defn;
      ST element_def;
      String card = ("*".equals(ed.getMax()) ? (ed.getMin() == 0 ? "*" : "+") : (ed.getMin() == 0 ? "?" : "")) + ";";
  
      if(id.endsWith("[x]")) {
        element_def = ed.getType().size() > 1? tmplt(INNER_SHAPE_TEMPLATE) : tmplt(ELEMENT_TEMPLATE);
        element_def.add("id", "");
      } else {
        element_def = tmplt(ELEMENT_TEMPLATE);
        element_def.add("id", "fhir:" + (id.charAt(0) == id.toLowerCase().charAt(0)? shortId : id) + " ");
      }
  
      List<ElementDefinition> children = ProfileUtilities.getChildList(sd, ed);
      if (children.size() > 0) {
        innerTypes.add(new ImmutablePair<StructureDefinition, ElementDefinition>(sd, ed));
        defn = simpleElement(sd, ed, id);
      } else if(id.endsWith("[x]")) {
        defn = genChoiceTypes(sd, ed, id);
      }
      else if (ed.getType().size() == 1) {
        // Single entry
        defn = genTypeRef(sd, ed, id, ed.getType().get(0));
      } else if (ed.getContentReference() != null) {
        // Reference to another element
        String ref = ed.getContentReference();
        if(!ref.startsWith("#"))
          throw new AssertionError("Not equipped to deal with absolute path references: " + ref);
        String refPath = null;
        for(ElementDefinition ed1: sd.getSnapshot().getElement()) {
          if(ed1.getId() != null && ed1.getId().equals(ref.substring(1))) {
            refPath = ed1.getPath();
            break;
          }
        }
        if(refPath == null)
          throw new AssertionError("Reference path not found: " + ref);
        // String typ = id.substring(0, id.indexOf(".") + 1) + ed.getContentReference().substring(1);
        defn = simpleElement(sd, ed, refPath);
      } else if(id.endsWith("[x]")) {
        defn = genChoiceTypes(sd, ed, id);
      } else {
        // TODO: Refactoring required here
        element_def = genAlternativeTypes(ed, id, shortId);
        element_def.add("id", id.charAt(0) == id.toLowerCase().charAt(0)? shortId : id);
        element_def.add("card", card);
        addComment(element_def, ed);
        return element_def.render();
      }
      element_def.add("defn", defn);
      element_def.add("card", card);
      addComment(element_def, ed);
      return element_def.render();
    }