OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [docbook-apps] callouts in TEX

I created a solution by myself. In case that someone else faces the same
problem I will list my solution afterwards.

First of all I included a definition of a counter in the preamble. In my
case this is done by a special stylesheet which is called preamble.xsl.
I inserted the following definition:

% ------------------------------------------------------------
% Counter für Callouts
% ------------------------------------------------------------
% callout counter
% step the counter, print it and make a label for referencing

Then I wrote a stylessheet which I called verbatim.mod.xsl. This file
overrides the templates of db2latex. I wrote the following templates:

  <xsl:template match="screen">
  <!-- two linebreaks to force a break -->
    <!-- If there is a tag co inside of screen call my callout handling -->
      <xsl:when test="child::co">
        <!-- hand over the content of screen in verbatim mode -->
        <xsl:call-template name="transform-lines">
          <xsl:with-param name="pcdata">
            <!-- verbatim mode is important basic to determine the end
                 of every line -->
            <xsl:apply-templates mode="make.verbatim.mode"/>
      <!-- screen is used as verbatim element without callouts -->
        <!-- use the db2latex stylesheets -->
    <!-- In any case reset counter to zero -->

  <xsl:template match="co" mode="make.verbatim.mode">
    <!-- Replace the content of co with a special character
         which divides the verbatim element from the counter
         and append \co{<id of element>}-->
    <xsl:value-of select="@id"/>

  <!-- read in line by line -->
  <xsl:template name="transform-lines">
    <!-- hand over CDATA from screen -->
    <xsl:param name="pcdata"/>
      <!-- read line -->
      <xsl:when test="contains ($pcdata, '&#xA;')">
        <!-- parameter verb gets as value the current line -->
        <xsl:param name="verb" select="substring-before($pcdata,'&#xA;')"/>
        <!-- Is there any content in that line? -->
          <xsl:if test="string-length($verb)>1">
          <!-- Make the line verbatim. A special character divides
               verbatim an non verbatim environment -->
              <!-- Is there a tag co in the current line -->
              <xsl:when test="contains($verb,'&#xFE;\co{')">
                <!-- If so, the current line should not be appended
                     by the special character -->
                <xsl:value-of select="$verb"/>
                <!-- The current line must be closed by the special
                     character to end verbatim environment -->
                <xsl:value-of select="$verb"/>
       <!-- Go on for the next line -->
       <xsl:call-template name="transform-lines">
       <xsl:with-param name="pcdata"

    <!-- No linebreak found -->
    <!-- Something goes wrong :-( -->
      <xsl:value-of select="$pcdata"/>

<!-- Match Descriptions -->
<xsl:template match="callout">
  <xsl:value-of select="@arearefs"/>

The templates handle callouts that occure in the following form:
$bar <co id="barid"/>
$barfoo <co id="barfooid"/>
  <callout aerearefs="barid">
    <para>Description of bar</para>
  <callout aerearefs="barfooid">
    <para>Description of barfoo</para>

The result would be something like:
$bar      1
$barfoo   2

1 Description of bar
2 Description of barfoo

best regards
Kai Hagemeister

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]