/**
   * Generates the HTML for a Method element.
   *
   * @param layout A Method Element. Layout object.
   * @param linkedElements If not null, this object will be populated with a list of linked elements
   *     in the page.
   * @return A url of the generated content HTML file.
   */
  public String generateHtml(IElementLayout layout) {
    if (layout == null) {
      return "about:blank"; //$NON-NLS-1$
    }

    // System.out.println("*** generateHtml: " + LibraryUtil.getTypeName(layout.getElement()) );

    // add time logging when publishing element
    long time_start = Calendar.getInstance().getTimeInMillis();
    String elementPath = layout.getNoAdjustedElementPath().replace('/', File.separatorChar);
    String elementPathName = elementPath + layout.getFileName(ResourceHelper.FILE_EXT_HTML);
    String filePath = this.getPublishDir() + elementPath;
    String html_file = this.getPublishDir() + elementPathName;

    try {

      StringBuffer xml = getXml(layout);

      String xsl_uri;

      File f = new File(filePath);
      if (!f.exists()) {
        f.mkdirs();
      }

      // Generate the additonal outputs.
      List layouts = layout.getLayouts();
      xsl_uri = layoutXslRootPath + layout.getXslUrl();
      generateHtml(layout, xsl_uri, html_file, xml);

      // Generate other layout files.
      if (layouts != null && layouts.size() > 0) {
        for (Iterator it = layouts.iterator(); it.hasNext(); ) {
          LayoutInfo info = (LayoutInfo) it.next();
          xsl_uri = layoutXslRootPath + info.layout_xsl;
          String file = filePath + info.fileName;
          generateHtml(layout, xsl_uri, file, xml);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      html_file = null;
    }

    long time_end = Calendar.getInstance().getTimeInMillis();
    long mini_seconds = time_end - time_start;
    if (mini_seconds > 1000) {
      String msg =
          mini_seconds
              + " mini-second(s) publishing element "
              + LibraryUtil.getTypeName(layout.getElement())
              + "["
              + elementPathName
              + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      IContentValidator validator = getValidator();
      if (validator == null) {
        System.out.println(msg);
      } else {
        validator.logInfo(msg);
      }
    }
    if (html_file != null) {
      return html_file;
    }

    return "about:blank"; //$NON-NLS-1$
  }