2019-07-06 の docbook-xsl-1.79.2 の時点で、現在受け入れられている回答は、各目次を完成させるのに十分ではありません。
ただし、次の XSL テンプレートはそうです。重要な洞察は、Oxygen XML エディターのデバッガーを使用toc-context
して、ルート要素に正しく設定されている一方で、nodes
変数がまだローカル サブセットであることに気付いたことです。
変更を取り消しましたtoc-context
。root-nodes
代わりに、を選択して新しい変数を作成し、代わりに使用するようにテンプレートを/
編集しましたmake.toc
root-nodes
nodes.
これをカスタマイズ レイヤーに配置すると、すべての目次が完全な目次になります。
<xsl:template name="make.toc">
<xsl:param name="toc-context" select="."/>
<xsl:param name="toc.title.p" select="true()"/>
<xsl:param name="nodes" select="/NOT-AN-ELEMENT"/>
<xsl:variable name="root-nodes" select="/"/>
<xsl:variable name="nodes.plus" select="$root-nodes | d:qandaset"/>
<xsl:variable name="toc.title">
<xsl:if test="$toc.title.p">
<xsl:choose>
<xsl:when test="$make.clean.html != 0">
<div class="toc-title">
<xsl:call-template name="gentext">
<xsl:with-param name="key">TableofContents</xsl:with-param>
</xsl:call-template>
</div>
</xsl:when>
<xsl:otherwise>
<p>
<strong>
<xsl:call-template name="gentext">
<xsl:with-param name="key">TableofContents</xsl:with-param>
</xsl:call-template>
</strong>
</p>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:variable>
<xsl:choose>
<xsl:when test="$manual.toc != ''">
<xsl:variable name="id">
<xsl:call-template name="object.id"/>
</xsl:variable>
<xsl:variable name="toc" select="document($manual.toc, .)"/>
<xsl:variable name="tocentry" select="$toc//d:tocentry[@linkend=$id]"/>
<xsl:if test="$tocentry and $tocentry/*">
<div class="toc">
<xsl:copy-of select="$toc.title"/>
<xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
<xsl:call-template name="toc.list.attributes">
<xsl:with-param name="toc-context" select="$toc-context"/>
<xsl:with-param name="toc.title.p" select="$toc.title.p"/>
<xsl:with-param name="nodes" select="$root-nodes"/>
</xsl:call-template>
<xsl:call-template name="manual-toc">
<xsl:with-param name="tocentry" select="$tocentry/*[1]"/>
</xsl:call-template>
</xsl:element>
</div>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$qanda.in.toc != 0">
<xsl:if test="$nodes.plus">
<div class="toc">
<xsl:copy-of select="$toc.title"/>
<xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
<xsl:call-template name="toc.list.attributes">
<xsl:with-param name="toc-context" select="$toc-context"/>
<xsl:with-param name="toc.title.p" select="$toc.title.p"/>
<xsl:with-param name="nodes" select="$root-nodes"/>
</xsl:call-template>
<xsl:apply-templates select="$nodes.plus" mode="toc">
<xsl:with-param name="toc-context" select="$toc-context"/>
</xsl:apply-templates>
</xsl:element>
</div>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:if test="$root-nodes">
<div class="toc">
<xsl:copy-of select="$toc.title"/>
<xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
<xsl:call-template name="toc.list.attributes">
<xsl:with-param name="toc-context" select="$toc-context"/>
<xsl:with-param name="toc.title.p" select="$toc.title.p"/>
<xsl:with-param name="nodes" select="$root-nodes"/>
</xsl:call-template>
<xsl:apply-templates select="$root-nodes" mode="toc">
<xsl:with-param name="toc-context" select="$toc-context"/>
</xsl:apply-templates>
</xsl:element>
</div>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
注:チャンクされたすべてのページが独自の ToC を取得するわけではないという問題が残っていますが、これはこれとは関係ありません。並べ替えたら、それをどのように行ったかについてコメントを追加します。