Next / Previous / Contents / NM Tech homepage

7.6.2. The html-lit-block template: Formatting a literate block

This template is a slightly modified version of the programlisting template from the stock version in html/verbatim.xsl. We generate an HTML pre element with a class='executable' attribute, which is styled by the rule in Section 10.4.1, “pre.executable.

zdp_html.xsl
<!--Literate code block-->
<xsl:template name="html-lit-block">
  <xsl:param name="suppress-numbers" select="'0'"/>
  <xsl:variable name="id">
    <xsl:call-template name="object.id"/>
  </xsl:variable>

  <xsl:call-template name="anchor"/>

  <xsl:choose>
    <xsl:when test="$suppress-numbers = '0'
                    and @linenumbering = 'numbered'
                    and $use.extensions != '0'
                    and $linenumbering.extension != '0'">
      <xsl:variable name="rtf">
        <xsl:apply-templates/>
      </xsl:variable>
      <pre class="executable">
        <xsl:call-template name="number.rtf.lines">
          <xsl:with-param name="rtf" select="$rtf"/>
        </xsl:call-template>
      </pre>
    </xsl:when>
    <xsl:otherwise>
      <pre class="executable">
        <xsl:apply-templates/>
      </pre>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>