I would suggest having the two TOCs call different templates, so change the first one to call "brief.table.of.content.titlepage" and write a new template with that name.  You can copy the contents of the template named "table.of.contents.titlepage.recto" (which is the one that actually generates the formatted title) from fo/titlepage.templates.xsl and change it as needed.  If you need to handle translations, you could need to create a new gentext string and call that instead of the stock "TableOfContents" key.

Bob Stayton
Sagehill Enterprises
b...@sagehill.net

On 5/11/2018 1:41 AM, Peter Fleck wrote:

Brilliant Bob, that worked perfectly thank you so much.

The only thing that I need changed is the /shorttoc/ title to be "Brief Contents" rather than "Table of Contents" which will refer to the larger /toc/, though this is not critical - is that possible?

Do I create a second title page that gets called in the following?

       <xsl:if test="$toc.title.p">
         <xsl:call-template name="table.of.contents.titlepage"/>
       </xsl:if>

Thanks again,

Peter


On 10/05/18 23:22, Bob Stayton wrote:

Hi Peter,

I had to do something like that, and here is a sample of the XSL customization that I used.  You may need to adapt it to your usage.

This is a customization of the "division.toc" template found in fo/autotoc.xsl.  Copy that to your customization layer and make the changes as marked by the comments.  Then add the new templates in mode="shorttoc" that follow.  Those templates just call "toc.line" without applying templates to any children, except for the template for "part".  Let me know if this isn't clear or doesn't work.

<xsl:template name="division.toc">
  <xsl:param name="toc-context" select="."/>
  <xsl:param name="toc.title.p" select="true()"/>

  <xsl:variable name="cid">
    <xsl:call-template name="object.id">
      <xsl:with-param name="object" select="$toc-context"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="nodes"
                select="$toc-context/d:part
                        |$toc-context/d:reference
                        |$toc-context/d:preface
                        |$toc-context/d:chapter
                        |$toc-context/d:appendix
                        |$toc-context/d:article
                        |$toc-context/d:topic
                        |$toc-context/d:bibliography
                        |$toc-context/d:glossary
                        |$toc-context/d:index"/>

  <xsl:if test="$nodes">
    <fo:block id="toc...{$cid}"
xsl:use-attribute-sets="toc.margin.properties">
      <xsl:if test="$axf.extensions != 0 and
                    $xsl1.1.bookmarks = 0 and
                    $show.bookmarks != 0">
        <xsl:attribute name="axf:outline-level">1</xsl:attribute>
        <xsl:attribute name="axf:outline-expand">false</xsl:attribute>
        <xsl:attribute name="axf:outline-title">
          <xsl:call-template name="gentext">
            <xsl:with-param name="key" select="'TableofContents'"/>
          </xsl:call-template>
        </xsl:attribute>
      </xsl:if>

      <!-- Changes start here -->
      <xsl:if test="$toc.title.p">
        <xsl:call-template name="table.of.contents.titlepage"/>
      </xsl:if>
      <xsl:apply-templates select="$nodes" mode="shorttoc">
        <xsl:with-param name="toc-context" select="$toc-context"/>
      </xsl:apply-templates>

      <fo:block break-after="page"/>

      <xsl:if test="$toc.title.p">
        <xsl:call-template name="table.of.contents.titlepage"/>
      </xsl:if>
      <xsl:apply-templates select="$nodes" mode="toc">
        <xsl:with-param name="toc-context" select="$toc-context"/>
      </xsl:apply-templates>
    </fo:block>
   <!-- changes end here -->
  </xsl:if>

</xsl:template>

<xsl:template match="*" mode="shorttoc">
  <xsl:param name="toc-context"/>
  <xsl:call-template name="toc.line">
    <xsl:with-param name="toc-context" select="$toc-context"/>
  </xsl:call-template>
</xsl:template>

<xsl:template match="d:part" mode="shorttoc">
  <xsl:param name="toc-context"/>
  <xsl:call-template name="toc.line">
    <xsl:with-param name="toc-context" select="$toc-context"/>
  </xsl:call-template>
  <!-- and any component children of part -->
  <xsl:variable name="nodes" select="d:chapter | d:appendix | d:reference"/>

  <xsl:if test="$nodes">
    <fo:block>
      <xsl:attribute name="margin-left">
        <xsl:call-template name="set.toc.indent"/>
      </xsl:attribute>
      <xsl:apply-templates select="$nodes" mode="shorttoc">
        <xsl:with-param name="toc-context" select="$toc-context"/>
      </xsl:apply-templates>
    </fo:block>
  </xsl:if>
</xsl:template>

By the way, your attempt to use <xsl:call-template name="make.book.tocs"> with params cannot work because that named template is not set up to accept any parameters.  It's like passing undefined arguments to a function.

Bob Stayton
Sagehill Enterprises
b...@sagehill.net
On 5/8/2018 8:16 AM, Peter Fleck wrote:

Hi all,

Is it possible to have multiple TOC's?

I need a short TOC with just <part> and <chapter> titles and then a second TOC following after with <section> for a more detailed TOC.

I tried adding the following to <xsl:template match="d:book">

   <xsl:call-template name="make.book.tocs">
    <xsl:with-param name="toc.max.depth" select="4"/>
    <xsl:with-param name="toc.section.depth" select="0"/>
   </xsl:call-template>
   <xsl:call-template name="make.book.tocs">
    <xsl:with-param name="toc.max.depth" select="4"/>
    <xsl:with-param name="toc.section.depth" select="1"/>
   </xsl:call-template>

But I'm getting a /Previously Used ID error - ID values must be unique within a document /which makes sense.

I know I can manually create a TOC file and include that way - https://tdg.docbook.org/tdg/5.2/toc.html but is there a way to do it automatically and avoid the duplicate ID?

Thanks,

Peter





Reply via email to