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] Multiple TOCs


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
bobs@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





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