title: Generate a TOC of sections under each chapter with DocBook/XSLT-FO
body: <p>I'm using FOP 2.3 and I have the following:</p>
  
  <pre><code>&lt;book&gt;
    &lt;chapter&gt;
      &lt;title&gt;ChA&lt;/title&gt;
      &lt;section&gt;
        &lt;title&gt;Structures&lt;/title&gt;
        &lt;xi:include href="struct1.xml"/&gt;
      &lt;/section&gt;
      &lt;section&gt;
        &lt;title&gt;Functions&lt;/title&gt;
        &lt;xi:include href="function1.xml"/&gt;
      &lt;/section&gt;
    &lt;/chapter&gt;
  &lt;/book&gt;
  </code></pre>
  
  <p>For <code>function1.xml</code> (as an example), I have:</p>
  
  <pre><code>&lt;refentry xml:id="some_func" version="5.0"&gt;
    &lt;refmeta&gt;
      &lt;refentrytitle&gt;SomeFunc&lt;/refentrytitle&gt;
    &lt;/refmeta&gt;
    ...
  &lt;/refentry&gt;
  </code></pre>
  
  <p>Is it possible to...</p>
  
  <ol>
  <li>Not list the sections between the <code>refentry</code>s, but to only list them under the chapter title as a mini ToC?</li>
  <li>List the <code>refentry/refentrytitle</code> values under each section?</li>
  </ol>
  
  <p>For example the output for the beginning of the chapter <em>ChA</em> should look like:</p>
  
  <pre><code>Page X
         ChA
           Structures
             SomeStruct
           Functions
             SomeFunc
  
  Page X+1
         SomeStruct page
  
  Page X+2
         SomeFunc page
  
  Page X+3
         ChB
           Structures
             SomeStruct2
           Functions
             SomeFunc2
  ...
  </code></pre>
  
  <p>Next <em>new</em> page renders every <code>refentry</code> from all sections of chapter <em>ChA</em> sequentially, and are not broken up by sections <em>Structures</em> and <em>Functions</em>.</p>
  
  <p>&nbsp;
  &nbsp;</p>
  
  <p><strong>Edit 1</strong></p>
  
  <p>I was able to prevent the sections to be printed between the manual pages. I copied the <code>section.content</code> template:</p>
  
  <pre><code>&lt;xsl:template name="section.content"&gt;
    &lt;!-- Don't display section --&gt;
    &lt;!-- &lt;xsl:call-template name="section.titlepage"/&gt; --&gt;
    ...
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>As for listing the sections, I found this:</p>
  
  <pre><code>&lt;xsl:template match="chapter"&gt;
    ...
    &lt;fo:page-sequence hyphenate="{$hyphenate}"
                      master-reference="{$master-reference}"&gt;
      ...
      &lt;fo:flow flow-name="xsl-region-body"&gt;
        &lt;xsl:call-template name="set.flow.properties"&gt;
          &lt;xsl:with-param name="element" select="local-name(.)"/&gt;
          &lt;xsl:with-param name="master-reference" select="$master-reference"/&gt;
        &lt;/xsl:call-template&gt;
  
        &lt;fo:block id="{$id}"
                  xsl:use-attribute-sets="component.titlepage.properties"&gt;
          &lt;xsl:call-template name="chapter.titlepage"/&gt;
          &lt;!-- === HERE IS WHERE I AM INSERTING MY CUSTOM TABLE OF CONTENTS === --&gt;
          &lt;xsl:for-each select="self::*/section"&gt;
            &lt;fo:block&gt;
              &lt;xsl:message&gt;DEBUG&gt;&lt;xsl:value-of select="title"/&gt;&lt;/xsl:message&gt;
              &lt;xsl:value-of select="title"/&gt;
  
              &lt;xsl:for-each select="self::*/refentry/refmeta"&gt;
                &lt;fo:block&gt;
                  &lt;xsl:value-of select="refentrytitle"/&gt;
                &lt;/fo:block&gt;
              &lt;/xsl:for-each&gt;
            &lt;/fo:block&gt;
          &lt;/xsl:for-each&gt;
  
        &lt;/fo:block&gt;
  
        &lt;xsl:call-template name="make.component.tocs"/&gt;
  
        &lt;xsl:apply-templates/&gt;
      &lt;/fo:flow&gt;
    &lt;/fo:page-sequence&gt;
  &lt;/xsl:template&gt;
  </code></pre>