Next / Previous / Contents / NM Tech homepage

11.6.3. The fo-lit-block template: Format a literate block

This template formats a programlisting element that contains a literate code fragment. It has one required parameter named file-name, which must contain the name of the file to be displayed.

zdp_fo.xsl
  <xsl:template name="fo-lit-block">
    <xsl:param name="file-name">file-name???</xsl:param>

This template is a slightly modified version of the programlisting template from the stock html/verbatim.xsl file. The first few lines, here, are unaltered from the stock template.

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

The stock template uses the shade.verbatim.style attribute set. Our version substitutes the lit.shading.style attribute set defined above. We also omit the code for the case where $shade.verbatim was false. Everything else here is from the stock template.

zdp_fo.xsl
    <fo:block id="{$id}"
        margin-top="-3pt" white-space-collapse='false'
        white-space-treatment='preserve' linefeed-treatment='preserve'
        xsl:use-attribute-sets="monospace.verbatim.properties 
                                lit.shading.style">
      <xsl:choose>
        <xsl:when test="$hyphenate.verbatim != 0 and 
                        function-available('exsl:node-set')">
          <xsl:apply-templates
              select="exsl:node-set($content)"
              mode="hyphenate.verbatim"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:copy-of select="$content"/>
        </xsl:otherwise>
      </xsl:choose>
    </fo:block>
  </xsl:template>