public static String describeBinding(
     String prefix, ElementDefinitionBindingComponent def, PageProcessor page) throws Exception {
   if (!def.hasValueSet()) return def.getDescription();
   String ref =
       def.getValueSet() instanceof UriType
           ? ((UriType) def.getValueSet()).asStringValue()
           : ((Reference) def.getValueSet()).getReference();
   ValueSet vs = page.getValueSets().get(ref);
   if (vs != null) {
     String pp = (String) vs.getUserData("path");
     return def.getDescription()
         + "<br/>"
         + conf(def)
         + "<a href=\""
         + prefix
         + pp.replace(File.separatorChar, '/')
         + "\">"
         + vs.getName()
         + "</a>"
         + confTail(def);
   }
   if (ref.startsWith("http:") || ref.startsWith("https:"))
     return def.getDescription()
         + "<br/>"
         + conf(def)
         + " <a href=\""
         + ref
         + "\">"
         + ref
         + "</a>"
         + confTail(def);
   else
     return def.getDescription()
         + "<br/>"
         + conf(def)
         + " ?? Broken Reference to "
         + ref
         + " ??"
         + confTail(def);
 }
  private void gen(String prefix, Map<BindingSpecification, List<CDUsage>> txusages2)
      throws Exception {
    List<BindingSpecification> cds = new ArrayList<BindingSpecification>();
    cds.addAll(txusages.keySet());
    if (cds.size() == 0) return;

    Collections.sort(cds, new MyCompare());
    write("<h3>\r\nTerminology Bindings\r\n</h3>\r\n");
    // 1. new form
    write("<table class=\"grid\">\r\n");
    write(" <tr><th>Path</th><th>Definition</th><th>Type</th><th>Reference</th></tr>\r\n");
    for (BindingSpecification cd : cds) {
      String path;
      List<CDUsage> list = txusages.get(cd);
      for (int i = 2; i < list.size(); i++) {
        if (!list.get(i).element.typeCode().equals(list.get(1).element.typeCode()))
          throw new Exception(
              "Mixed types on one concept domain in one type - not yet supported by the build process for binding "
                  + cd.getName());
      }
      String name = cd.getValueSet() != null ? cd.getValueSet().getName() : cd.getName();
      write(" <tr><td valign=\"top\" title=\"" + name + "\">");
      boolean first = true;
      for (int i = 1; i < list.size(); i++) {
        if (!first) write("<br/>");
        first = false;
        write(list.get(i).path);
      }
      write(" </td>");
      write("<td valign=\"top\">" + Utilities.escapeXml(cd.getDefinition()) + "</td>");
      if (cd.getBinding() == BindingMethod.Unbound)
        write("<td>Unknown</td><td valign=\"top\">No details provided yet</td>");
      else {
        write(
            "<td><a href=\""
                + prefix
                + "terminologies.html#"
                + cd.getStrength().toCode()
                + "\">"
                + cd.getStrength().getDisplay()
                + "</a></td>");
        write("<td valign=\"top\">");
        if (cd.getBinding() == BindingSpecification.BindingMethod.Special) {
          if (name.equals("MessageEvent"))
            write(
                "<a href=\""
                    + prefix
                    + "valueset-message-events.html\">http://hl7.org/fhir/valueset/message-events</a>");
          else if (name.equals("ResourceType"))
            write(
                "<a href=\""
                    + prefix
                    + "valueset-resource-types.html\">http://hl7.org/fhir/valueset/resource-types</a>");
          else if (name.equals("DataType"))
            write(
                "<a href=\""
                    + prefix
                    + "valueset-data-types.html\">http://hl7.org/fhir/valueset/data-types</a>");
          else if (name.equals("FHIRDefinedType"))
            write(
                "<a href=\""
                    + prefix
                    + "valueset-defined-types.html\">http://hl7.org/fhir/valueset/defined-types</a>");
          else throw new Exception("Unknown special type " + name);
        }
        if (cd.getValueSet() != null) {
          ValueSet vs = cd.getValueSet();
          String pp = (String) vs.getUserData("path");
          if (pp == null) throw new Exception("unknown path on " + cd.getReference());
          write(
              "<a href=\""
                  + prefix
                  + pp.replace(File.separatorChar, '/')
                  + "\">"
                  + vs.getName()
                  + "</a><!-- b -->");
        } else if (cd.getBinding() == BindingSpecification.BindingMethod.ValueSet) {
          if (Utilities.noString(cd.getReference())) write("??");
          else if (cd.getReference().startsWith("valueset-"))
            write(
                "<a href=\""
                    + prefix
                    + cd.getReference()
                    + ".html\">http://hl7.org/fhir/ValueSet/"
                    + cd.getReference().substring(9)
                    + "</a><!-- a -->");
          else if (cd.getReference().startsWith("http://hl7.org/fhir")) {
            if (cd.getReference().startsWith("http://hl7.org/fhir/ValueSet/v3-")) {
              ValueSet vs = page.getValueSets().get(cd.getReference());
              String pp = (String) vs.getUserData("path");
              if (pp == null) throw new Exception("unknown path on " + cd.getReference());
              write(
                  "<a href=\""
                      + prefix
                      + pp.replace(File.separatorChar, '/')
                      + "\">"
                      + cd.getReference()
                      + "</a><!-- b -->");
            } else if (cd.getReference().startsWith("http://hl7.org/fhir/ValueSet/v2-")) {
              ValueSet vs = page.getValueSets().get(cd.getReference());
              String pp = (String) vs.getUserData("path");
              write(
                  "<a href=\""
                      + prefix
                      + pp.replace(File.separatorChar, '/')
                      + "\">"
                      + cd.getReference()
                      + "</a><!-- c -->");
            } else if (cd.getReference().startsWith("http://hl7.org/fhir/ValueSet/")) {
              String ref = getBindingLink(cd);
              write("<a href=\"" + prefix + ref + "\">" + cd.getReference() + "</a><!-- d -->");
              //              BindingSpecification bs1 =
              // page.getDefinitions().getBindingByURL(cd.getReference());
              //              if (bs1 != null)
              //                write("<a
              // href=\""+cd.getReference().substring(23)+".html\">"+cd.getReference()+"</a><!-- d
              // -->");
              //              else
              //                write("<a
              // href=\"valueset-"+cd.getReference().substring(23)+".html\">"+cd.getReference()+"</a><!-- d -->");
            } else
              throw new Exception("Internal reference " + cd.getReference() + " not handled yet");
          } else if (cd.getReference().startsWith("http:"))
            write("<a href=\"" + cd.getReference() + "\">" + cd.getReference() + "</a><!-- e -->");
          else
            write(
                "<a href=\""
                    + prefix
                    + "valueset-"
                    + cd.getReference()
                    + ".html\">http://hl7.org/fhir/"
                    + cd.getReference()
                    + "</a><!-- e -->");
        } else if (cd.getBinding() == BindingSpecification.BindingMethod.CodeList) {
          write(
              "<a href=\""
                  + prefix
                  + "valueset-"
                  + cd.getReference().substring(1)
                  + ".html\">http://hl7.org/fhir/"
                  + cd.getReference().substring(1)
                  + "</a><!-- f -->");
        } else if (cd.getBinding() == BindingSpecification.BindingMethod.Reference) {
          write(
              "<a href=\""
                  + prefix
                  + cd.getReference()
                  + "\">"
                  + cd.getDescription()
                  + "</a><!-- g -->");
        }

        write("</td>");
      }
      write(" </tr>\r\n");
    }
    write("</table>\r\n<p> </p>\r\n");
  }